Spectre.Telemetry (Spectre v0.3.0)

Copy Markdown View Source

Privacy-safe operational telemetry boundary.

Spectre emits through the standard :telemetry module when the host has it installed. Tests and lightweight hosts may instead provide a :telemetry_handler callback in runtime options. Telemetry is observational: callback failures never alter a turn.

Summary

Functions

Emits one privacy-safe event under the [:spectre, ...] prefix.

Functions

emit(event, measurements \\ %{}, metadata \\ %{}, opts \\ [])

@spec emit([atom()], map(), map(), keyword()) :: :ok

Emits one privacy-safe event under the [:spectre, ...] prefix.

When :telemetry is installed, Spectre calls :telemetry.execute/3. A host may also pass telemetry_handler: as an arity-three function or {module, function} tuple. Both handlers receive the prefixed event, measurements, and metadata.

Spectre.Telemetry.emit(
  [:execution, :stop],
  %{duration_us: 850},
  %{outcome: :ok, kind: :action}
)

Telemetry is observational. Invalid handlers, exceptions, exits, and throws are contained and the function always returns :ok. Callers must keep metadata free of prompts, conversation text, credentials, and raw adapter errors.