Skip to content

[go-fan] Go Module Review: go.opentelemetry.io/otel #17232

In review

Description

@github-actions

Overview: Today's Go Fan review covers go.opentelemetry.io/otel (pinned at v1.47.0, the latest stable release). The pin is current, so no upgrade is needed. The main finding is a sampler design question: InitProvider installs AlwaysSample/TraceIDRatioBased directly, not wrapped in ParentBased, so an incoming traceparent sampling decision is ignored. Also, the semconv pairing comment in semconv.go should be re-checked against v1.47.0. Note: the sandbox denied go commands and the upstream source/changelog fetch was blocked, so the canary tests were not run and upstream v1.44 to v1.47 release notes were not verified.

Full Report

🐹 Go Fan Report: go.opentelemetry.io/otel

Module Overview

go.opentelemetry.io/otel is the OpenTelemetry Go API. The project uses it for distributed tracing: the gateway builds an OTLP/HTTP trace pipeline (internal/tracing/provider.go), wraps HTTP handlers with server spans, and instruments tool calls and proxy forwards with client/internal spans. Related modules pinned in the same release train are otel/sdk, otel/trace, and otel/exporters/otlp/otlptrace/otlptracehttp.

Current Usage in gh-aw

  • Files: 24 Go files import go.opentelemetry.io/otel* (9 production, 15 test)

  • Import Count: 60 import lines

  • Key APIs Used:

    • Exporter: otlptracehttp.New with WithEndpointURL, WithTimeout, WithMaxResponseSize, WithRetry, WithHeaders
    • SDK: sdktrace.NewTracerProvider, WithBatcher, WithMaxExportBatchSize(256), WithBatchTimeout(2s), WithResource, WithSampler (AlwaysSample, NeverSample, TraceIDRatioBased)
    • Resource: resource.New with WithTelemetrySDK, WithContainer, WithHost, WithProcessPID; fallback via NewWithAttributes and Merge
    • Propagation: propagation.TraceContext, propagation.Baggage, global otel.SetTextMapPropagator
    • Spans: trace.Span.RecordError(..., WithStackTrace(true)), SetStatus(codes.Error, ...), SpanKindServer/Client/Internal
    • Noop: trace/noop for disabled tracing
  • Custom code: internal/tracing/fanout.go hand-implements sdktrace.SpanExporter for multi-endpoint fan-out. Canary tests guard it.

Research Findings

Recent Updates

  • Latest stable: v1.47.0 (published 2026-10-02, per GitHub releases). v1.47.0-rc.1 was a prerelease (2026-08-28).
  • Recent stable releases: v1.46.0 (2026-08-25), v1.45.0 (2026-08-03), v1.44.0 (2026-05-27).
  • Not verified in this run: release-note contents for v1.44 to v1.47 (changelog fetch blocked), deprecations, and breaking changes. The repo's own comments mention panic recording added in v1.44.0 and a semconv v1.43.0 pairing with v1.46.0.

Best Practices

Per the OpenTelemetry Go SDK defaults, NewTracerProvider uses ParentBased(AlwaysSample()) unless a sampler is set. Wrapping the root sampler in ParentBased lets a remote parent's sampled flag decide whether to record a child span.

Improvement Opportunities

🏃 Quick Wins

  1. Confirm sampler intent (internal/tracing/provider.go, sampler switch): the gateway sets sdktrace.AlwaysSample(), NeverSample(), or TraceIDRatioBased(rate) as the root sampler, not wrapped in ParentBased. An incoming traceparent with flags=00 is still recorded and exported when rate >= 1.0. This may be intentional, since the gateway is explicitly configured with an OTLP endpoint and ParentContext marks its synthetic parent as sampled. If honoring upstream decisions is desired, wrap each case with sdktrace.ParentBased(...) and add a test with an unsampled remote parent. Otherwise, document the choice.
  2. Re-check the semconv pairing (internal/tracing/semconv.go): the header says semconv/v1.43.0 "ships with otel v1.46.0" as an example, while go.mod pins v1.47.0. Confirm which semconv package v1.47.0 ships and whether expectedSchemaURL in semconv_test.go needs to move. This is the "conflicting Schema URL" risk the file warns about.

✨ Feature Opportunities

  • Panic recording is left enabled (per the comment in provider.go). Verify this still matches the v1.47.0 default. The code comment is the only evidence available here.

📐 Best Practice Alignment

  • WithRetry uses a 1-minute MaxElapsedTime with 5s to 30s intervals. Check that this matches the flush behavior expected at shutdown, since Provider.Shutdown relies on sdk.Shutdown to flush.

🔧 General Improvements

  • fanout.go hand-implements SpanExporter. Verify TestSpanExporterInterfaceCanary still matches the v1.47.0 interface.

Module Summary

Field Value
Module go.opentelemetry.io/otel
Version v1.47.0 (with otel/sdk, otel/trace, otlptracehttp at v1.47.0)
Repository https://github.com/open-telemetry/opentelemetry-go
Latest Release v1.47.0 (2026-10-02)
Last Reviewed 2026-11-24

Key Features

  • Stable traces API and SDK (otel/trace, otel/sdk/trace)
  • OTLP/HTTP exporter with configurable retry, timeout, and headers
  • W3C TraceContext and Baggage propagators
  • Semantic conventions via otel/semconv/vX.Y.Z (pinned to v1.43.0 here)
  • Noop tracer provider for zero-overhead disabled mode

References

Recommendations

  1. Run the OTel canary and semconv tests after confirming the pin: go test ./internal/tracing/ -run 'Canary|TestSchemaURL' -v. These were not run in this review.
  2. Decide on ParentBased sampling (Quick Win 1) and either change the code with a test or document the current behavior.
  3. Re-check the semconv pairing against v1.47.0 (Quick Win 2).
  4. Read the v1.44 to v1.47 changelog entries for deprecations before the next bump.

Next Steps

  • Schedule a follow-up review that includes the upstream changelog once the source fetch is available.
  • Pick up the sampler and semconv items as separate issues if the team agrees they are wanted.

Generated by Go Fan

References:

Generated by Go Fan · copilot · routed: haiku55 xhigh · ~14 AIC · ⊞ 5.8K · ◷

  • expires on Dec 1, 2026, 7:16 AM UTC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions