Open
Conversation
Adds injectContext/extractContext/setupPropagation helpers wrapping the W3CTraceContextPropagator from @opentelemetry/core. Adds @opentelemetry/core as an explicit dependency since it is not re-exported by sdk-trace-base.
- Move @opentelemetry/api from devDependencies to dependencies (runtime import) - Guard proxy span end in onResponse to prevent double-end on OPA block path - Wrap explain handler in try/finally for reliable span cleanup
- Remove noisy audit-ring:push span (O(1) op, already covered by proxy:request) - Use SDK resolveRef() for OTel endpoint resolution (handles $env:/$secret:/$file:) - Add @agentspec/otel to Key Files in CLAUDE.md
- concepts/observability.md: architecture, span reference, config, degradation - guides/add-observability.md: step-by-step setup with Jaeger/Tempo examples - Add both to VitePress sidebar navigation
- Bundle @agentspec/otel into sidecar dist via tsup noExternal - Update Dockerfile to copy otel package, build it, and strip workspace dep - Add 3 E2E tests: traceparent injection, distinct trace IDs, client trace propagation - Update mock-agent to echo traceparent header in responses - Enable OTel tracing in E2E test agent.yaml
The @opentelemetry/exporter-trace-otlp-grpc package depends on @grpc/grpc-js which uses dynamic requires that break when bundled by esbuild/tsup. This caused the sidecar Docker container to crash on startup. - Make gRPC exporter a dynamic import (only loaded when protocol is 'grpc') - Make initTracing() async to support the lazy import - Mark gRPC exporter as external in sidecar tsup config - Update provider tests for async initTracing
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.
Summary
Adds native OpenTelemetry trace export to both the AgentSpec sidecar and SDK reporter. A new shared
@agentspec/otelpackage provides TracerProvider setup, OTLP exporters, and W3C trace context propagation. Both layers emit spans linked viatraceparentheaders for full distributed tracing.@agentspec/otelpackage with TracerProvider, OTLP exporters (HTTP/protobuf + gRPC), rate-based sampler, W3C propagationtraceparentinjection into upstream, OPA block spansspec.observability.tracingfrom manifest, auto-initializes whenbackend: otelArchitecture
Package dependency graph
Span hierarchy
Configuration flow
Graceful degradation
New files
packages/otel/src/provider.tspackages/otel/src/sampler.tspackages/otel/src/propagation.tspackages/otel/src/index.tsdocs/concepts/observability.mddocs/guides/add-observability.mdModified files
packages/sidecar/src/proxy.tspackages/sidecar/src/control-plane/index.tspackages/sidecar/src/control-plane/events.tspackages/sidecar/src/control-plane/explain.tspackages/sidecar/src/index.tspackages/sidecar/src/config.tsotelEndpointenv var configpackages/sdk/src/agent/reporter.tsdocs/.vitepress/config.mtsCLAUDE.mdTest plan
@agentspec/otel: 15 unit tests (provider, sampler, propagation)@agentspec/sidecar: 254 tests (9 new OTel tests, 0 regressions)@agentspec/sdk: 288 tests (3 new OTel tests, 0 regressions)traceparentheader reaches upstreambackend: otel, verify spans in UI