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: [ ... ]
KeyDescriptionRequired or Defaults
system_codeSystem code for reportRequired
schemaModule for report generationFettle.Schema.FTHealthCheckV1
nameHuman-readable name of systemdefaults to system_code
descriptionHuman-readable description of systemdefaults to system_code
initial_delay_msNumber of milliseconds to wait before running first check0
period_msNumber of milliseconds to wait between runs of the same check30_000
timeout_msNumber of milliseconds to wait before timing-out a running check5000
panic_guide_urlURL of documentation for check1 2
business_impactWhich business function is affected?1
technical_summaryTechnical description for Ops1
checksAn array of pre-configured health-check configOptional, see Fettle.add/3 3
  1. Specifies default value for checks. Required only if not specified for every check.
  2. panic_guide_url can form the base-url for checks which specify a relative panic_guide_url.
  3. checks is an array, but each element can be specified as either a map, or a Keyword list (or any other Enumerable 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)

t()

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

Link to this type spec_and_mod() View Source
spec_and_mod() :: {Fettle.Spec.t, module, init_args :: any}

Tuple which specifies a check (derived from app config)

Link to this type t() View Source
t() :: %Fettle.Config{business_impact: String.t, description: atom | String.t, initial_delay_ms: integer, name: atom | String.t, panic_guide_url: String.t, period_ms: integer, schema: atom, system_code: atom | String.t, technical_summary: String.t, timeout_ms: integer}

Top-level configuration for global settings and check defaults (derived from app config)

Link to this section Functions

Link to this function check_from_config(check, config) View Source
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:

KeyTypeDescriptionDefault/Required
nameStringName of checkrequired
idStringShort id of checkDefaults to name
descriptionStringLonger description of checkDefaults to name
panic_guide_urlStringURL of documentation for checkRequired, defaults to config
business_impactStringWhich business function is affected?Required, defaults to config
technical_summaryStringTechnical description for OpsRequired, defaults to config
severity1-3Severity level: 1 high, 3 lowRequired, defaults to 1
checkeratomFettle.Checker moduleRequired
argsanypassed as argument for Fettle.Checker moduledefaults 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`
    },
    %{
      ...
    }
  ]
Link to this function default_keys(config, key_defaults) View Source
default_keys(config :: map, key_defaults :: Keyword.t) :: map

default missing, nil or empty keys to matching values in keyword list

Link to this function ensure_keys!(config, required_keys) View Source
ensure_keys!(config :: map, required_keys :: list) ::
  map |
  no_return

ensure required keys are not missing, null, or empty strings

Link to this function interpolate_panic_guide_url(check_url, config_url) View Source

append path parts to top-level config panic_guide_url if relative path is given in checker.

Link to this function to_app_config(map_or_kws) View Source
to_app_config(map | list) :: Fettle.Config.t

Parses configuration into %Fettle.Config{}