What does a shared model gateway's request log capture that in-app tracing misses, and what does it miss in turn?
answer
- one choke point, every team
- bytes actually sent upstream
- resolved model after alias and fallback
- blind to app context and tools
- join on a correlation id
basics
~20 sA 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 sBecause 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
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.
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.
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.
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.