fettle v0.1.0 Fettle.Config View Source
Processes configuration for healthchecks into internal structures.
The :fettle
OTP application expects to find configuration under its OTP name,
with at least the mandatory fields specified. e.g.
config :fettle,
system_code: :my_app, # NB mandatory
name: "My Application",
description: "My Application provides...",
panic_guide_url: "https://stackoverflow.com",
initial_delay_ms: 1_000,
period_ms: 30_000,
timeout_ms: 2_000,
checks: [ ... ]
Key | Description | Required or Defaults |
---|---|---|
system_code | System code for report | Required |
schema | Module for report generation | Fettle.Schema.FTHealthCheckV1 |
name | Human-readable name of system | defaults to system_code |
description | Human-readable description of system | defaults to system_code |
initial_delay_ms | Number of milliseconds to wait before running first check | 0 |
period_ms | Number of milliseconds to wait between runs of the same check | 30_000 |
timeout_ms | Number of milliseconds to wait before timing-out a running check | 5000 |
panic_guide_url | URL of documentation for check | 1 2 |
business_impact | Which business function is affected? | 1 |
technical_summary | Technical description for Ops | 1 |
checks | An array of pre-configured health-check config | Optional, see Fettle.add/3 3 |
- Specifies default value for checks. Required only if not specified for every check.
panic_guide_url
can form the base-url for checks which specify a relativepanic_guide_url
.checks
is an array, but each element can be specified as either a map, or aKeyword
list (or any otherEnumerable
that yields key-value pairs).
Fettle uses DeferredConfig to resolve {:system, "ENV_VAR"}
style
tuples using shell enviroment variables; this works for all config values; remember to convert to the
correct type, e.g. period_ms: {:system, "FETTLE_PERIOD_MS", {String, :to_integer}}
,
Link to this section Summary
Types
Tuple which specifies a check (derived from app config)
Top-level configuration for global settings and check defaults (derived from app config)
Functions
Convert a single health check specification from config into a Fettle.Spec
spec, with module and args
default missing, nil or empty keys to matching values in keyword list
ensure required keys are not missing, null, or empty strings
append path parts to top-level config panic_guide_url
if relative path is given in checker
Parses configuration into %Fettle.Config{}
Link to this section Types
spec_and_mod() :: {Fettle.Spec.t, module, init_args :: any}
Tuple which specifies a check (derived from app config)
Top-level configuration for global settings and check defaults (derived from app config)
Link to this section Functions
check_from_config(check :: map | list, config :: Fettle.Config.t) :: spec_and_mod
Convert a single health check specification from config into a Fettle.Spec
spec, with module and args.
Each check is specified as a collection of key-value pairs:
Key | Type | Description | Default/Required |
---|---|---|---|
name | String | Name of check | required |
id | String | Short id of check | Defaults to name |
description | String | Longer description of check | Defaults to name |
panic_guide_url | String | URL of documentation for check | Required, defaults to config |
business_impact | String | Which business function is affected? | Required, defaults to config |
technical_summary | String | Technical description for Ops | Required, defaults to config |
severity | 1-3 | Severity level: 1 high, 3 low | Required, defaults to 1 |
checker | atom | Fettle.Checker module | Required |
args | any | passed as argument for Fettle.Checker module | defaults to [] |
Some fields of the check can be omitted, and the default value from the top-level config will be used
instead; this applies to all fields except name
, full_name
, id
and severity
; if id
is omitted, name
will be used, if full_name
is omitted, name
will be used; severity
defaults to 1
.
panic_guide_url
has special behavior, in that if a path starting with #
or /
is given, then
this is appended to the panic_guide_url
in the top-level configuration properties.
config :health,
system_code: "service-a",
schema: Fettle.Schema.FTHealthCheckV1,
panic_guide_url: "http://co.com/docs/service/healthchecks",
technical_summary: "We'll spend all week repairing the damage.",
checks: [
%{
name: "service-b", # also provides id and full_name if those undefined
panic_guide_url: "#service-b", # appended to top-level url
# technical_summary will come from top-level
business_impact: "No sales",
period_ms: 10_000, # override default for this check only
checker: MyHealth.Spec, # implementation module name
args: [url: "https://service-b.co.com/__gtg"] # for `Fettle.Checker.check/1`
},
%{
...
}
]
default_keys(config :: map, key_defaults :: Keyword.t) :: map
default missing, nil or empty keys to matching values in keyword list
ensure_keys!(config :: map, required_keys :: list) :: map | no_return
ensure required keys are not missing, null, or empty strings
append path parts to top-level config panic_guide_url
if relative path is given in checker.
to_app_config(map | list) :: Fettle.Config.t
Parses configuration into %Fettle.Config{}