# `ADK.Telemetry.DebugHandler`
[🔗](https://github.com/zeroasterisk/adk-elixir/blob/main/lib/adk/telemetry/debug_handler.ex#L1)

Telemetry handler that captures ADK events into `ADK.Telemetry.SpanStore`.

Attaches to all `ADK.Telemetry.events()` `:stop` events and builds span-like
maps that are stored by event_id and session_id for the debug/trace HTTP endpoints.

## Usage

Called automatically during application startup. Can also be attached manually:

    ADK.Telemetry.DebugHandler.attach()

## Span Format

Each captured span is a map with:

    %{
      name: "adk.agent.stop",
      span_id: "a1b2c3...",
      trace_id: "d4e5f6...",
      start_time: 1710000000.0,
      end_time: 1710000001.5,
      duration_ms: 1500.0,
      attributes: %{agent_name: "my_agent", session_id: "sess-1", ...}
    }

# `attach`

```elixir
@spec attach() :: :ok | {:error, :already_exists}
```

Attach the debug handler to all ADK telemetry stop events.

# `detach`

```elixir
@spec detach() :: :ok | {:error, :not_found}
```

Detach the debug handler.

---

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