feat(tracing): OTel resource enrichment, semconv HTTP attributes, cached tracers#3857
Merged
feat(tracing): OTel resource enrichment, semconv HTTP attributes, cached tracers#3857
Conversation
4 tasks
- Add semconv.ServiceVersion, resource.WithSchemaURL, resource.WithTelemetrySDK to provider - Use stable semconv v1.26.0 HTTP constants for span attributes across all files - Cache tracing.Tracer() at construction time in UnifiedServer and proxyHandler Agent-Logs-Url: https://github.com/github/gh-aw-mcpg/sessions/e47e43a6-f379-4c51-a9ed-3d4390f56df7 Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Review OpenTelemetry Go SDK integration in gh-aw
feat(tracing): OTel resource enrichment, semconv HTTP attributes, cached tracers
Apr 15, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Enhances the gateway’s OpenTelemetry tracing by enriching OTEL resources, standardizing HTTP span attributes on stable semantic-convention constants, and reducing per-request overhead by caching tracers on server/handler construction.
Changes:
- Enrich OTEL
resourcewith SDK metadata, schema URL, andservice.version. - Replace raw
"http.*"attribute strings withsemconv/v1.26.0constants for method/path/status. - Cache
oteltrace.Tracerinstances inUnifiedServerandproxyHandlerto avoid repeatedotel.Tracer(...)calls.
Show a summary per file
| File | Description |
|---|---|
| internal/tracing/provider.go | Adds SDK/schema/service-version resource enrichment during provider init. |
| internal/tracing/http.go | Uses semconv HTTP method + URL path keys in the generic HTTP wrapper. |
| internal/server/unified.go | Caches tracer; switches HTTP status attribute to semconv. |
| internal/server/http_helpers.go | Uses semconv HTTP method + URL path keys in server HTTP middleware. |
| internal/proxy/proxy.go | Constructs proxyHandler with a cached tracer. |
| internal/proxy/handler.go | Adds cached tracer + semconv keys for path/status within proxy spans. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comments suppressed due to low confidence (1)
internal/proxy/handler.go:205
- This span attribute uses
semconv.URLPathKeybutpathmay include the query string (it is forwarded upstream asfullPath).url.pathshould not contain?query=...; use the raw path (no query) forURLPathKeyand optionally capture query/full URL via the appropriate semconv keys.
fwdCtx, fwdSpan := h.getTracer().Start(ctx, "proxy.backend.forward",
oteltrace.WithAttributes(
semconv.URLPathKey.String(path),
attribute.String("tool.name", toolName),
),
- Files reviewed: 6/6 changed files
- Comments generated: 2
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This was referenced Apr 15, 2026
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.
Applies the quick-win improvements from the go-fan OTel module review: richer resource metadata, stable semconv constants for HTTP span attributes, and cached tracers at construction time.
Resource improvements (
internal/tracing/provider.go)Semconv HTTP attribute constants
Replaced raw string attributes with stable semconv v1.26.0 constants across all instrumented files:
attribute.String("http.method", r.Method)semconv.HTTPRequestMethodKey.String(r.Method)attribute.String("http.path", r.URL.Path)semconv.URLPathKey.String(r.URL.Path)attribute.Int("http.status_code", code)semconv.HTTPResponseStatusCodeKey.Int(code)Affected:
internal/tracing/http.go,internal/server/http_helpers.go,internal/server/unified.go,internal/proxy/handler.go.Cached tracers at construction
UnifiedServerandproxyHandlerpreviously calledtracing.Tracer()(→otel.Tracer(...)) on every request. Both now cache the tracer at construction via atracer oteltrace.Tracerfield, with agetTracer()nil-safe fallback to keep existing tests (which construct these structs directly) working without modification.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
example.com/tmp/go-build2146563392/b510/launcher.test /tmp/go-build2146563392/b510/launcher.test -test.testlogfile=/tmp/go-build2146563392/b510/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true 6563392/b203/_pk-p ache/go/1.25.8/xgo.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp bin/as -p b/gh-aw-mcpg/int-atomic -lang=go1.25 /opt/hostedtoolc-buildtags go_.�� otlptrace/otlptr-errorsas -trimpath x_amd64/compile -p vendor/golang.ordocker-cli-plugin-metadata -lang=go1.25 x_amd64/compile(dns block)/tmp/go-build4139057404/b514/launcher.test /tmp/go-build4139057404/b514/launcher.test -test.testlogfile=/tmp/go-build4139057404/b514/testlog.txt -test.paniconexit0 -test.timeout=10m0s /home/REDACTED/.cache/go-build/05/05ba880d21430c45c3563656362c54dda898a477387de95da38a5d091bd8bbf6-d /tmp/go-build2146563392/b392/_pkg_.a -trimpath(dns block)invalid-host-that-does-not-exist-12345.com/tmp/go-build2146563392/b492/config.test /tmp/go-build2146563392/b492/config.test -test.testlogfile=/tmp/go-build2146563392/b492/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true 6563392/b163/_pk-p .cfg x_amd64/vet(dns block)/tmp/go-build4139057404/b496/config.test /tmp/go-build4139057404/b496/config.test -test.testlogfile=/tmp/go-build4139057404/b496/testlog.txt -test.paniconexit0 -test.timeout=10m0s -I aw-mcpg/internal/difc/agent.go aw-mcpg/internal/difc/capabilities.go ache/go/1.25.8/x64/pkg/tool/linux_amd64/vet --gdwarf-5 --64 -o ache/go/1.25.8/x64/pkg/tool/linux_amd64/vet -o /tmp/go-build2146563392/b370/_pkg_.a -trimpath 6563392/b378/vet.cfg -p google.golang.or/tmp/go-build3569075202/b428/vet.cfg -lang=go1.24 /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linu1(dns block)nonexistent.local/tmp/go-build2146563392/b510/launcher.test /tmp/go-build2146563392/b510/launcher.test -test.testlogfile=/tmp/go-build2146563392/b510/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true 6563392/b203/_pk-p ache/go/1.25.8/xgo.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp bin/as -p b/gh-aw-mcpg/int-atomic -lang=go1.25 /opt/hostedtoolc-buildtags go_.�� otlptrace/otlptr-errorsas -trimpath x_amd64/compile -p vendor/golang.ordocker-cli-plugin-metadata -lang=go1.25 x_amd64/compile(dns block)/tmp/go-build4139057404/b514/launcher.test /tmp/go-build4139057404/b514/launcher.test -test.testlogfile=/tmp/go-build4139057404/b514/testlog.txt -test.paniconexit0 -test.timeout=10m0s /home/REDACTED/.cache/go-build/05/05ba880d21430c45c3563656362c54dda898a477387de95da38a5d091bd8bbf6-d /tmp/go-build2146563392/b392/_pkg_.a -trimpath(dns block)slow.example.com/tmp/go-build2146563392/b510/launcher.test /tmp/go-build2146563392/b510/launcher.test -test.testlogfile=/tmp/go-build2146563392/b510/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true 6563392/b203/_pk-p ache/go/1.25.8/xgo.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp bin/as -p b/gh-aw-mcpg/int-atomic -lang=go1.25 /opt/hostedtoolc-buildtags go_.�� otlptrace/otlptr-errorsas -trimpath x_amd64/compile -p vendor/golang.ordocker-cli-plugin-metadata -lang=go1.25 x_amd64/compile(dns block)/tmp/go-build4139057404/b514/launcher.test /tmp/go-build4139057404/b514/launcher.test -test.testlogfile=/tmp/go-build4139057404/b514/testlog.txt -test.paniconexit0 -test.timeout=10m0s /home/REDACTED/.cache/go-build/05/05ba880d21430c45c3563656362c54dda898a477387de95da38a5d091bd8bbf6-d /tmp/go-build2146563392/b392/_pkg_.a -trimpath(dns block)this-host-does-not-exist-12345.com/tmp/go-build2146563392/b519/mcp.test /tmp/go-build2146563392/b519/mcp.test -test.testlogfile=/tmp/go-build2146563392/b519/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true /grpc_binarylog_v1/binarylog.pb.go .cfg x_amd64/compile -o(dns block)/tmp/go-build4139057404/b523/mcp.test /tmp/go-build4139057404/b523/mcp.test -test.testlogfile=/tmp/go-build4139057404/b523/testlog.txt -test.paniconexit0 -test.timeout=10m0s -ato�� ry=1 8 x_amd64/vet -errorsas -ifaceassert -nilfunc x_amd64/vet -ato�� -bool -buildtags x_amd64/vet -errorsas -ifaceassert -nilfunc x_amd64/vet(dns block)If you need me to access, download, or install something from one of these locations, you can either: