TraceGuard.Config (trace_guard v0.1.0)

Copy Markdown View Source

Internal module. Not part of TraceGuard's public API: it may change in any release. Use the functions in TraceGuard instead.

Validated TraceGuard configuration.

Configuration is read from the :trace_guard application environment when the application starts, validated, and cached in :persistent_term so the request hot path never re-validates it.

config :trace_guard,
  failure_status: 500,
  max_events: 100,
  max_reports: 50,
  redact_keys: ["card_number"],
  capture_request_headers: ["accept", "content-type"],
  ecto_telemetry_prefixes: [[:my_app, :repo]]

See docs/configuration.md for the full reference.

Summary

Functions

Sensitive keys that are always redacted, in normalized form.

Default option values.

Returns the active configuration.

Loads, validates and caches configuration from the application environment.

Validates opts, merges them over the defaults and caches the result.

Validates opts without caching them.

Types

t()

@type t() :: %TraceGuard.Config{
  capture_exception_message: boolean(),
  capture_path: boolean(),
  capture_path_params: boolean(),
  capture_request_headers: [String.t()],
  capture_sql: boolean(),
  drop_record_ttl: pos_integer(),
  ecto_telemetry_prefixes: [[atom()]],
  enabled: boolean(),
  failure_status: 100..599,
  incoming_header: String.t() | nil,
  max_drop_records: pos_integer(),
  max_events: pos_integer(),
  max_pending_reports: pos_integer(),
  max_reports: pos_integer(),
  max_stacktrace_frames: non_neg_integer(),
  max_string_length: pos_integer(),
  max_task_collectors: pos_integer(),
  redact_keys: [String.t()],
  response_header: String.t() | nil,
  storage: module() | {module(), keyword()},
  task_collector_lifetime: pos_integer(),
  task_drain_timeout: non_neg_integer()
}

Functions

default_redact_keys()

@spec default_redact_keys() :: [String.t()]

Sensitive keys that are always redacted, in normalized form.

defaults()

@spec defaults() :: keyword()

Default option values.

get()

@spec get() :: t()

Returns the active configuration.

Falls back to loading from the application environment if nothing has been cached yet (for example when TraceGuard functions are called before the application has started).

load!()

@spec load!() :: t()

Loads, validates and caches configuration from the application environment.

put!(opts)

@spec put!(keyword()) :: t()

Validates opts, merges them over the defaults and caches the result.

Raises ArgumentError on invalid configuration. Intended for application start-up and tests; changing configuration at runtime rewrites a :persistent_term, which triggers a global GC and should be rare.

validate!(opts)

@spec validate!(keyword()) :: t()

Validates opts without caching them.