Skip to content

chore: decouple opentelemetry-proto from opentelemetry-sdk#3512

Open
scottgerring wants to merge 7 commits into
open-telemetry:mainfrom
scottgerring:sgg/proto-decouple
Open

chore: decouple opentelemetry-proto from opentelemetry-sdk#3512
scottgerring wants to merge 7 commits into
open-telemetry:mainfrom
scottgerring:sgg/proto-decouple

Conversation

@scottgerring

Copy link
Copy Markdown
Member

Summary

This refactors opentelemetry-proto so it only contains generated OTLP protobuf types. The diff is substantial because of the orphan rules - opentelemetry-otlp cannot implement the conversion traits for foreign types into foreign types. My feeling is that we just need to pull off the bandaid here!

The SDK/api-aware transform helpers have been moved into opentelemetry-otlp, where they are used by the exporters. This removes the direct opentelemetry / opentelemetry_sdk dependency from opentelemetry-proto and makes the crate usable by consumers that only need OTLP wire-format types. This will also provide other options to structure changes like #3460 , where we could benefit from having the dependency the other way around (although this is by no means a done deal).

Changes

  • Remove the public opentelemetry_proto::transform module.
  • Move SDK/API → OTLP protobuf transformation logic into a private opentelemetry-otlp::transform module.
  • Update OTLP exporters to use the local transform helpers.
  • Update opentelemetry-proto docs and changelog to describe the crate as generated protobuf types only.

Prior art / related work

This implements the SDK-decoupling part of:

@scottgerring scottgerring assigned lalitb and unassigned lalitb May 11, 2026
@scottgerring scottgerring requested a review from lalitb May 11, 2026 07:55
@scottgerring

Copy link
Copy Markdown
Member Author

@lalitb I know you've worked on this before; it would be great to get your high-level opinions on this so I can push it in the right direction. I'm not sure if i've missed some important nuance given this has come up a few times but never landed!

@codecov

codecov Bot commented May 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 46.46617% with 356 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.0%. Comparing base (dfdc478) to head (ec5443d).
⚠️ Report is 26 commits behind head on main.

Files with missing lines Patch % Lines
opentelemetry-otlp/src/transform/metrics.rs 9.8% 202 Missing ⚠️
opentelemetry-otlp/src/transform/logs.rs 69.9% 68 Missing ⚠️
opentelemetry-otlp/src/transform/trace.rs 47.6% 45 Missing ⚠️
opentelemetry-otlp/src/transform/common.rs 74.3% 30 Missing ⚠️
opentelemetry-otlp/src/exporter/tonic/metrics.rs 0.0% 3 Missing ⚠️
opentelemetry-otlp/src/exporter/http/logs.rs 0.0% 2 Missing ⚠️
opentelemetry-otlp/src/exporter/http/trace.rs 0.0% 2 Missing ⚠️
opentelemetry-otlp/src/exporter/tonic/logs.rs 0.0% 2 Missing ⚠️
opentelemetry-otlp/src/exporter/tonic/trace.rs 0.0% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main   #3512     +/-   ##
=======================================
+ Coverage   82.8%   83.0%   +0.1%     
=======================================
  Files        130     129      -1     
  Lines      27289   27229     -60     
=======================================
- Hits       22622   22614      -8     
+ Misses      4667    4615     -52     

☔ View full report in Codecov by Harness.
📢 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 force-pushed the sgg/proto-decouple branch 2 times, most recently from 803374d to 4985d5c Compare May 12, 2026 07:07
@scottgerring scottgerring marked this pull request as ready for review May 12, 2026 07:15
@scottgerring scottgerring requested a review from a team as a code owner May 12, 2026 07:15

fn set_resource(&mut self, resource: &opentelemetry_sdk::Resource) {
self.resource = resource.into();
self.resource =

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.

More of a style suggestion. But I wonder if it would be better to package this as a extension trait against SDK resource, instead of resource_to_attributes_with_schema function

@scottgerring scottgerring May 26, 2026

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.

@TommyCpp thanks for taking a look, and good point!

I think this conversion is one of the few places where a method-style API could be reasonable, since it’s a high-level boundary used directly by the exporters.

That said, I’m a bit hesitant to make it look like an operation that inherently belongs on Resource: this is really an OTLP/proto-specific projection of a Resource, including how we carry the schema URL alongside attributes. Since we already have a local target type here, From<&Resource> gives us a short call site without adding an extension trait or implying this is a general Resource capability; maybe something like this? -->

Suggested change
self.resource =
self.resource = resource.into();

For the broader transform module I’d probably keep the explicit *_to_proto functions, since most are lower-level implementation details or external-to-external mappings where From isn’t available due to orphan rules.

@github-actions

Copy link
Copy Markdown

Thank you for your contribution! This PR has been automatically marked as stale because it has not had activity in the last 14 days. This may be due to a delay in review on our side or awaiting a response from you; either is fine, and we appreciate your patience.

It will be closed in 14 days if no further activity occurs. Pushing a new commit or leaving a comment will remove the stale label and keep the PR open.

@scottgerring

Copy link
Copy Markdown
Member Author

This isn't stale, it just needs a review :D

@cijothomas

Copy link
Copy Markdown
Member

@lalitb Can you review this one?

@github-actions

Copy link
Copy Markdown

Thank you for your contribution! This PR has been automatically marked as stale because it has not had activity in the last 14 days. This may be due to a delay in review on our side or awaiting a response from you; either is fine, and we appreciate your patience.

It will be closed in 14 days if no further activity occurs. Pushing a new commit or leaving a comment will remove the stale label and keep the PR open.

@github-actions github-actions Bot added Stale and removed Stale labels Jun 25, 2026
@scottgerring

Copy link
Copy Markdown
Member Author

@lalitb do you have time to look at this?

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.

4 participants