nemo_gym.server_runtime.request_handling.trace_context
nemo_gym.server_runtime.request_handling.trace_context
Middleware that reads trace context carried in a request’s URL path.
Module Contents
Classes
Functions
Data
API
Strip /ng-trace/<traceparent> from the path and supply it as the inbound traceparent.
The segment comes from apply_rollout_prefix: a model URL an agent hands to a client that
sends no traceparent header, such as a harness inside a sandbox. A header the client did
send wins. The segment is stripped whether or not traces are on, so such a URL always routes.
Put /ng-trace/<traceparent> back into root-relative and same-origin redirect targets.
Inserted after a rollout or token-capture prefix (which the capture middleware has already restored) or at the root; cross-origin targets and targets that already carry a segment are left alone.
Install TraceContextPathMiddleware outside the instrumentor, which reads headers and path when it
opens the server span. Same mechanism as install_request_context_isolation; call it after
instrument_app_for_telemetry and before install_request_context_isolation, which stays outermost.