Skip to main content
A telemetry block makes the Sidecar push OpenTelemetry signals to a collector you run. One Grafana, Honeycomb or Datadog then shows every Sidecar: statements per lane and verdict, denials by source, and a statement’s latency split into the Sidecar’s own policy cost, the AI analyzer, a human approval hold, and the upstream itself. Nothing is built when the block is absent. The data path has no telemetry code in it until you add one.
config.yaml
Three signals, three switches. Metrics are on as soon as the block exists. Traces turn on with a positive sample_ratio. Events — the audit trail as log records — turn on with events.enabled.

Configuration

The block is validated with the rest of the file, so --validate and the Control Plane both refuse a bad endpoint before anything starts. The SDK’s OTEL_EXPORTER_OTLP_* environment variables are not read: the block is the configuration.
A Sidecar managed by a Control Plane reports the telemetry capability in its handshake. The Control Plane serves the block only to a Sidecar whose build decodes it, so an older Sidecar never receives a key it would refuse.

What every signal carries

The resource identifies the process: The schema URL is https://hoop.dev/schemas/sidecar-telemetry/1.2. An attribute or series added bumps the minor version. One renamed or removed bumps the major, because a dashboard written against the old name goes dark. Schema versions lists what each version added. Attributes shared by the signals: Principal, session id, tables and statement text are never on a metric: they are unbounded, and they belong on the span and the log record.

Metrics

hoop.analyzer.kind is classify for a risk classification and decide for the approval agent or the hand-off agent. Filter on classify where a query means classification. hoop.action on an ai-handoff level is the action the hand-off resolved to, never ai-handoff. Counters survive a hot reload. The three analyzer families are the ones GET /metrics serves in the Prometheus text format, which stays as it is; see Risk Analysis. Through a collector’s Prometheus exporter the names read hoop_sidecar_statements_total, hoop_sidecar_statement_duration_seconds_bucket, and the attributes hoop_lane, hoop_stage, and so on.

Where a statement’s time goes

hoop.sidecar.statement.duration has one series per stage of a statement’s life, so you can read what the Sidecar costs apart from what the database or API costs: review is its own stage so a ten-minute approval does not read as a slow policy. A listener in return mode (review_mode: return) shows no wait here: the client is denied at once and resends after approval, and only the Control Plane knows the time between filing and approval. hoop.pairing on the upstream stage says how exact the measurement is:
  • exact — the protocol pairs request and response itself: one gRPC call, or HTTP/1, where responses answer requests in order.
  • unpipelined — postgres, mysql, mssql, mongodb, oracle, clickhouse. Their codecs do not expose which response answers which request, so the sample is taken only when one request is outstanding and dropped when the client pipelines. The series describes unpipelined exchanges and never guesses. An extended-protocol client that sends two statements per query is therefore not sampled.
Every other stage carries hoop.outcome as allow or deny.
The histogram bucket bounds, in seconds: 0.00005, 0.0001, 0.00025, 0.0005, 0.001, 0.0025, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10, 30, 60, 300 and 600. A local policy stage takes microseconds and lands in the first bucket. A quantile interpolates inside its bucket, so a stage under 50 µs reads between 0 and 50 µs. For its mean, divide _sum by _count. Older versions start the bounds at 0.001. During a rollout, the bounds under 1 ms count only the upgraded Sidecars, so a quantile summed over versions is wrong: with equal traffic at 20 µs from old and new versions, p95 reads about 950 µs. For this reason the quantile queries above keep service_version in the by clause. That label exists only when the collector turns resource attributes into labels; without it, read only the bounds from 1 ms up until every Sidecar runs the new bounds.

Control Plane handshakes

A Sidecar connected to a Control Plane handshakes once at boot and again on every heartbeat, about once a minute. From version 1.325.0, hoop.sidecar.control_plane.handshakes counts each one by how it went: boot is counted once, when the exporter starts: a Sidecar that reaches that point had its boot handshake answered. A failed heartbeat changes nothing on the data path. The lanes keep serving the last configuration. With events.enabled, each failure is also a log record: body control_plane_handshake, severity WARN, with hoop.handshake.kind and hoop.outcome and nothing else. The error text stays in the Sidecar’s own log, because it can carry the Control Plane’s response body or a redirect location. The record is not an audit event, and GET /stats does not count it in events_sent. With events off, only the counter goes out. The Control Plane cannot report its own outage. Its fleet can: the counter keeps coming from every Sidecar while the Control Plane is down. The Control Plane’s own signals are on OpenTelemetry for the Control Plane.

