For the complete documentation index, see llms.txt. Markdown versions of all docs pages are available by appending .md to any docs URL.
Set up and customize traces
Configure distributed tracing for the agentgateway proxy to send OTLP traces to the enterprise telemetry stack.
The agentgateway proxy does not emit traces by default. To enable tracing, create an EnterpriseAgentgatewayPolicy that points at the enterprise telemetry collector and sets a sampling rate for your traces. When tracing is enabled, the agentgateway proxy emits HTTP, MCP, and LLM spans with attributes that follow the OpenTelemetry semantic conventions for generative AI. All spans are stored in ClickHouse.
Set up an LLM or MCP route.
- To route LLM traffic, see LLM (OpenAI).
- To route MCP traffic, see MCP servers.
Install the management UI for Solo Enterprise for agentgateway. The management UI includes the built-in telemetry stack. The
enterprise-agentgateway-ui-telemetry-collectoraccepts OTLP traces on port4317and automatically routes them to ClickHouse.Important
You can send traces to a different backend, such as Datadog, Jaeger, Grafana Cloud, and others. However, if you do not use the built-in
enterprise-agentgateway-ui-telemetry-collector, traces are not stored in ClickHouse and will not appear in the management UI Tracing page. For details, see Alternative backends.Important
The Tracing page in the management UI displays only LLM and MCP spans. Plain HTTP traffic is captured in ClickHouse, but does not appear in the management UI.
Enable tracing
Create an EnterpriseAgentgatewayPolicy that points the agentgateway proxy at the enterprise telemetry collector.
kubectl apply -f- <<EOF
apiVersion: enterpriseagentgateway.solo.io/v1alpha1
kind: EnterpriseAgentgatewayPolicy
metadata:
name: tracing
namespace: agentgateway-system
spec:
targetRefs:
- kind: Gateway
name: agentgateway-proxy
group: gateway.networking.k8s.io
frontend:
tracing:
backendRef:
name: enterprise-agentgateway-ui-telemetry-collector
namespace: agentgateway-system
kind: Service
port: 4317
protocol: GRPC
randomSampling: "true"
EOFVerify traces
Send an LLM request through the proxy. The following example uses the OpenAI route from the LLM get started guide.
curl "$INGRESS_GW_ADDRESS/v1/chat/completions" -H content-type:application/json -d '{ "model": "gpt-3.5-turbo", "messages": [ { "role": "user", "content": "Compose a poem that explains the concept of recursion in programming." } ] }' | jqcurl "localhost:8080/v1/chat/completions" -H content-type:application/json -d '{ "model": "gpt-3.5-turbo", "messages": [ { "role": "user", "content": "Compose a poem that explains the concept of recursion in programming." } ] }' | jqOpen the management UI and navigate to Tracing to verify that your LLM or MCP request appears in the list.
Port-forward the UI.
kubectl port-forward service/enterprise-agentgateway-ui -n agentgateway-system 4000:80Open the management UI.
Navigate to Tracing and verify that your request appears in the list.
Control sampling rate
Sampling controls how much trace data agentgateway generates. Tracing every request gives complete visibility but adds overhead and increases storage costs. Sampling only a fraction keeps costs low while still capturing enough data to detect issues and understand latency.
Agentgateway has two independent sampling settings. Which one applies depends on whether the incoming request already carries trace context from an upstream client.
| Setting | Applies when | Default |
|---|---|---|
randomSampling | The incoming request carries no trace context, so the proxy decides whether to start a new trace. | false |
clientSampling | The incoming request already carries a trace from an upstream client. | true |
Both settings accept the same value format. For example, set the field to "true" to sample every applicable request, "false" to sample none, or a decimal string such as "0.1" to sample that fraction (10% in this case).
Because clientSampling defaults to "true", agentgateway already follows 100% of traces that a client started, even when randomSampling is "false". This means tracing is off by default for traffic that originates at the gateway, but on for traffic that flows through it as part of a distributed trace from an upstream service.
The following example shows a common production configuration where you follow all traces that clients already started and sample a fraction of requests that originate at the gateway.
kubectl apply -f- <<EOF
apiVersion: enterpriseagentgateway.solo.io/v1alpha1
kind: EnterpriseAgentgatewayPolicy
metadata:
name: tracing
namespace: agentgateway-system
spec:
targetRefs:
- kind: Gateway
name: agentgateway-proxy
group: gateway.networking.k8s.io
frontend:
tracing:
backendRef:
name: enterprise-agentgateway-ui-telemetry-collector
namespace: agentgateway-system
kind: Service
port: 4317
protocol: GRPC
randomSampling: "0.1"
clientSampling: "true"
EOFFilter spans
Use the filter field to write a CEL expression that controls which sampled spans are exported to the telemetry collector. A span is exported only when the expression evaluates to true. The filter runs after sampling, so it applies to all spans already selected by either randomSampling or clientSampling.
The following example exports only spans where the HTTP response code is 400 or greater.
kubectl apply -f- <<EOF
apiVersion: enterpriseagentgateway.solo.io/v1alpha1
kind: EnterpriseAgentgatewayPolicy
metadata:
name: tracing
namespace: agentgateway-system
spec:
targetRefs:
- kind: Gateway
name: agentgateway-proxy
group: gateway.networking.k8s.io
frontend:
tracing:
backendRef:
name: enterprise-agentgateway-ui-telemetry-collector
namespace: agentgateway-system
kind: Service
port: 4317
protocol: GRPC
randomSampling: "true"
filter: 'response.code >= 400'
EOFCommon filter patterns:
| Goal | CEL expression |
|---|---|
| Export only errors | response.code >= 400 |
| Export only LLM requests | has(llm.provider) |
| Export by user | request.headers["x-user-id"] == "user-123" |
| Export errors or LLM requests | response.code >= 400 || has(llm.provider) |
For the full list of available CEL variables, see the CEL variables reference.
Customize span attributes
Agentgateway emits standard OpenTelemetry attributes on every span. You can add custom attributes or remove default ones. Attribute customization applies to all sampled spans, regardless of whether they were selected by randomSampling or clientSampling. For the full list of default attributes, see Span attribute reference.
Note
Customizing span attributes does not apply to policy call child spans, such as spans for ext_authz or rate limiting calls. Those spans have a fixed attribute set.
Add span and resource attributes
Use the attributes.add field to add custom tags to individual spans. Attribute values are CEL expressions that are evaluated on every request, so they can be dynamic.
Use the resources field to describe the agentgateway process itself. Resource values are static values that are added to every span. Your tracing backend uses resource attributes to label and group spans in its service list. The most common resource attribute is service.name, which defaults to agentgateway.
kubectl apply -f- <<EOF
apiVersion: enterpriseagentgateway.solo.io/v1alpha1
kind: EnterpriseAgentgatewayPolicy
metadata:
name: tracing
namespace: agentgateway-system
spec:
targetRefs:
- kind: Gateway
name: agentgateway-proxy
group: gateway.networking.k8s.io
frontend:
tracing:
backendRef:
name: enterprise-agentgateway-ui-telemetry-collector
namespace: agentgateway-system
kind: Service
port: 4317
protocol: GRPC
randomSampling: "true"
resources:
- name: deployment.environment.name
expression: '"production"'
- name: service.name
expression: '"my-agentgateway"'
attributes:
add:
- name: user.id
expression: 'request.headers["x-user-id"]'
- name: request.path
expression: 'request.path'
EOFRemove span attributes
Use the attributes.remove field to drop attributes from spans.
kubectl apply -f- <<EOF
apiVersion: enterpriseagentgateway.solo.io/v1alpha1
kind: EnterpriseAgentgatewayPolicy
metadata:
name: tracing
namespace: agentgateway-system
spec:
targetRefs:
- kind: Gateway
name: agentgateway-proxy
group: gateway.networking.k8s.io
frontend:
tracing:
backendRef:
name: enterprise-agentgateway-ui-telemetry-collector
namespace: agentgateway-system
kind: Service
port: 4317
protocol: GRPC
randomSampling: "true"
attributes:
remove:
- src.addr
- http.version
EOFAlternative backends
The primary setup routes traces to the built-in enterprise telemetry stack. You can route traces to any OTLP-compatible backend by changing the backendRef to point to a different service, or by using the url field to specify an endpoint directly.
Cleanup
Delete the EnterpriseAgentgatewayPolicy resource.
kubectl delete EnterpriseAgentgatewayPolicy tracing -n agentgateway-system