Skip to content

fix(tracing): honor the OTLP protocol environment variables - #459

Open
ravi-pplx wants to merge 1 commit into
block:mainfrom
perplexityai:fix/tracing-otlp-protocol
Open

ravi-pplx wants to merge 1 commit into
block:mainfrom
perplexityai:fix/tracing-otlp-protocol

Conversation

@ravi-pplx

@ravi-pplx ravi-pplx commented Nov 22, 2026 •

Copy link
Copy Markdown

tracing.New always creates a gRPC exporter, whatever the OTLP protocol variables say. With OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf and an OTLP/HTTP endpoint such as http://collector:4318, every export fails and the spans are dropped. When a traces endpoint is also set, the error is dial tcp: lookup tcp/4318/v1/traces: unknown port. The metrics exporter already speaks OTLP/HTTP, so a collector that only listens for HTTP gets metrics but no traces.

Change

  • The traces exporter follows OTEL_EXPORTER_OTLP_TRACES_PROTOCOL, then OTEL_EXPORTER_OTLP_PROTOCOL, and uses otlptracehttp for http/protobuf. Endpoint, headers, TLS and timeout still come from the exporter's own OTEL_EXPORTER_OTLP_* handling.
  • gRPC stays the default, so deployments that set neither variable are unchanged. The OTLP exporter spec allows keeping grpc as the default for backward compatibility.
  • As the environment variable spec requires, values are case-insensitive and an unrecognized value is ignored with a warning. http/json, which the Go SDK has no exporter for, is also ignored, so a traces-specific http/json falls through to the general variable.
  • When a value is ignored, New still installs the exporter and returns a working stop function. It also returns an error that wraps the new ErrUnsupportedProtocol and names each ignored variable. cachewd logs that error as a warning and keeps starting, and the cachew CLI prints it as a warning.

Behaviour changes

  • A deployment that sets OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf for other services but points cachew at a gRPC endpoint now sends OTLP/HTTP to it. Such a deployment needs OTEL_EXPORTER_OTLP_TRACES_PROTOCOL=grpc.

Testing

  • TestNewExportsHTTPTraces runs an OTLP/HTTP receiver and checks that a span reaches /v1/traces in four cases: the general variable, a traces-specific override, an upper-case value, and an unsupported traces-specific value that falls through to the general one. The unsupported case also expects ErrUnsupportedProtocol.
  • TestNewFallsBackToGRPCForUnsupportedProtocol checks that http/json alone keeps the gRPC exporter, and that New returns a stop function along with an ErrUnsupportedProtocol error naming the variable.
  • Against the current tracing.go, every HTTP case fails because the receiver gets no request.

Created with Perplexity

@ravi-pplx
ravi-pplx requested a review from a team as a code owner November 22, 2026 03:32
@ravi-pplx
ravi-pplx requested review from joshfriend and removed request for a team November 22, 2026 03:32
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-22T03:56:39.742189Z 3ec5047 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2faf075f64

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread internal/tracing/tracing.go Resolved
@ravi-pplx
ravi-pplx force-pushed the fix/tracing-otlp-protocol branch from 2faf075 to a8dace6 Compare November 22, 2026 03:50

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a8dace6c26

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread internal/tracing/tracing_test.go Resolved
tracing.New always created a gRPC exporter. A deployment that sets
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf and points the endpoint at
an OTLP/HTTP collector had every export fail, so its spans were lost.

The exporter now follows OTEL_EXPORTER_OTLP_TRACES_PROTOCOL, then
OTEL_EXPORTER_OTLP_PROTOCOL, and still defaults to grpc. As the OTel
specification requires, values are case-insensitive, and an
unsupported value such as http/json is ignored with a warning instead
of failing startup. New reports ignored values by returning an error
wrapping ErrUnsupportedProtocol alongside a working stop function, and
cachewd and the cachew CLI print it as a warning.

Signed-off-by: Ravi Agarwal <ravi@perplexity.ai>
Co-authored-by: Perplexity <noreply@perplexity.ai>
@ravi-pplx
ravi-pplx force-pushed the fix/tracing-otlp-protocol branch from a8dace6 to 3ec5047 Compare November 22, 2026 03:54
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.

1 participant