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!
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.
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.
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.
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.