DEV Community

nRouter
nRouter

Posted on

Your gateway won't send logs to Datadog or Langfuse. Your app already can.

Start with the fact most vendor guides bury: on nRouter, request logs are not delivered to Datadog, Langfuse, S3, GCS, Slack or a webhook. Not yet. A Slack or webhook destination can be saved, and Test connection sends one test message — and then nothing. No request log follows, for any destination type.

That sounds like a gap. It is actually a clarification, because the telemetry was never inside the gateway waiting to be shipped. It arrives at your application on every response.

The headers are the feed

Every response carries:

  • x-nr-request-id — present on every response; the join key for everything downstream.
  • x-nr-model — the model that actually served the request.
  • x-nr-input-tokens, x-nr-output-tokens, x-nr-total-tokens — when usage is available.
  • x-nr-latency-ms — milliseconds until the response headers were ready.
  • x-nr-request-cost — the settled cost. Absent when the call could not be priced — never a zero placeholder.
  • x-nr-cost-status — exact or unpriced, so an absent cost is never mistaken for a free call.

Read them where you make the call, write one structured record, and POST it to Datadog's Logs API or as a Langfuse trace. The two tools want different shapes from the same row — Datadog is a high-volume intake you query and alert on; Langfuse nests observations in traces in sessions, built for "which step of which conversation went wrong" — so send deliberately, not everything everywhere.

Two properties of this pattern are easy to miss:

  1. The credentials stay yours. Your Datadog or Langfuse keys live in your application's environment. For this approach they are never entered into the gateway.
  2. The record cannot contain prompt text. The gateway's request log stores metadata only — prompt and response text are never in it — and the headers carry metadata only. A record built from headers is structurally content-free.

Tag at the source

Send x-nr-tags with comma-separated key=value pairs (team, feature, environment). The gateway uses them for cost attribution; carry the same values into the record you forward and both systems group identically. Keep cardinality sane — tag groupings you report on, never a unique id per request. And tags describe spend; they never authorize it. Which budget a call draws from comes from the authenticated key.

History and alerts, kept in their boxes

The Logs page exports a filtered view to CSV — model, tokens, cost, latency, status, request id. Retention is bounded by plan, so export on a schedule shorter than your window and join downstream on the request id.

Alert channels are live today (Email, Slack, Teams, Jira, webhook; webhook payloads can be signed). But an alert is a notification about a threshold. It is not a copy of your request logs, and a passing Test connection is not delivery. Most observability confusion is taxonomy confusion.

Verify it like you mean it

Make one call. Find your record in Datadog or Langfuse carrying the request id. Find the same id on the gateway's Logs page and confirm model, tokens and cost match the headers your code recorded. That proves your sending path — which, today, is the only delivery path there is.

Full guide: https://nrouter.ai/blog/guides/datadog-langfuse-llm-callbacks

Top comments (0)