Skip to main content
Configure Cloudflare AI Gateway to send traces to Phoenix, either by exporting the gateway’s spans (no application code) or by instrumenting your application with OpenInference.

Prerequisites

  • A Cloudflare AI Gateway. Create one in the Cloudflare dashboard under AI → AI Gateway.
  • A running Phoenix instance (see Launch Phoenix). To export gateway spans, Cloudflare must be able to reach your Phoenix collector.
  • Python 3.10+ (only to instrument your application).

Launch Phoenix

No uv? pip install arize-phoenix && phoenix serve does the same thing. See Terminal setup for customization.
Phoenix serves its UI and OTLP HTTP on port 6006, and OTLP gRPC on port 4317. For a local instance that’s http://localhost:6006 — leave it running while you work.
To export gateway spans, AI Gateway sends them from Cloudflare’s edge, so Cloudflare must be able to reach your Phoenix collector. A deployed Phoenix endpoint can receive spans directly. To use a local endpoint, expose it with a tunnel such as cloudflared.

Set up tracing

This option does not require application code. The gateway exports a span for each request it proxies.In the Cloudflare dashboard, open your gateway, go to Settings → Otel Integration → Add Destination, and enter these values:
  1. OTLP Traces Endpoint: your Phoenix endpoint with /v1/traces appended (for a local instance exposed through a tunnel, use https://<your-tunnel-hostname>/v1/traces).
  2. Content Type: select Protobuf.
  3. Custom Headers: add x-project-name set to the Phoenix project you want traces to land in. Phoenix creates the project on the first span.
Set Content Type to Protobuf, not the default JSON. Phoenix’s trace endpoint accepts only Protobuf, and a destination left on JSON is rejected before any spans arrive.
If your Phoenix requires an API key, the destination also needs an Authorization value of Bearer <your-phoenix-api-key>. Cloudflare can send this value as a header or read it from a Secrets Store attached to the gateway. Some gateways reject a plain header and require the Secrets Store. Use Cloudflare’s OTel integration docs for the current setup steps.
Save the destination, then send traffic through the gateway. Cloudflare exports spans in batches, so wait a minute or two for them to appear.
When you export gateway spans, you can nest the gateway span under an existing application span instead of starting a new trace. Pass the parent context to the gateway request with these headers:

Add custom metadata

Attach your own key/value metadata to gateway requests with the cf-aig-metadata header (JSON). Cloudflare exports each key and value as a span attribute in Phoenix, so you can filter and group by metadata such as user, team, environment, or tenant.
Do not put secrets or sensitive personal data in metadata. Phoenix stores these values as span attributes visible to anyone with access to the project.

What renders in Phoenix

  • Gateway export: each proxied request is an LLM span with the model name and token counts populated. The provider, cost, and full prompt and response are stored under the span’s Attributes.
  • App instrumentation (OpenInference): spans include the model, token counts, and the prompt and response rendered in the formatted message view.

Troubleshooting

  • No spans arriving (gateway export): confirm Content Type is Protobuf (JSON is rejected), the endpoint ends in /v1/traces, and Cloudflare can reach your Phoenix collector.
  • Spans in the wrong project: set the x-project-name header (gateway export) or project_name in register() (app instrumentation).
  • Nothing yet: Cloudflare exports in batches, so send a few requests and wait a minute or two.

Resources

Cloudflare AI Gateway OTEL docs

OpenTelemetry Gen AI semantics