feat(otel): emit server-side spans + traceresponse header (RIG-2889) - #713
Open
rigel-mintaka wants to merge 2 commits into
Open
feat(otel): emit server-side spans + traceresponse header (RIG-2889)#713rigel-mintaka wants to merge 2 commits into
rigel-mintaka wants to merge 2 commits into
Conversation
Wire OTel emission into the compass-server binary and its RPC doors (T4b T2). The endpoint is env-only (`OTEL_EXPORTER_OTLP_ENDPOINT`); empty = tracing off, so the shipped socket-only path stays zero-overhead. - **cmd/compass-server:** bootstrap `SetupTracerProvider`/`SetupMeterProvider` off `ServeConfig.OtelEndpoint` (populated from the env knob in `buildServeConfig`), defer both shutdowns before `Serve`. - **serve.go / network_door.go:** mount `otelconnect` (outermost) + the trace-response interceptor on every door chain — socket + dev `CompassService`, `CommsService`, and the network shared bearer/admin-gate chain — so the RPC span envelopes the security interceptors and their ordering is unchanged relative to itself. Both interceptors are inert no-ops when no provider is installed. The interceptor + comms-handler construction lives in `buildDoors` (where `otelIC` is consumed), keeping `Serve` within its complexity budget. - **comms.go:** stamp `compass.message.id` onto the handler span in `PostMessage` and `RespondToAsk` (no-op when no span is active). - **CORS:** expose the `traceresponse` header on `devCORS` + `networkCORS` so a cross-origin browser can read the response trace id. Adds `connectrpc.com/otelconnect v0.9.0`; refreshes the nix `vendorHash` for the moved module set. Spec-impact: none. Refs RIG-2889. Co-authored-by: Matt Wilkinson <matt@rigel.build>
|
Compass engineering docs preview: https://compass-obs-rig-2889-server.compass-eng-docs.pages.dev Deployed from |
…t (RIG-2889) Review round 1 on PR #713. ### M1 — shutdown flush dropped on graceful drain The deferred `traceShutdown`/`meterShutdown` ran with the signal-derived `ctx`, which is already cancelled by the time they fire (the SIGTERM that ends `Serve` is the same signal that cancels `ctx`). A cancelled ctx makes the SDK `Shutdown` abort its final `ForceFlush` immediately, so the last buffered batch of spans/metrics was silently dropped exactly on the drain path the defers exist to flush — contradicting the frozen design contract (bounded 2s shutdown flush, mirroring the agent). Each defer now derives a fresh `context.WithTimeout(context.WithoutCancel(ctx), 2*time.Second)` at fire time (not at bootstrap, where an absolute deadline would expire mid-run), matching the `context.WithoutCancel` precedent already in `internal/runner/run.go`. ### L1 — vacuous disabled-path span assertion `TestServerEmissionDisabledProducesNoSpansNoHeader` wired an in-memory exporter to a provider it never set global and never referenced, so its zero-spans check could never fire. Dropped the dead exporter; the traceresponse-header-absence assertion is the real disabled-path proof (no recording span ⇒ no header). Renamed to `TestServerEmissionDisabledSetsNoTraceResponseHeader` to match what it proves. Spec-impact: none. Refs RIG-2889 Co-authored-by: Matt Wilkinson <matt@rigel.build>
rigel-mintaka
marked this pull request as ready for review
August 28, 2026 05:54
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR is part of a stack containing 2 PRs:
mainWire OTel emission into the compass-server binary and its RPC doors (T4b T2). The endpoint is env-only (
OTEL_EXPORTER_OTLP_ENDPOINT); empty = tracing off, so the shipped socket-only path stays zero-overhead.SetupTracerProvider/SetupMeterProvideroffServeConfig.OtelEndpoint(populated from the env knob inbuildServeConfig), defer both shutdowns beforeServe.otelconnect(outermost) + the trace-response interceptor on every door chain — socket + devCompassService,CommsService, and the network shared bearer/admin-gate chain — so the RPC span envelopes the security interceptors and their ordering is unchanged relative to itself. Both interceptors are inert no-ops when no provider is installed. The interceptor + comms-handler construction lives inbuildDoors(whereotelICis consumed), keepingServewithin its complexity budget.compass.message.idonto the handler span inPostMessageandRespondToAsk(no-op when no span is active).traceresponseheader ondevCORS+networkCORSso a cross-origin browser can read the response trace id.Adds
connectrpc.com/otelconnect v0.9.0; refreshes the nixvendorHashfor the moved module set.Spec-impact: none. Refs RIG-2889.
Co-authored-by: Matt Wilkinson matt@rigel.build