Skip to content

tracing: support OTLP/HTTP as an alternative to the gRPC exporter #2567

Description

@satyamg1620

What would you like to be added:

Select the OTLP transport from OTEL_EXPORTER_OTLP_PROTOCOL / OTEL_EXPORTER_OTLP_TRACES_PROTOCOL in initTraceExporter (pkg/common/observability/tracing/telemetry.go), and add an otlptracehttp path alongside the existing otlptracegrpc one.

otlptracegrpc.New is the only exporter constructed today. No OTLP exporter package reads the protocol variable - protocol selection is the caller's job - so http/protobuf currently has no effect and spans still go over gRPC to port 4317, against a backend that may only serve 4318.

Three implementation notes:

  • This adds a module. go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp is not in go.sum. It is a new direct dependency at the same version as the gRPC exporter (v1.44.0) and from the same release train as the modules already required, so it adds no new transitive versions, but it needs agreement before the work starts.

  • http/json is out of scope. The Go SDK ships no JSON encoder for OTLP; only grpc and http/protobuf are implementable. http/json should reach the error handler as unsupported rather than falling back silently.

  • The loopback fallback becomes protocol-dependent. localCollectorOptions pins localhost:4317 and plaintext when no transport variable is set. The HTTP exporter defaults to 4318, so the fallback has to select per protocol, and the option types (otlptracegrpc.Option and otlptracehttp.Option) are distinct, so one helper cannot serve both as currently written.

Why is this needed:

OTLP/HTTP is the transport many managed backends and ingress paths expose, and some environments terminate gRPC at the edge or disallow HTTP/2 to the collector. With gRPC as the only path, those deployments cannot export at all. The protocol variable is read by nothing: an operator sets OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf, sees no error, and gets no spans.

Acceptance criteria:

  • http/protobuf exports over OTLP/HTTP; grpc and unset both export over gRPC.
  • OTEL_EXPORTER_OTLP_TRACES_PROTOCOL takes precedence over OTEL_EXPORTER_OTLP_PROTOCOL.
  • An unsupported protocol value is reported through the error handler.
  • The TLS, header and certificate behavior established in tracing: honor OTLP TLS, authentication and certificate environment variables #2311 holds on the HTTP path.
  • With no transport variables set, the fallback targets 4317 for gRPC and 4318 for HTTP, plaintext in both cases.
  • Tests against an in-process HTTP collector, mirroring the gRPC collector in telemetry_otlp_test.go.

Part of #1632.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triageIndicates an issue or PR lacks a triage label and requires one.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions