ForgeOpsTracker.Configuration (forge_ops_tracker v0.1.0)

Copy Markdown View Source

Holds a single ForgeOps DSN plus everything else the client needs to build and deliver events. Mirrors gems/forge_ops_tracker's Configuration -- a single Sentry-style DSN string carries both the ingestion URL and the project's api_key: https://<api_key>@host/api/v1/events.

Backed by a GenServer (started under ForgeOpsTracker.Application's supervision tree, the same "shared mutable state" role every other SDK in this repo's own Configuration class plays) rather than a plain struct a caller has to thread through every call -- Elixir has no language-level singleton the way Ruby's module-level state or a Kotlin object gives other clients in this repo for free, so a supervised process is the idiomatic BEAM equivalent.

Summary

Functions

The DSN's userinfo component, percent-decoded -- nil if the DSN is unset or malformed.

Returns a specification to start this module under a supervisor.

The current configuration.

The ingestion URL with credentials stripped out (they travel as the Authorization header instead).

Updates the configuration via a function that receives the current struct and returns the new one -- ForgeOpsTracker.Configuration.update(&%{&1 | dsn: "..."}) -- the closest Elixir equivalent to every other SDK's own mutable Configuration object, without actually mutating anything (this replaces the GenServer's state, doesn't mutate a shared struct in place).

Types

t()

@type t() :: %ForgeOpsTracker.Configuration{
  app_module_prefix: String.t() | nil,
  dsn: String.t() | nil,
  enabled_environments: MapSet.t(String.t()),
  environment: String.t(),
  logger: (String.t() -> any()) | nil,
  queue_size: pos_integer(),
  release: String.t() | nil,
  scrub_pii: boolean(),
  server_name: String.t() | nil,
  timeout: pos_integer()
}

Functions

api_key(config)

@spec api_key(t()) :: String.t() | nil

The DSN's userinfo component, percent-decoded -- nil if the DSN is unset or malformed.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

enabled?(config)

@spec enabled?(t()) :: boolean()

get()

@spec get() :: t()

The current configuration.

ingestion_uri(config)

@spec ingestion_uri(t()) :: String.t() | nil

The ingestion URL with credentials stripped out (they travel as the Authorization header instead).

log(configuration, message)

@spec log(t(), String.t()) :: :ok

update(fun)

@spec update((t() -> t())) :: t()

Updates the configuration via a function that receives the current struct and returns the new one -- ForgeOpsTracker.Configuration.update(&%{&1 | dsn: "..."}) -- the closest Elixir equivalent to every other SDK's own mutable Configuration object, without actually mutating anything (this replaces the GenServer's state, doesn't mutate a shared struct in place).

If fun raises, that's re-raised here, in the calling process, with its original stacktrace -- not left to crash this shared, process-wide GenServer (which every other part of a host app calling ForgeOpsTracker also depends on) over what's usually just a caller bug, like an unknown configuration key.