# `TraceGuard.Config`
[🔗](https://github.com/HataluliRandima/trace_guard/blob/v0.1.0/lib/trace_guard/config.ex#L1)

**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.

# `t`

```elixir
@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()
}
```

# `default_redact_keys`

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

Sensitive keys that are always redacted, in normalized form.

# `defaults`

```elixir
@spec defaults() :: keyword()
```

Default option values.

# `get`

```elixir
@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!`

```elixir
@spec load!() :: t()
```

Loads, validates and caches configuration from the application environment.

# `put!`

```elixir
@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!`

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

Validates `opts` without caching them.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
