What is the relationship between telemetry and opentelemetry?

I am researching instrumentation and I see there’s the :telemetry library but there is also :opentelemetry and additional integrations such as :opentelemetry_ecto.

What is the relationship between the two? Is opentelemetry meant to replace telemetry or do they serve different purposes?

It also seems like they both have mechanisms for tracking events. There is Tracer.with_span in opentelemetry and there is :telemetry.execute in telemetry.

If you’re using one or the other or both, would love to hear about your setup!

There is no direct relationship between these two libraries.

:telemetry allows you to add hooks and collect metrics from internals of your own code and libraries and then do stuff with it using collectors.

OpenTelemtry is a distributed tracing standard for applications.

OpenTelemtry can use bits and pieces and hook into libraries and code using :telemetry but they operate on entirely different layer.

You might want to look at telemetria library I wrote to simplify enabling and globally configuring telemetry in your app. It is backend-agnostic and might be used with both :telemetry and :opentelemetry backends.

3 Likes

To clarify I’m referring to :opentelemetry the elixir/erlang implementation of the tracing standard.

I was wondering if :opentelemetry makes :telemetry unnecessary or if they are complementary.

Very cool. Will check it out!

Yes, they’re complementary. One is Elixir/Erlang specific, the other one not.

telemetry is a framework/standard inside the ecosystem to emit events about the internal execution of a code. those events can be used to produce metrics, logs, traces and anything else you can think.
opentelemetry is a library that integrates with the opentelemetry toolset and standard.

telemetry events can be consumed to generate opentelemetry traces, logs and metrics but is not limited to it. for example, the same event telemetry event can generate a trace to opentelemetry and a metric on prometheus, and a log line.

on a systems side thing it’s like telemetry is ebpf for elixir/erlang code, and opentelemetry is more like tetragon.

2 Likes

Thanks this really clears it up!

So I suppose it would be considered a good practice to have code produce telemetry events (which is agnostic to how it would be consumed) and somewhere else one might forward telemetry events to opentelemetry?

Actually it seems like this is what opentelemetry_ecto is doing:

It is calling :telemetry.attach to listen to telemetry events coming from Ecto, then it translates that to a format that opentelemetry understands.

So it seems like telemetry is almost like a logging solution but a lot broader (not just text messages). It does nothing to specify how those messages are actually handled.

1 Like

usually telemetry is used for libraries, so they can expose their execution steps to the external world. while opentelemetry you gonna use on your actual application. on application side you usually just need to worry about telemetry if you want to attach to some event.

2 Likes