open-telemetry / opentelemetry-rust

The Rust OpenTelemetry implementation
https://opentelemetry.io
Apache License 2.0
1.85k stars 431 forks source link

Publish protobuf conversions as their own crate or otherwise expose #627

Closed Sushisource closed 2 years ago

Sushisource commented 3 years ago

I have a usecase where I've written a Rust lib that is used by a variety of other languages to create a single worker process. I don't want to require my users to run the OTel collector when they are running our workers, but I do have a need to propagate spans and metrics from the Rust library, to the library where they can they be exported by the user's choice of exporter.

Seemingly, the easiest way to do this is for me to essentially do what happens when exporting to an OTel collector, but rather than actually calling a collector over HTTP or gRPC, I simply pass the protobufs in memory to the side where they are unpacked, turned into that languages' typical representation (would also be nice if the SDKs had proto->lang api converters to make that easy), and then passed to the user's exporter.

As it stands though, all the proto conversion stuff is privately hidden inside https://github.com/open-telemetry/opentelemetry-rust/tree/main/opentelemetry-otlp/src/transform -- if this was it's own crate, or even publicly exposed, that would be awesome! Right now I'm resorting to just copying your transformation code in order to do this.

Thanks!

TommyCpp commented 3 years ago

I think it will also help reduce duplicate transformation code in opentelemetry-otlp and opentelemetry-zpages. Will take a swing on this once I get my new device set up.