# `Excessibility.TelemetryCapture.Enrichers.EctoQueries`
[🔗](https://github.com/lessthanseventy/excessibility/blob/v0.18.1/lib/telemetry_capture/enrichers/ecto_queries.ex#L1)

Enriches timeline events with Ecto query information.

Provides two mechanisms:
1. **Telemetry handler** — attaches to `[:ecto, :query]` events during test
   execution. Call `attach/0` before tests and `detach/0` after.
2. **Enricher callback** — reads captured queries from opts or the query store.

## Example Output

    %{
      ecto_queries: [
        %{source: "products", operation: :select, duration_ms: 1.2, query: "SELECT..."}
      ],
      ecto_query_count: 2,
      ecto_total_query_ms: 2.0
    }

# `attach`

Attaches a telemetry handler to `[:ecto, :query]` events.

# `build_query_record`

Builds a normalized query record from an Ecto `[..., :query]` telemetry
event's measurements and metadata. Shared so the live capture layer
(`Excessibility.TelemetryCapture`) attributes queries to events using the
same shape this enricher reads back.

# `clear`

Clears all recorded queries.

# `cost`

Returns the cost of this enricher.

# `detach`

Detaches the telemetry handler.

# `enrich`

Enriches assigns with Ecto query data.

Reads queries from the `:ecto_queries` key in opts.
Returns query list, count, and total duration.

# `get_queries`

Returns all recorded queries in order.

# `name`

Returns the enricher name.

# `record_query`

Records a query in the store.

# `start_store`

Starts the Agent-based query store.

# `stop_store`

Stops the query store.

Idempotent and race-safe: safe to call concurrently from multiple
`on_exit` callbacks when tests share the globally-named Agent.

---

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