New Relic integration
The New Relic integration reports every gateway request to New Relic, where it appears alongside your application data with the model, provider, token usage, cost, latency and the calling key and team. The gateway sends this data as OpenTelemetry spans to New Relic's OTLP endpoint, so nothing extra has to be installed in the gateway image.
Set SPANWAY_OTEL_V2=true on the gateway to use it. The newrelic callback then runs as a preset of the OpenTelemetry logger. The gateway images do not include the New Relic Python agent, and without SPANWAY_OTEL_V2=true the callback looks for that agent, logs a warning that it is missing and turns itself off.
A real-world scenario
An operations team monitors all of its services in New Relic and gets paged from there. They add the gateway as one more application. Model calls now appear in New Relic AI monitoring with their cost and latency, the existing error rate alert covers provider failures, and the team never has to open a second tool to see why the checkout assistant is slow.
Turn it on from the Admin UI
- Set
SPANWAY_OTEL_V2=truein the gateway environment and restart the gateway. - Sign in as a proxy admin and open Settings, then Logging & Alerts. Click Add Callback.
- Pick New Relic in the Callback dropdown and fill in the license key. The app name field is only read by the agent mode, so the spans are named by
OTEL_SERVICE_NAMEinstead. - Click Add Callback. The table shows a
newrelicrow. - Send one request through the gateway, then look for it in New Relic as described below.
The row's Test action and GET /health/services?service=newrelic check the New Relic Python agent, which the gateway images do not include, so they report unhealthy with a message that the integration is disabled even when the spans arrive. Check the data in New Relic instead.
Turn it on in the config file
spanway_settings:
callbacks: ["newrelic"]
| Variable | Purpose |
|---|---|
SPANWAY_OTEL_V2 | Set to true. This is what makes the callback send OpenTelemetry spans. Required. |
NEW_RELIC_LICENSE_KEY | Ingest license key of the New Relic account. Required. |
NEW_RELIC_REGION | us or eu, the New Relic data center the spans go to. Defaults to us. |
NEW_RELIC_AI_MONITORING_RECORD_CONTENT_ENABLED | Set to true to send prompt and response content on the span, or false to send only usage and metadata. When it is not set, the content setting of the OpenTelemetry logger applies, which sends no content by default. |
OTEL_SERVICE_NAME | Service name the spans carry in New Relic. Defaults to spanway. |
Check that data arrives
curl http://localhost:4000/v1/chat/completions \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "gpt-5.5", "messages": [{"role": "user", "content": "Say hello"}]}'
Expected result: a 200 with the model's answer, and within a minute New Relic lists a service named spanway (or your OTEL_SERVICE_NAME) with a span for the call that carries the model, provider, token counts and cost.
What is reported
Each request produces a span with the model, provider, request id, token counts, cost and duration, plus the identity fields the gateway attaches to every log entry, using the OpenTelemetry gen_ai attribute names that New Relic reads natively. Failed requests produce spans marked as errors with the exception type. Message content is left out unless you turn it on, which is the right default for regulated workloads.
Per-team accounts
Teams can report to their own New Relic account by attaching the newrelic callback with their own license key in newrelic_api_key and, for the EU data center, newrelic_region: eu in callback_vars, as described in team logging. This needs SPANWAY_OTEL_V2=true on the gateway.
Errors
| Status | Where | Meaning | Fix |
|---|---|---|---|
403 Only proxy admins can trigger the New Relic test event. | GET /health/services?service=newrelic | The caller is not a proxy admin. | Use a proxy admin key. |
status: unhealthy saying the integration is disabled | GET /health/services?service=newrelic or the Test action | This check needs the New Relic Python agent, which the gateway images do not include. It says nothing about the OpenTelemetry spans. | Send a request and check for its span in New Relic. |
| Nothing appears in New Relic | New Relic | SPANWAY_OTEL_V2 is not true, so the callback looked for the agent and turned itself off. Or the license key is wrong, or the gateway cannot reach otlp.nr-data.net (otlp.eu01.nr-data.net for eu). | Set SPANWAY_OTEL_V2=true and restart, then check NEW_RELIC_LICENSE_KEY, NEW_RELIC_REGION and outbound access. |
| Team destination refused | Team callback | New Relic as a team destination needs the version 2 OpenTelemetry logger. | Set SPANWAY_OTEL_V2=true. |
403 naming scoped_integrations | Team callback | Per team accounts need the license feature. | Use the gateway wide callback, or add the feature. |
Logs
| Level | Line | Meaning |
|---|---|---|
| WARNING | A New Relic line naming the missing license key, app name or agent package | SPANWAY_OTEL_V2 is not true, so the callback tried the agent mode and turned itself off. Set SPANWAY_OTEL_V2=true and restart. |
| WARNING | New Relic: unknown newrelic_region '<value>'; supported regions: eu, us. Using the default (US) endpoint. | NEW_RELIC_REGION has an unknown value and the US endpoint is used. Set us or eu. |
Related
- OpenTelemetry for the version 2 logger and its settings.
- Logging for the other integrations.
- Team logging for per team accounts.
- Error reference and log reference.