Repository navigation
chore: decouple opentelemetry-proto from opentelemetry-sdk - #3512
scottgerring wants to merge 8 commits into
Conversation
|
@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 Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #3512 +/- ##
=======================================
- Coverage 84.0% 83.7% -0.3%
=======================================
Files 123 122 -1
Lines 30141 29765 -376
=======================================
- Hits 25328 24942 -386
- Misses 4813 4823 +10 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
803374d to
4985d5c
Compare
4985d5c to
ec5443d
Compare
|
|
||
| fn set_resource(&mut self, resource: &opentelemetry_sdk::Resource) { | ||
| self.resource = resource.into(); | ||
| self.resource = |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
@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? -->
| 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.
|
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. |
|
This isn't stale, it just needs a review :D |
|
@lalitb Can you review this one? |
|
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. |
|
@lalitb do you have time to look at this? |
|
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. |
|
Closed as inactive. Thank you again for the contribution; please feel free to reopen this PR (or open a new one) if you'd like to continue the work. |
|
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. |
|
Closed as inactive. Thank you again for the contribution; please feel free to reopen this PR (or open a new one) if you'd like to continue the work. |
ec5443d to
af9dbc1
Compare
The transform module was copied from opentelemetry-proto before two fixes landed on main. Port them into the opentelemetry-otlp copy so the move does not silently regress behaviour: - trace: group_spans_by_resource_and_scope moves spans into the proto conversion instead of cloning every SpanData (open-telemetry#3652). - logs: group_logs_by_resource_and_scope keys on the full InstrumentationScope and exports each scope's own schema_url, so logs sharing a target but differing in scope version/attributes/schema are no longer merged. Adds a regression test for the logs scope-grouping behaviour.
af9dbc1 to
6f8bb39
Compare
Personally, I like having the conversion traits as convenience. Could we instead define a feature flag (e.g. |
@herin049 TBH i'd rather fix the relationship between the crates and eat a bit of verbosity on the conversions. |
Isn't process context an SDK-independent crate? Regardless, I see your point here. Could we instead invert the dependency and add an optional |
6f8bb39 to
d25f572
Compare
I don't think the SDK should depend on a particular wire format crate - the spec is reasonably direct:
My mental model is that the SDK and the proto crate should logically fan in as deps of the OTLP crate; there should be no need for SDK or proto to depend on each other. In this case Rust's orphan rules mean we took a dep yonks ago so we could implement the conversion traits, implicitly accepting a tradeoff for caller sugar which causes pain now. Beyond that, in general with the feature flags we've already got so many that make the build increasingly hard to reason about, I am super hesitant to introduce more. Could be I'm missing something more here? Do you need the conversion functions for your procCtx purposes, or just the proto? One thing notable with this approach is - previously if you wanted to build something that serialises SDK types to proto types, you didn't need the OTLP crate, now you would. We actually have #3763 open at the moment which would add a new crate to do OTLP file format export, but it seems likely we'll fold that into the existing OTLP crate. edit: in the interests of not getting bogged down forever on what might be a heavy PR to review, maybe there's a cheap-and-cheerful the way you suggested initially; move the SDK dep behind a non-default flag in the proto crate. I'd personally rather pull the bandaid off, but let's see what the other @open-telemetry/rust-maintainers think |
Apologies if I'm seeming a bit pedantic 😅, was just thinking about alternatives. And no, this isn't needed for the process context work we're doing in Python, I'm just trying to look at this from a Rust user/implementor POV. I just have a strong preference for implementing the std traits when possible since in makes things a bit more ergonomic (in my opinion). I'm sure you and other maintainers have a much better idea of what the best approach is, so I'd be happy with whatever we align on. |
@herin049 honestly it's good to discuss to work out what's going to suck less 💪 ! I'll try and get opinions from the others so we can turn this around. |
Pull request dashboard statusClosed · refreshed 2026-10-27 09:44 UTC Status above doesn't look right?
|
This comment has been minimized.
This comment has been minimized.
|
+1 on removing proto’s dependency on the SDK and keeping protocol conversion outside the SDK. Could we keep the conversions public somewhere? Several public projects, including an exporter in contrib, use them to convert SDK data before sending or storing it in their own way. The file exporter in #3763 also uses these conversions for all three signals, so we should coordinate the changes. One option would be a small, separate conversion crate. The logs and metrics OTLP exporters are already stable, so this would avoid adding proto types and a new conversion API to their public interface. The conversion crate could remain experimental until we are ready to stabilise it. We could start with one function per signal, returning If we agree on this direction, we could add the replacement in this PR, or add it first in a separate PR before removing the old conversions. Migration instructions and a note about the removed tracez conversions would also help users. This is my preference, but I’d like to hear what the other @open-telemetry/rust-maintainers think. Would you prefer this approach, or a different way to keep the conversions available? |
@lalitb so I reckon we're aligned on breaking the dep and accepting free functions, and tbh if you're happy to add another crate just for this i'd be happy too as this will let us preserve the conversions for other users as you say. @herin049 as you started us down this path again, will this work for you all over in python land? I'm happy to throw this up quickly, but also happy to step out of the way if you are feeling enthusiastic; I know we are blocking you here. |
This sounds great, it's actually almost exactly what we do in Python
Definitely not blocking, feel free to take your time here! |
This comment has been minimized.
This comment has been minimized.
|
Closing this in favour of #3824 which takes the approach agreed on above - introducing a conversion crate. Just a draft for now but i'll have some time to polish it this week. |
Summary
This refactors
opentelemetry-protoso 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 directopentelemetry/opentelemetry_sdkdependency fromopentelemetry-protoand 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
opentelemetry_proto::transformmodule.opentelemetry-otlp::transformmodule.opentelemetry-protodocs and changelog to describe the crate as generated protobuf types only.Prior art / related work
This implements the SDK-decoupling part of:
prostfrom OTLP/JSON #3419 / feat: decouple prost from OTLP/JSON #3451 - adjacent work to reduce unnecessary proto/exporter dependencies for OTLP JSON/prost usage