Repository navigation
Add opt-in OpenTelemetry tracing and correlation - #202
Merged
Merged
Conversation
Instrument HTTP, MCP, shell invocations and commands with content-free spans. Propagate current request trace context through long-lived sessions, correlate analytics and logs, and export asynchronously over OTLP/HTTP. Amp-Thread-ID: https://ampcode.com/threads/T-e4f49316-3937-40ba-bec0-10c7b2204a50 Co-authored-by: Amp <amp@ampcode.com>
Prefer explicit YAML exporter, resource, and sampler settings over optional OTEL environment fallbacks. Honor file-based disable and validate tracing configuration in server and stdio startup. Amp-Thread-ID: https://ampcode.com/threads/T-e4f49316-3937-40ba-bec0-10c7b2204a50 Co-authored-by: Amp <amp@ampcode.com>
There was a problem hiding this comment.
🔵 Needs a closer look
Cross-transport propagation and exporter lifecycle changes need human validation, and nested write attribution remains unresolved.
1 open issue
What changed in this PR
Adds opt-in OpenTelemetry tracing across OpenLore execution paths, with analytics and log correlation.
Changes:
- Adds configurable OTLP/HTTP export, sampling, and shutdown flushing.
- Propagates request context through HTTP, MCP, and shell execution.
- Adds integration tests and configuration/privacy documentation.
| File | Description |
|---|---|
| pkg/shell/shell.go | Adds invocation and command tracing. |
| pkg/shell/cmds/analytics_metrics.go | Passes execution context to metrics. |
| pkg/shell/analytics_test.go | Tests nested tracing and content redaction. |
| pkg/openlore/telemetry_test.go | Tests request parentage and transport propagation. |
| pkg/openlore/server.go | Adds shell context and log correlation. |
| pkg/openlore/mcp.go | Instruments MCP requests and propagates context. |
| pkg/openlore/mcp_test.go | Updates transcript tests for context. |
| pkg/openlore/mcp_http_sessions.go | Passes current request context to sessions. |
| openlore.yml.example | Adds tracing configuration examples. |
| internal/telemetry/telemetry.go | Implements exporter setup and correlation handlers. |
| internal/telemetry/telemetry_test.go | Tests export, configuration precedence, and sampling. |
| internal/httpserver/httpserver.go | Wraps HTTP handling with tracing. |
| internal/configdocs/main.go | Defines tracing configuration documentation. |
| internal/config/documented_keys_test.go | Tests tracing configuration validation. |
| internal/config/config.go | Loads and validates tracing settings. |
| internal/analytics/types.go | Adds trace and span identifiers. |
| internal/analytics/storage.go | Captures correlation before queuing events. |
| internal/analytics/analytics_test.go | Tests persisted trace correlation. |
| go.sum | Records dependency checksums. |
| go.mod | Adds telemetry dependencies. |
| docs/openlore-yml.md | Documents tracing settings. |
| docs/configure-the-server.md | Explains tracing, privacy, and limitations. |
| cmd/openlore/main.go | Initializes tracing and flushes on shutdown. |
Review effort: Balanced
| s.executionContext = ctx | ||
| defer func() { | ||
| s.executionContext = previousContext | ||
| s.invocationID, s.commandEventID, s.pipelinePosition = previousInvocation, previousEvent, previousPosition |
Resolve dependency conflicts by retaining main dependency updates and aligning the OpenTelemetry SDK and OTLP exporter at v1.44.0. Amp-Thread-ID: https://ampcode.com/threads/T-e4f49316-3937-40ba-bec0-10c7b2204a50 Co-authored-by: Amp <amp@ampcode.com>
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
tracing:inopenlore.yml, with bounded asynchronous export, sampling, and shutdown flushing.enabled: falseprevents export. Configure the full endpoint, service name, sampling ratio, authentication headers, and resource attributes without environment variables.Verification
nix develop --command go test ./...— passed, including after rebasing onto current main.nix develop --command go vet ./...— passed.nix develop --command go test -race ./internal/config ./internal/telemetry ./cmd/openlore ./pkg/openlore ./pkg/shell ./internal/analytics ./internal/httpserver— passed.nix develop --command go mod verify— all modules verified.Scope and limitations