Skip to content

Conversation

@scottgerring
Copy link
Member

@scottgerring scottgerring commented Nov 10, 2025

Really A Draft: Trying a different approach; please hold off on reviews!

Fixes #3082
This PR removes the ability to specify invalid combinations of transport (HTTP/gRPC) and encoding (JSON/Protobuf) by making the invalid combinations unrepresentable.

For completeness, I staged a separate branch that simply errors out when a user specifies an invalid combination. This has less impact on the API surface and is a smaller change, but doesn't prevent the user from specifying the invalid combinations. I prefer this variant here where we use the type system!

Changes

We do this by:

  • Removing with_protocol from the WithExportConfig shared between both gRPC and HTTP exporters
  • Introducing HttpEncodingProtocol, and supporting methods on WithHttpConfig to configure JSON or Protobuf encoding

I wanted to draw a clear line between 'protocol' and 'encoding' as this feels like where the confusion has crept in, but the spec itself uses the term protocol to refer to both application layer protocol and body encoding.

Merge requirement checklist

  • CONTRIBUTING guidelines followed
  • Unit tests added/updated (if applicable)
  • Appropriate CHANGELOG.md files updated for non-trivial, user-facing changes
  • Changes in public API reviewed (if applicable)

@scottgerring scottgerring force-pushed the chore/protocol-cleanup-2 branch 2 times, most recently from cbcc038 to 6a969a2 Compare November 10, 2025 12:38
@codecov
Copy link

codecov bot commented Nov 10, 2025

Codecov Report

❌ Patch coverage is 93.97590% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.7%. Comparing base (5c8dbc8) to head (829a910).

Files with missing lines Patch % Lines
opentelemetry-otlp/src/exporter/http/mod.rs 83.8% 5 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main   #3229     +/-   ##
=======================================
- Coverage   80.8%   80.7%   -0.1%     
=======================================
  Files        128     128             
  Lines      23156   23152      -4     
=======================================
- Hits       18711   18704      -7     
- Misses      4445    4448      +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@scottgerring scottgerring marked this pull request as ready for review November 10, 2025 12:47
@scottgerring scottgerring requested a review from a team as a code owner November 10, 2025 12:47
@scottgerring scottgerring marked this pull request as draft November 10, 2025 12:54
}

#[allow(clippy::derivable_impls)]
impl Default for HttpConfig {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see anything in this that can't be derived.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch!

@scottgerring scottgerring force-pushed the chore/protocol-cleanup-2 branch 3 times, most recently from 81bef11 to 1a8d755 Compare November 10, 2025 13:22
@scottgerring scottgerring force-pushed the chore/protocol-cleanup-2 branch from 1a8d755 to 829a910 Compare November 10, 2025 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OTLP Stabilization: Protocol enum ambiguity in API

2 participants