skip to content

Request Logging and Replay

Every call passes the gateway, so it can keep full request and response bodies and re-run old traffic on a new model. Interviewers ask what to log, who may read it, and what a replay proves.

on this pageshow

questions

6

What does a shared model gateway's request log capture that in-app tracing misses, and what does it miss in turn?

level: juniorimportance: must knowfreq 45%

answer

  1. one choke point, every team
  2. bytes actually sent upstream
  3. resolved model after alias and fallback
  4. blind to app context and tools
  5. join on a correlation id

basics

~20 s

A gateway log records every team's model calls in one schema: the exact request sent upstream, the resolved model, response, usage and errors. It misses application context: the user action, where prompt text came from, tool execution and what happened next.

solid answer

~50 s

Because every call passes the gateway, its log is complete by construction: it covers teams that never instrumented anything, and it records what was really sent upstream, after the gateway translated the request, applied defaults, resolved an alias and perhaps fell back to another model. It also sees the provider's raw response, finish reason, token usage, throttling and errors in one uniform schema. What it cannot see is what the application knows: which user action or agent step produced the call, which retrieved documents became which prompt text, whether a tool call was executed, and whether the answer was shown, edited or discarded. Calls that bypass the gateway are invisible to it. So the two are complements: the app sends a correlation id with each call, and the gateway record joins the app's trace instead of replacing it.

go deeper

for a junior

Recall the two lists: the gateway sees every call, the request actually sent and the response; the application sees why the call happened and what happened next.

for a middle

Explain why the logged request can differ from what the caller sent, through translation, defaults, alias resolution and fallback, and why that difference matters when debugging.

for a senior

Show the join and the write path: a correlation id from the application, an off-path log write that counts dropped records, and the bypass traffic no gateway log can see.

for a principal

Treat the gateway log as the one complete record across teams, valuable and sensitive at once, and decide who owns its schema, its access and the rule that all traffic passes it.

A **shared model gateway** is one internal endpoint that every application calls instead of calling each model provider directly. Because every model call crosses it, the gateway is a natural place to keep a **request log**: one record per call, in one schema, for every team. **In-app tracing** is the other place calls get recorded: the application emits spans around its own work, the model call included, with the application's own context attached. The two overlap, but each sees things the other cannot, and an interviewer asking this wants both lists and the join between them. ## What only the gateway sees - **Completeness by construction.** A team that never added tracing still appears, because its calls pass the gateway. Coverage does not depend on every team doing the work. - **The request as actually sent upstream.** The gateway may translate the caller's request into a provider's shape, drop a parameter the provider lacks, fill in defaults, resolve an alias such as `drafting-default` to a dated model, or fall back to a different model after an error. Only the gateway knows the final request the provider received. - **The resolved model and the routing path.** Which provider and which model snapshot answered, and whether a fallback hop was taken. - **The provider's raw response.** Text, tool calls, the finish reason, the token usage the provider reported, and provider latency separated from the application's own time. - **Throttling and errors.** Every HTTP 429, timeout and provider error, including those the gateway absorbed by retrying or failing over, which the application may never hear about. - **One schema across teams.** Every record has the same fields, so "which routes hit the output-length limit last week" is one query, not a survey of every team's tracing. ## What only the application sees - **Why the call happened.** The user action, the feature, the step inside an agent loop, the session the call belongs to. - **Where the prompt text came from.** Retrieved documents arrive at the gateway already pasted into the prompt; their sources, ranks and scores live in the application. - **Tool execution.** The gateway sees a tool call in a response and, on the next call, the tool result as message text. It does not see the tool run, how long it took, or whether it failed and was retried. - **What happened to the answer.** Whether it was shown, post-processed, rejected by a validator, edited by the user or discarded. - **Work that never reaches the gateway.** Answers served from an application cache, models run locally, and any call a team makes straight to a provider with its own key. Bypass traffic is invisible to the gateway, which is one reason to make the gateway the only holder of provider keys. ## Side by side | Question | Gateway request log | In-app tracing | |---|---|---| | Does every team's traffic appear? | Yes, if it passes the gateway | Only where a team instrumented | | What did the provider actually receive? | Yes | Usually only the caller's version | | Which model answered, after fallback? | Yes | Often not | | Which documents fed the prompt? | No, only their text | Yes | | Did the tool call run and succeed? | No | Yes | | Did the user see or use the answer? | No | Yes | ## Joining the two The answer is not to pick one. The application generates a **correlation id**, its trace or request id, and sends it with every call, for example in a request header or a metadata field the gateway defines. The gateway writes that id into its record. An investigation can then start from either side: from a user complaint in the application's trace down to the exact upstream request, or from a spike of truncated outputs in the gateway log up to the features and sessions affected. How spans are modelled inside the application is a tracing topic of its own; the gateway only needs the id. ## Writing the log without slowing the call The gateway sits in the path of every call, so how it writes records matters: 1. **Off the critical path.** The gateway returns the response first and hands the record to a local buffer or queue that ships it to the log store. A slow log store then cannot add latency or fail calls. 2. **Count what is dropped.** A crash or a full buffer loses records; a counter of dropped records makes that loss visible instead of silent. 3. **Assemble streams.** For a streamed response the gateway forwards chunks as they arrive, keeps a copy, and writes one record when the stream ends, including the usage figures many providers send last and a flag if the caller disconnected. 4. **Exceptions by route.** A route whose records are an audit obligation can choose to fail the call when the record cannot be written; that is a per-route decision, not the default. Because this log holds what every team sent to every model, it is valuable and sensitive at once. Who may read it is a separate design decision, and so is what each record must contain to be replayed later.

  • Should the gateway write its log record before it returns the response to the caller?
    Usually not: the gateway hands the record to a local buffer or queue and returns, so a slow log store cannot add latency or fail calls. The price is that a crash or a full buffer can lose records, so dropped records should be counted. A route whose records are an audit obligation may instead fail the call when the record cannot be written.
  • With a streamed response, how does the gateway log an answer it never holds whole?
    It forwards each chunk to the caller as it arrives and keeps a copy, assembling the text, tool calls, finish reason and the usage figures many providers send at the end, then writes one record when the stream closes. If the caller disconnects mid-stream, the record says so and keeps the partial output, because a cut stream is itself worth finding.
  • Why log the request as sent upstream rather than as the caller sent it?
    Because the two can differ: the gateway may have mapped parameters, dropped an unsupported one, filled a default or resolved an alias to a dated model. Debugging and replay need what the provider actually received. Many teams log both, or log the caller's request plus a list of the transformations the gateway applied.

