Telemetry handler that captures SubAgent events for trace logging.
This handler attaches to all SubAgent telemetry events, builds v2 flat
event envelopes, and forwards them to the Collector for writing to a
JSONL file. Events are filtered by process — only events from processes
that have an active collector in their TraceContext collector stack
are captured.
On run.start events, the handler extracts the full agent config from
telemetry metadata and includes it in the event data so the Collector
can emit a deduplicated agent.config event.
Summary
Functions
Attaches the handler to telemetry events.
Detaches the handler from telemetry events.
Returns the list of telemetry events this handler subscribes to.
Handles a telemetry event.
Functions
Attaches the handler to telemetry events.
Parameters
handler_id- Unique identifier for this handler attachmentcollector- The Collector process to write events totrace_id- The trace ID for this trace sessionmeta- Additional metadata to include with events (optional)
Examples
Handler.attach("my-trace", collector_pid, "trace-123")
@spec detach(String.t()) :: :ok | {:error, :not_found}
Detaches the handler from telemetry events.
Parameters
handler_id- The handler ID that was used during attachment
Examples
Handler.detach("my-trace")
@spec events() :: [[atom()]]
Returns the list of telemetry events this handler subscribes to.
Handles a telemetry event.
Events are only captured if the calling process has the config's collector
in its active TraceContext collector stack.
This function never raises — errors are logged at debug level to avoid crashing the caller's execution.