Skip to content

internal/telemetry: add gRPC transport for OTLP trace export#33941

Merged
fjl merged 3 commits into
ethereum:masterfrom
barnabasbusa:telemetry/grpc-export
Apr 21, 2026
Merged

internal/telemetry: add gRPC transport for OTLP trace export#33941
fjl merged 3 commits into
ethereum:masterfrom
barnabasbusa:telemetry/grpc-export

Conversation

@barnabasbusa
Copy link
Copy Markdown
Member

@barnabasbusa barnabasbusa commented Mar 3, 2026

Summary

  • Add grpc:// and grpcs:// URL scheme support for OTLP trace export alongside existing http:///https://
  • The OTLP spec defines two transports: HTTP (port 4318) and gRPC (port 4317). Many observability backends (Jaeger, Tempo, Datadog) prefer gRPC for lower overhead
  • Both otlptracehttp and otlptracegrpc return *otlptrace.Exporter, so only exporter construction changes — everything downstream (batch processor, tracer provider, lifecycle) is untouched
  • Update flag usage strings to be transport-agnostic

Example usage

geth --rpc.telemetry --rpc.telemetry.endpoint grpc://localhost:4317
geth --rpc.telemetry --rpc.telemetry.endpoint grpcs://tempo-grpc.example.com:443

Test plan

  • go build ./... compiles
  • go vet ./internal/telemetry/... passes
  • Manual: run OTel Collector, start geth with grpc://localhost:4317, verify traces arrive
  • Confirm HTTP transport still works with http://localhost:4318
  • Confirm invalid scheme like ftp:// still returns error

🤖 Generated with Claude Code

}
if u.Scheme == "grpc" {
opts = append(opts, otlptracegrpc.WithInsecure())
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The path is ignored here? Is it meaningful for GRPC?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

No, gRPC derives its HTTP/2 path from the protobuf service definition (/opentelemetry.proto.collector.trace.v1.TraceService/Export) there's no user-facing path option in otlptracegrpc. Added a validation error in the follow-up commit that rejects gRPC URLs with a path component.

Comment thread internal/telemetry/tracesetup/setup.go Outdated
Comment thread go.mod Outdated
@barnabasbusa
Copy link
Copy Markdown
Member Author

Thanks for the heads up @gballet. Happy to rebase on top of #33916 once it merges — the grpc exporter module will pick up v1.40 transitively.

jrhea
jrhea previously approved these changes Mar 3, 2026
Copy link
Copy Markdown
Contributor

@jrhea jrhea left a comment

Choose a reason for hiding this comment

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

very nice. i tested it locally and I can confirm that the HTTP transport still works with http://localhost:4318

rjl493456442
rjl493456442 previously approved these changes Mar 5, 2026
@jrhea jrhea added this to the 1.17.2 milestone Mar 5, 2026
barnabasbusa and others added 2 commits March 12, 2026 12:01
The OTLP specification defines two transports: HTTP (port 4318) and gRPC
(port 4317). The existing exporter setup only supports HTTP/HTTPS schemes.
This adds gRPC support via URL scheme dispatch:

  - grpc://host:port  → plaintext gRPC
  - grpcs://host:port → TLS-secured gRPC

Many observability backends (Jaeger, Tempo, Datadog) prefer gRPC for its
lower overhead. Both otlptracehttp and otlptracegrpc return the same
*otlptrace.Exporter type, so only the exporter construction changes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Extract auth header construction before the switch to avoid
  duplication between HTTP and gRPC cases.
- Return an error if a URL path is provided with a gRPC endpoint,
  since gRPC uses service/method routing rather than URL paths.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@barnabasbusa barnabasbusa force-pushed the telemetry/grpc-export branch from 1d97a12 to b6897d3 Compare March 12, 2026 11:01
@barnabasbusa barnabasbusa dismissed stale reviews from jrhea and rjl493456442 via 8f1fc90 March 12, 2026 11:04
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@barnabasbusa barnabasbusa force-pushed the telemetry/grpc-export branch from 8f1fc90 to 81f8aaa Compare March 12, 2026 11:11
@rjl493456442 rjl493456442 modified the milestones: 1.17.2, 1.17.3 Mar 30, 2026
@barnabasbusa
Copy link
Copy Markdown
Member Author

@jrhea bump on this. Do I need to do anything else?

Copy link
Copy Markdown
Contributor

@jrhea jrhea left a comment

Choose a reason for hiding this comment

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

I just tested it again in dev mode and still seems fine.

@fjl fjl merged commit f568ab9 into ethereum:master Apr 21, 2026
5 of 8 checks passed
@barnabasbusa barnabasbusa deleted the telemetry/grpc-export branch May 6, 2026 14:08
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.

5 participants