Skip to content

feat(otel): emit runner client spans (RIG-2890) - #714

Open
rigel-mintaka wants to merge 2 commits into
compass-obs/rig-2889-server-emissionfrom
compass-obs/rig-2890-runner-emission
Open

feat(otel): emit runner client spans (RIG-2890)#714
rigel-mintaka wants to merge 2 commits into
compass-obs/rig-2889-server-emissionfrom
compass-obs/rig-2890-runner-emission

Conversation

@rigel-mintaka

@rigel-mintaka rigel-mintaka commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

This PR is part of a stack containing 2 PRs:

  1. main
  2. feat(otel): emit server-side spans + traceresponse header (RIG-2889) #713
  3. "feat(otel): emit runner client spans (RIG-2890)" (this PR)

Wire OTel emission into the compass-runner binary and its outbound RunnerService client (T4b T3). Endpoint is env-only (OTEL_EXPORTER_OTLP_ENDPOINT); empty = tracing off.

  • cmd/compass-runner: bootstrap SetupTracerProvider/SetupMeterProvider off RunnerConfig.OtelEndpoint (populated from the env knob via a setupOtel helper), defer the combined shutdown before runner.Run.
  • runner.go: prepend the otelconnect client interceptor (outermost, ahead of the bearer-token interceptor) on NewRunnerServiceClient so enroll and Sessions dials emit CLIENT spans; a no-op when no global provider is installed.

Rides the connectrpc.com/otelconnect v0.9.0 dep added by the T2 base commit (RIG-2889).

Spec-impact: none. Refs RIG-2890.

Co-authored-by: Matt Wilkinson matt@rigel.build

@linear-code

linear-code Bot commented Aug 28, 2026

Copy link
Copy Markdown

RIG-2890

@github-actions

github-actions Bot commented Aug 28, 2026

Copy link
Copy Markdown

Compass engineering docs preview: https://compass-obs-rig-2890-runner.compass-eng-docs.pages.dev

Deployed from compass-obs/rig-2890-runner-emission at e6badb1.

rigel-mintaka and others added 2 commits August 28, 2026 01:26
Wire OTel emission into the compass-runner binary and its outbound RunnerService client (T4b T3). Endpoint is env-only (`OTEL_EXPORTER_OTLP_ENDPOINT`); empty = tracing off.

- **cmd/compass-runner:** bootstrap `SetupTracerProvider`/`SetupMeterProvider` off `RunnerConfig.OtelEndpoint` (populated from the env knob via a `setupOtel` helper), defer the combined shutdown before `runner.Run`.
- **runner.go:** prepend the `otelconnect` client interceptor (outermost, ahead of the bearer-token interceptor) on `NewRunnerServiceClient` so enroll and Sessions dials emit CLIENT spans; a no-op when no global provider is installed.

Rides the `connectrpc.com/otelconnect v0.9.0` dep added by the T2 base commit (RIG-2889).

Spec-impact: none. Refs RIG-2890.

Co-authored-by: Matt Wilkinson <matt@rigel.build>
…IG-2890)

Review round 1 on PR #714.

### M2 — dead, misleading `RunnerConfig.OtelEndpoint`

The field was write-only: `main.setupOtel` already installs and gates the global provider (that IS the enable gate), and `Dial` mounts the otelconnect interceptor unconditionally — no runner-package code ever read the field. Its doc comment nonetheless claimed it "gates whether this Runner exports OTel data", a false invariant for the next maintainer. Removed the field, the `OtelEndpoint:` set at the call site, and `setupOtel`'s now-unused endpoint return (it returns only the shutdown). The tautological `TestRunnerConfigOtelEndpointFromEnv` (asserted a struct field equals what it was just assigned — L2) is deleted; the enabled/disabled span tests already cover the real env → provider gate.

### M3 — shutdown flush dropped on graceful drain

`setupOtel`'s combined shutdown ran `tracerShutdown`/`meterShutdown` with the signal-derived `ctx`, already cancelled by the time the defer fires, so the SDK `Shutdown` aborted its final `ForceFlush` and dropped the last buffered batch — the same defect the sibling server bootstrap carried. The shutdown 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` and the frozen design's 2s bound.

Spec-impact: none. Refs RIG-2890

Co-authored-by: Matt Wilkinson <matt@rigel.build>
@rigel-mintaka
rigel-mintaka force-pushed the compass-obs/rig-2890-runner-emission branch from 2bd0b92 to e6badb1 Compare August 28, 2026 05:44
@rigel-mintaka
rigel-mintaka marked this pull request as ready for review August 28, 2026 05:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant