hst337

hst337

How to convert telemetry to opentelemetry

I have a lot of libraries which emit telemetry events, and I’d like to covert them into OpenTelemetry spans. I’ve found the opentelemetry_telemetry library, but examples there do not work and it looks heavily outdated, without proper documentation, plus :telemetry doesn’t allow attaching to event by prefix, so I have to write some strange and hacky code to translate spans from one library to another.

It would be nice if anyone could share their experience here, thanks!

First 10 of 16 Posts Switch mode

michallepicki

michallepicki

Tricky subject, but I wouldn’t say that the telemetry library itself has any notion of spans? It’s main purpose is dynamic dispatch, and maybe some specific library emits events that are aware of spans :thinking:

Are you looking for some way to reduce code boilerplate that can be found in libraries like these ones from opentelemetry-erlang-contrib?

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

If you look at libraries like OpenTelemetryOban you can see that the common pattern is to create :telemetry hooks that then initiate open telemetry spans. This allows you to stick with the more general purpose telemetry library while also enabling people who use open telemetry to get otel spans out.

hst337

hst337 OP

I thought so too, but it turns out that telemetry.span generates unique span context in metadata for every span, so it is possible to convert a telemetry span to opentelemetry span.

hst337

hst337 OP

Yeah, I’ve seen it, and just took a look again, but it feels really annoying to write the same boilerplate for something which telemetry.span already does out of the box. I want a solution where every span from telemetry is automatically exported in an opentelemetry format. And I don’t see any limitations for this solution, do you?

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

The limitation is that if someone wants to get spans from your library and export them to say app signal they have to convert otel spans to app signal spans which is a lot heavier weight than regular telemetry spans to app signal spans.

End users of your library that aren’t doing otel will end up pulling in a bunch of dependencies as well.

hst337

hst337 OP

You got me wrong. I am not suggesting writing telemetry in otel always. I am suggesting to have a relay which automatically converts all telemetry spans to otel spans, and as far as I can see, there are no limitations for this, but still, every opentelemetry_* library writes this boilerplate from scratch

tristan

tristan

Rebar3 Core Team

The first point about AppSignal is a good one But there are not a “bunch of dependencies” that will be pulled in . A library should only depend on opentelemetry_api which itself has 0 dependencies :slight_smile:

bside

bside

I’m not sure what trouble you’re having here. The bridge library is up to date and used by probably half of our instrumentation libraries. Perhaps you could elaborate here or pop into opentelemetry on the Elixir Slack for help.

hst337

hst337 OP

I want to automatically convert telemetry span events to opentelemetry spans. I know that the generic solution is possible, but I can’t implement it yet with the knowledge I have right now

bside

bside

It is possible but it has additional requirements. There is no way to try to create spans from every possible event in the system without a mechanism to register the events.

Please note, this undocumented experimental functionality is being removed from this library so do not rely on it.

https://github.com/open-telemetry/opentelemetry-erlang-contrib/blob/main/utilities/opentelemetry_telemetry/src/otel_telemetry.erl#L28-L36

Where Next?

Trending in Questions Top

jonnycharles
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
silverdr
Using Phoenix.LiveView.TagEngine as an EEx.Engine is deprecated! To compile HEEx, use Phoenix.LiveView.TagEngine.compile/2 instead. Sta...
New
dli
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app? Looking for hints regarding: Addi...
New
bottlenecked
Hi all, I wanted to ask how the community is dealing with post-release steps. Today we have Ecto migrations, which make sure that the db...
New
michallepicki
I am using Oban and occasionally, shortly after a deployment, a handful of jobs can fail because of dependency on other parts of the syst...
New
rahultumpala
Hello, I have an Elixir backend that implements a custom protocol over TCP. I want to load test the backend and assess the performance o...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
type1fool
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
akoutmos
@hugobarauna and I (Alex Koutmos) have been hard at work on writing a book on Nerves that takes you from simply blinking LEDs to building...
New

We're in Beta

About us Mission Statement