A building's front-desk visitor log records everyone who enters, when, and which floor they went to, even for offices that keep no notes of their own. It cannot tell you what was said in the meeting upstairs; only the office's own notes know that. Matching a visitor badge number in both records joins them.

  • In-app tracing makes a gateway log redundant, since the app already records every prompt.
  • The gateway log shows which documents retrieval chose and why.
  • Logging the model name the caller asked for is enough to know what answered.
  • Every model call in the company is guaranteed to appear in the gateway log.
  • A gateway log record must always be written before the response returns.
open as a page

Before a model migration you replay a week of gateway-logged requests on the candidate; how do you compare answers when the log holds no labels?

level: seniorimportance: must knowfreq 42%

basics

~20 s

Rerun the incumbent on the same requests to measure its own noise floor, then compare the candidate on label-free signals: format validity, tool-call agreement, refusals, truncation, field-level or semantic diffs, and human review of sampled disagreements.

open as a page

What must a model gateway's logged request contain so it can be replayed faithfully on another model months later?

level: middleimportance: should knowfreq 40%

basics

~20 s

The exact rendered messages, the resolved dated model rather than an alias, every effective parameter including defaults, the full tool definitions and tool mode, any output schema, the prompt version, and the original response as a baseline.

open as a page

How do you keep a bulk replay of gateway-logged traffic from firing side effects, exhausting provider quota or polluting production cost and quality figures?

level: seniorimportance: should knowfreq 30%

basics

~20 s

Treat the replay as a separate tenant: outputs are recorded but never executed or delivered, it runs on its own key and cap at a paced rate, and every request carries a replay tag that dashboards, health checks and future samples exclude.

open as a page

As owner of a shared model gateway, how do you set per-route body logging and read access when legal asks who can read logged prompts?

level: principalimportance: should knowfreq 32%

basics

~20 s

Log metadata on every route and full bodies only on routes whose owners opt in for a stated purpose such as debugging or replay. Store bodies apart, and let only the owning team and named roles read them through an audited path.

open as a page

Why does replaying a gateway-logged multi-turn conversation on a new model stop being faithful after the first turn that changes, and what do you replay instead?

level: seniorimportance: nice to knowfreq 22%

basics

~20 s

Each later user message reacts to the old model's reply, so once the candidate answers differently the logged next turn no longer follows. Replay each turn with the logged history as a fixed prefix, and record where the candidate first diverged.

open as a page