ExWapp.Telemetry (ExWapp v0.1.5)

Copy Markdown View Source

Optional instrumentation and canonical event list for ExWapp.

Session events use the [:ex_wapp, :session, ...] prefix. Store, app-state, safety, quota, and client events use their corresponding ExWapp domain prefix.

Events are ignored unless the host application configures an adapter:

config :ex_wapp, :telemetry_adapter, :telemetry

Add :telemetry to your application's dependencies to use that backend, or configure a module implementing ExWapp.Telemetry.Adapter. Emission is best effort: an unavailable or failing adapter never interrupts protocol work. Adapter callbacks execute in the caller's process and should return promptly.

Summary

Functions

Attaches one handler to all canonical ExWapp events using the adapter.

Detaches a handler using the configured adapter.

Returns all canonical ExWapp telemetry events.

Emits an event through the configured adapter, or does nothing if disabled.

Types

event_name()

@type event_name() :: [atom()]

handler()

@type handler() :: (event_name(), map(), map(), term() -> term())

Functions

attach_many(handler_id, handler, config \\ nil)

@spec attach_many(handler_id :: term(), handler :: handler(), config :: term()) ::
  :ok | {:error, term()}

Attaches one handler to all canonical ExWapp events using the adapter.

Returns {:error, :telemetry_not_configured} when disabled or {:error, {:unsupported_telemetry_callback, :attach_many}} for an adapter that only supports emission.

detach(handler_id)

@spec detach(term()) :: :ok | {:error, term()}

Detaches a handler using the configured adapter.

Returns an error if instrumentation or adapter handler management is unavailable.

events()

@spec events() :: [event_name()]

Returns all canonical ExWapp telemetry events.

execute(event, measurements, metadata \\ %{})

@spec execute(atom() | [atom()], map(), map()) :: :ok

Emits an event through the configured adapter, or does nothing if disabled.

Atoms expand to the session prefix; lists are passed through unchanged. Adapter errors are ignored so instrumentation cannot fail an operation.