Traces

traces.sample_ratio above zero opens one span per exchange, with the statements and their stages under it:
The sampling decision is taken once, at the exchange, so every statement of a sampled connection is in, and a 1% ratio costs 1%. An mcp lane opens no exchange span: each tool call it judges is a trace of its own, sampled on its own. The statement span carries hoop.direction, hoop.operation, the HTTP method, path and status, the database and tables, then at the end hoop.verdict, hoop.deny.source, hoop.rule, hoop.risk_level. A denied statement’s span has an error status naming the rule. The exchange span carries hoop.principal and hoop.session_id. The upstream measurement is an event on the enclosing span. The OPA decision and the analyzer’s provider call carry the stage’s span as a W3C traceparent header, so a Rego service or a model gateway that is itself traced joins the same trace. Statement text is never on a span.

Events

events.enabled adds a sink to the audit chain that sends every event as a log record. The body is the kind: session_start, statement, violation, masked, error, session_end. Severity is WARN for violation and masked, ERROR for error, INFO otherwise. A record written under a sampled span carries its trace and span id, so a backend that stores both joins the violation to the trace that produced it. The record goes through the same redaction as the audit file and the Control Plane copy. hoop.statement is a sha256: fingerprint unless events.statement_text: true, because the collector is a new place audit data leaves the process; the file keeps the text under the audit block’s own redact_statements. The sink never fails a write and never blocks a statement: a bounded queue drops the oldest record when the collector falls behind, and GET /stats reports two counters:
events_sent counts the records handed to the queue. events_dropped counts the records the full queue removed before export. Neither counter shows delivery: events_sent minus events_dropped also holds records still in the queue, records whose export failed, and records the collector refused. Both are zero when events.enabled is off.
The audit file stays the record of truth. The log records are a copy for alerting and correlation, with a bounded queue that drops under pressure. Do not point a compliance process at them.

Alerts

Alerts live in your backend. Four worth having, in PromQL:
The last three rules read each series as (increase(X[W]) > 0) or ((X > 0) unless X offset W), then aggregate. An OpenTelemetry counter can first appear already above zero, so rate(X[W]) > 0 can miss an event that has no earlier sample. The second half catches that series. increase() handles a counter drop it can see in the window, such as a restart: a Sidecar keeps its service.instance.id across restarts, so its counters start again on the same labels. The rules have two limits. A restart whose first failure has the value the old process last exported (1 after 1) reads as no change, so the alert waits for the next failure. A Prometheus with no history fires once on a counter that failed before. The Envoy compose stack carries the fleet rule with tests: deploy/docker-compose/envoy-stack/telemetry/alerts.yml. And on the log records, a violation burst for one hoop.principal, which no metric can express because the principal is only on the record.

When the collector is down

Nothing changes for the client. Exports fail, one warning per 30 seconds per message reaches the Sidecar’s log, and traffic is unaffected. With a telemetry block the data path costs one instrument record per hook, with attribute sets built once per lane; without one it costs nothing. Shutdown flushes once, bounded by three seconds, after every listener has closed.

Schema versions


A local collector

The Envoy compose stack in the hoop repository, deploy/docker-compose/envoy-stack, ships an OpenTelemetry Collector, Prometheus and a Grafana with a provisioned hoop sidecar dashboard. Its sidecar/config.yaml carries the block above with every signal on, and docker compose logs otel-collector shows the spans and the audit records arrive. For your own collector, this is the receiving side:
otel-collector.yaml

Next

Risk Analysis

The analyzer families in Prometheus text format, and the queries that tune timeout_sec.

Config File Reference

Every section, inheritance between listeners, and what startup refuses.

Agent Approvals

Hold and return modes, which decide whether the review stage shows a wait.

Architecture

The trace of one connection through the gate, which is what the stages measure.