LLM Observability: Metrics, Traces and gen_ai Spans
LLM observability means you can answer, from data you already collect, what every model call did: which model and provider served it, how long it took, how many tokens it used, what it cost, and which governance decision applied. On DVARA, an AI gateway that governs model, tool and agent-to-agent calls, you get that from four signals: a structured access log line, Prometheus metrics, OpenTelemetry spans with the standard gen_ai.* attributes, and an audit record. The log, the trace and the audit record share one trace ID. Metrics and traces tell you how the system behaves. Only the audit record is signed evidence of the governed decision.
Updated November 9, 2026 for DVARA 1.13.0.
This post explains why each signal exists and what to watch. The full reference — every metric, label, endpoint and alert rule — lives in the observability docs. The audit side, for compliance teams, is on AI audit and compliance.
Why does observability matter for AI governance?
A governance claim is only as good as the evidence behind it. "We block unapproved models" needs a record of each block. "We attribute every dollar" needs token counts per workspace. "We can show what happened" needs a trail you can check later.
So an UP health check proves very little. It tells you the process is running. It does not tell you that a request was policy-checked, scanned for personal data, routed, and recorded. Observability on a gateway is about connecting one request to all of that evidence.
Which signal answers which question?
| Signal | The question it answers | Where it stops |
|---|---|---|
| Structured access log | What happened inside this one request? | An operational record, not the tamper-evident audit chain |
| Prometheus metrics | Is behaviour changing across many requests? | A counter cannot explain one decision |
| OpenTelemetry trace | Where did this request spend its time? | Exported only once you configure a collector |
| Audit record | Which governed action and outcome did DVARA record? | Open Source writes a local file; search and export are Enterprise |
You need all four. If you rely on metrics alone, you cannot explain an incident. If you rely on audit records alone, you cannot see latency drift.
What does one governed request leave behind?
The quickest way to see the signals is to follow one request. This walk-through uses the Open Source quickstart, which runs the built-in Mock provider and a policy that denies the model mock/unapproved. Every field below comes from the docs or the gateway's own tests. Values such as IDs change on each run.
1. The request and its correlation ID. Send the denied model:
curl -s -i http://localhost:8080/v1/chat/completions \
-H "Authorization: Bearer $DVARA_API_KEY" \
-H 'Content-Type: application/json' \
-d '{"model": "mock/unapproved", "messages": [{"role": "user", "content": "Hello"}]}'
DVARA refuses the call before it reaches any provider, and returns a trace ID with the refusal:
{
"error": {
"message": "mock/unapproved is not an approved model",
"type": "policy_violation",
"code": "policy_denied",
"trace_id": "99115c790f614434b3d5bda41eecacc1"
}
}
The same ID is in the X-Trace-ID response header. If your client sends its own X-Trace-ID (1–128 letters, digits, ., _, : or -), DVARA echoes that value instead.
2. The access log line. JSON logging is on by default. Each /v1/* request writes one record when it completes, and a stream is recorded when it finishes. Search your logs for the trace ID. The record can carry workspace_id, api_key (an opaque key ID, never the bearer token), model, provider, status, latency_ms, cache_status, stream, token counts and error_code. Fields that do not apply are left out.
3. The metrics. A refused call still counts. Every /v1/* request increments gateway_requests_total with its status, so this refusal shows up as status="403". Watch for a rise in 400, 401, 403 and 429 responses: it is how probing with stolen keys or alternate paths becomes visible.
4. The audit record. With DVARA_AUDIT_FILE_PATH and DVARA_AUDIT_HMAC_SECRET set, the Open Source gateway writes a POLICY_DENIED event and a GATEWAY_RESPONSE event. Each record carries a sequence number, the previous record's hash and an HMAC. From 1.13.0 the GATEWAY_RESPONSE payload also carries trace_id, the same value the client saw. So you can go from the client's error to the signed record in one search.
5. The span. When the call does reach a provider, the provider span carries the gen_ai.* attributes. The gateway's test for a non-streaming chat call to OpenAI checks these exact values:
| Attribute | Value in the test |
|---|---|
gen_ai.system | openai |
gen_ai.operation.name | chat |
gen_ai.request.model | gpt-4o |
gen_ai.request.max_tokens | 256 |
gen_ai.request.temperature | 0.7 |
gen_ai.response.model | gpt-4o-2024 |
gen_ai.response.id | resp-1 |
gen_ai.response.finish_reasons | stop |
gen_ai.usage.input_tokens | 10 |
gen_ai.usage.output_tokens | 20 |
Note that gen_ai.request.model and gen_ai.response.model differ. The request asked for an alias and the provider answered with a dated model. That difference is exactly what you want in a trace when an answer changes and nobody changed the code.
What are the OpenTelemetry GenAI semantic conventions?
The GenAI semantic conventions are OpenTelemetry's shared names for model-call telemetry: the provider, the operation, the requested and returned model, token usage and finish reasons. If your gateway emits them, any OpenTelemetry backend stores them as ordinary span attributes, and GenAI-aware backends can read them as model calls without custom parsing.
On the DVARA LLM Gateway they are on by default. Set management.tracing.genai-semconv.enabled=false to turn them off; the gateway's own provider and model span attributes stay.
What is set depends on the call:
| Call | gen_ai.* attributes on the span |
|---|---|
Non-streaming chat (gateway.provider.chat) | All ten in the table above, when the request and response carry them |
Streaming chat (gateway.provider.stream) | Request attributes only: system, operation, request model, max tokens, temperature |
Embeddings (gateway.provider.embed) | System, operation (embeddings) and request model |
gen_ai.request.max_tokens and gen_ai.request.temperature appear only when the request set them.
What should you put on the dashboard first?
Start with the signals that describe the governed request path. All of these are in the Open Source gateway:
| Panel | Metric | Why it matters |
|---|---|---|
| Traffic | gateway_requests_total by workspace, model, status | Who is calling what, and how often it is refused |
| Latency | gateway_latency_seconds by provider | Where failover and timeout decisions get validated |
| Tokens | gateway_tokens_total by workspace, model, direction | The cost driver |
| Cost | gateway_cost_dollars_total by workspace, model, provider | Spend as the gateway calculated it |
| Provider errors | gateway_provider_errors_total by provider, error code | Which provider is failing and how |
| Resilience | gateway_retries_total, gateway_fallbacks_total | Whether failover is a quiet safety net or a daily cost |
| Guardrails | gateway_guardrail_blocked_total by workspace, category | Requests refused by a guardrail |
On the Enterprise platform, add the signals that show governance itself is working. For example, gateway_audit_chain_broken_total rises when chain verification finds a changed or missing record. The observability docs list each one with what a bad value means.
Two habits save pain later. Do not put trace or session IDs in metric labels; they belong in traces. And do not alert on a metric until the feature that creates it is on and the series exists.
How do you turn the signals on?
Two settings need you to act; the rest are on by default.
# Prometheus scrapes need their own key (no default). Without it, /actuator/prometheus returns 401.
DVARA_ACTUATOR_METRICS_API_KEY=<your-metrics-api-key>
# Traces are created but not exported until you name a collector (blank by default).
OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4318
# Sampling defaults to 1.0 (every request). Lower it in production.
TRACING_SAMPLING_PROBABILITY=0.1
From 1.13.0, OTEL_EXPORTER_OTLP_ENDPOINT is the collector's base URL and the gateway adds /v1/traces. Use a metrics key that differs from DVARA_ACTUATOR_API_KEY; DVARA warns at startup when they match.
What are the limits?
Be clear about what these signals do not do:
- Metrics and logs are not evidence. Only the audit chain is HMAC-signed and hash-chained, and it is tamper-evident, not change-proof: it detects a changed or missing record, but it does not stop someone with storage access from deleting one.
- Open Source audit is a local file, off until configured. With
DVARA_AUDIT_FILE_PATHblank (the default), audit events are dropped. Audit search, export and compliance evidence are Enterprise. - In Open Source, only
GATEWAY_RESPONSEcarries the trace ID. Policy and PII events in the file do not, so match them by time, workspace, model and status. - Streams have fewer
gen_ai.*attributes. Token usage and the response model are not on the streaming span. - The provider attribute uses the older name. DVARA emits
gen_ai.system. The current OpenTelemetry registry marks it deprecated in favour ofgen_ai.provider.name(checked November 9, 2026), and the GenAI conventions are still at Development status. A backend that reads only the new name will not see the provider from this attribute. - After a failover, the span names the first provider. The provider span is opened for the provider routing picked. The access log, metrics and audit record name the provider that served the call, and
gateway_fallbacks_totalcounts the switch. - MCP and A2A signals are Enterprise and appear only with traffic. Their metrics and spans exist once those planes handle calls.
A checklist before production
Prove each of these with one test request and one deliberate failure:
- The response carries an
X-Trace-ID. - The access log is searchable by that ID.
- Request, latency, token and error metrics are being scraped, with the metrics key.
- A trace reaches your collector, if you need traces.
- The audit record is present: an Enterprise audit row, or a line in the Open Source audit file.
- A synthetic alert reaches the person who will act on it.
If any link is missing, the system is observable only in theory.
Try it
DVARA keeps a tamper-evident audit trail, runs policy and personal-data checks on every call, and stops agents that loop; routing and OpenAI compatibility come standard. To see the signals on your own machine, run the Open Source quickstart with an audit file set, send one allowed and one denied request, and follow both trace IDs through the log, the metrics and the audit file.