Skip to content

docs: add runnable OpenTelemetry tracing example - #7110

Merged
johanbrandhorst merged 1 commit into
grpc-ecosystem:mainfrom
hsdfat:example-otel-tracing
Jul 20, 2026
Merged

johanbrandhorst merged 1 commit into
grpc-ecosystem:mainfrom
hsdfat:example-otel-tracing

Conversation

@hsdfat

@hsdfat hsdfat commented Jul 18, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds a runnable OpenTelemetry tracing example demonstrating trace-context propagation through the gateway, and refreshes the tracing docs.

  • New examples/internal/cmd/example-otel-tracing/main.go: instruments the gateway HTTP layer with otelhttp and the gRPC client/server with otelgrpc stats handlers, exporting to stdouttrace. A single incoming HTTP request produces three connected spans (HTTP server → gRPC client → gRPC server) sharing one trace ID.
  • Rewrites the OpenTelemetry section of docs/docs/operations/tracing.md and answers the issue's question directly: with otelhttp + otelgrpc, no custom tracing wrapper is needed. Marked the OpenTracing/OpenCensus sections as legacy.

Fixes #3212

Breaking changes

None — additive example + docs only; runtime/public API untouched. The new OpenTelemetry deps are referenced solely by examples/internal.

  • Formatted (gofmt/goimports), passes staticcheck; go build ./... and gazelle (+ update-repos) produce no diff
  • I have read the Contributing Guidelines

Add a self-contained example under
examples/internal/cmd/example-otel-tracing that wires stdouttrace, a W3C
TraceContext propagator, an otelgrpc-instrumented in-process gRPC backend,
and runtime.NewServeMux wrapped in otelhttp.NewHandler. A single HTTP
request produces connected HTTP server -> gRPC client -> gRPC server spans
that share one trace ID exported to stdout.

Rewrite the OpenTelemetry section of the tracing docs to reference the
example and clarify that otelhttp and otelgrpc need no custom tracingWrapper
middleware, marking the OpenTracing and OpenCensus sections as legacy.

Fixes grpc-ecosystem#3212

@johanbrandhorst johanbrandhorst left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nicely done!

@johanbrandhorst
johanbrandhorst enabled auto-merge (squash) July 20, 2026 01:06
@johanbrandhorst
johanbrandhorst merged commit 8f8eb8a into grpc-ecosystem:main Jul 20, 2026
15 checks passed
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.

Looking for OpenTelemetry go tracing example with spans propagating through the gateway

2 participants