Repository navigation
Description
Description
Opentelemetry (https://opentelemetry.io/) is quickly becoming the standard of sending telemetry data such as metrics, logs, and traces) to any targets supporting its protocol. Airflow as a popular choice of data pipelines need to send opentelemetry telemetry to any targets during its operation to make the pipeline be observed by many monitoring/observability tools currently available. This feature for OpenTelemetry will contain plugins, listeners, and hooks to make it easy for users to send out their own telemetry data via OpenTelemetry standards.
Use case/motivation
By providing 'opentelemetry provider' for airflow, user can easily use the provider that contains :
- listeners - to listen for task runs and dag runs, and emit them out as opentelemetry traces to configured OTEL endpoint.
- provider opentelemetry hooks for users sending out traces, and logs using opentelemetry within their DAG source codes
Motivation for this feature.
AIP-49 is finally released and became part of native Airflow support. With the new OTEL tracing capability in place, when enabled, users should be able to monitor:
- The performance and detailed trace of events happening around DAG run. Users would be able to note when each of the tasks inside the DAG run happened, and what was their outcome. Additionally, these information is now capable of being sent into OTLP compatible endpoint for collecting, storing, and analyzing in the compatible opentelemetry backend of choice.
- Not only that, there are other traces emitted from Airflow processes such as scheduler, triggerer, and executor that will emit trace on when and how long each heartbeat had taken place, how long did the dag processing took place, whether there were any errors, and the interaction between each task instances and executors linked together, such that users would be able to identify how the DAG runs were queued, and executed in much more detail.
But what about custom spans and attributes?
DAG run now can be expressed in traces which would look like the following:

These relationship between when a certain task ran at which time and order, and should be good enough for most of the observing how well the DAG run went.
However, this does not capture per task specific details that can describe additional information such as
- What were the business context and details specific to certain runs?
- Any additional information that could not be collected as part of the basic Run itself, such as
- data quality related information that user may want to instrument
- any execution or runtime information specific to certain operators or external systems
- any additional logs in which can be part of span events
from otel_hook import OtelHook
...
def setup(**dag_context):
with otel_hook.start_as_current_span(name="do_setup", dag_context=dag_context) as s:
s.set_attribute("data quality", "fair")
s.set_attribute("description", "You can add attributes in otel hook to have business or data specific details on top of existing task instnace span.")
with otel_hook.start_as_current_span(name="do_sleep") as ss:
ss.set_attribute("sleep for", "one second")
time.sleep(1)
# simple setup operator in python
t0 = PythonOperator(
task_id="setup",
python_callable=setup
)Providing such means for the users to instrument any DAG run specific spans or contexts and make them as part of the task instance would tremendously help to gain deeper insights. Imagine if the user can easily add their own Spans inside their DAG file to record certain activities happening:

OTEL provider will have OTEL hook that can help you to do this. Using the hook, you may be able to create active span and attach it to the current running DAG's task instance, conveniently.
Supporting lower version of Airflow to emit DAG run trace
Another feature for the OpenTelemetry provider is providing ways to capture DAG runs in case the Airflow version is lower (v2.10.0) than the Airflow that has OTEL trace enabled. In that case, with the limited capability, OTEL provider can generate traces coming from the task instances, that can complement Airflows that either have lower version or have the OTEL capability disabled. In that case, provider can automatically detect and start generating its own traces regardless.
This can also be combined with user's custom instrumentation so that the instrumentation can still be used, whether the Airflow is enabled with OTEL, or airflow is using OTEL provider.
- OTEL provider will implement an event listener.
- this event listener will only work when it is enabled via configuration
- If the even listener detects the airflow version is >= 2.10.0, then it will try to check whether OTEL instrumentation is enabled. If so, it will use its configuration (endpoint) to emit traces. If not, it will default to the configuration provided by its connection info.
However, event listener can only detect and collect whatever information is available via DagRun and TaskInstance, and therefore will not be able to collect all the traces (e.g. scheduler job) that are available from OTEL traces for Airflow.
This feature could also be useful if user is unable to upgrade into Airflow v2.10, and still want to leverage the OTEL tracing.
Related issues
None
Are you willing to submit a PR?
- Yes I am willing to submit a PR!
Code of Conduct
- I agree to follow this project's Code of Conduct
Activity
ferruzzi commentedon Feb 23, 2024
I'm not sure I see the benefit here? We have already discussed and plan to implement traces and logging Some Day ™️ what is gained by adding a provider? A user can already currently add custom metrics to their operators and hooks by using
howardyoo commentedon Feb 24, 2024
@ferruzzi , there are couple of things.
I did happen to think about it for some time, and looks like some vendors like datadog does support dogstats as well as datadog hooks to send arbitrary telemetry data as needed. This seemed to be a reasonable choice.
rutvikjshah commentedon Mar 14, 2024
@ferruzzi , @howardyoo
I am trying to do a POC, basically I want to provide the status of my Airflow DAG runs (even task runs) and send this metrics to opentelemetry and show these logs as graphs in grafana dashboard. I followed the medium blog you have provided Better Apache Airflow Observability using OpenTelemetry. But I am kind of failed in achieving the results.
When I run otel-collector service as per the yaml that you attached in the medium blog. It is generating these logs. This means otel is up and running. But I am unable to send the metrics to otel. How can I do it. Informations are not sufficient in your blog. Can you please provide quick solution
ferruzzi commentedon Mar 14, 2024
Hey @rutvikjshah, thanks for your interest in checking it out and thanks for having a look at the blog post. This is definitely not the right place for me to help you out on that though. Join us over on the community slack and start up a thread (maybe in #user-troubleshooting) and we can have a chat and get you sorted out.
josix commentedon Aug 7, 2024
Hi @howardyoo and @ferruzzi,
I'm wondering if the OpenTelemetry provider would still fall under the scope of AIP-49. I noticed there's a discussion about the provider proposal in the dev-list. Could we move this topic into a Discussion? I'm currently helping to triage the open issues.
Thanks!
howardyoo commentedon Aug 7, 2024
josix commentedon Aug 7, 2024
Thanks @howardyoo for the quick response. Would you mind helping remove the label for AIP-49? I probably don't have permission to do this myself. I think we could leave it open, and I'll keep the status in sync with the email thread once a conclusion has been reached.
howardyoo commentedon Aug 7, 2024
howardyoo commentedon Aug 16, 2024
Hi folks! As part of the items raised during the discussion in dev mailing list, I updated the document for this issue to further clarify what is the requirements and reasons behind OpenTelemetry provider for Airflow.
swythan commentedon Sep 10, 2024
I'd be really interested in having access to this so I thought I would post my use case.
What I want to do is:
Stupid example:
With the proposed provider my trace would be:
This really helps diagnostics if the problem you're looking into is in e.g. FooService (or one of its dependencies).
I've verified this works with the code Howard has posted here: https://github.com/howardyoo/airflow_otel_provider
chris-stetter commentedon Dec 1, 2025
Now that OTEL tracing and metrics is airflow native, is there any plan to add OTEL logging to airflow? We are currently using remote cloudwatch logging, but would love to switch to remote OTEL.
ferruzzi commentedon Dec 1, 2025
@chris-stetter "plans" might be a strong word. It's been mentioned as a "some day" feature, but I don't believe anyone is actively working on that feature at the moment.
potiuk commentedon Dec 2, 2025
Well. Anyone can try (including you @chris-stetter ) - however so far also our assesment was that logging integration in OTEL is quite a different beast. Not only it is using quite a different approach than metrics and traces, but also it would haevily interact with the way we are doing logging in Airflow. Currently we are using structlogs and we also need integration of logging at the level of Airlfow UI - where we have to display the logs from tasks - not only from workers, but also from corresponding triggers - also it has all the performance improvements when scrolling the logs where we have to retrieve the logs only partially and K-Merge them when they are coming from different sources for the same task.
That makes the OTEL integration for logging far more risky and complicated - so there is currently no active work on that and unless someone has a very, very good reason to get it and invest time in it, it's unlikey to happen "like that".
But - implementing it yourself and testing or even finding someone who can implement and your company will pay for is a good way to speed it up (or even to implement it at all).
howardyoo commentedon Dec 2, 2025
PFacheris commentedon Feb 3, 2026
In case it's helpful to others, I've managed to get something working that hooks into the Airflow 3 structlog task logger (and does env variable based filtering to only deliver task logs). Would love if there was a cleaner way to accomplish this though.
https://gist.github.com/PFacheris/d622961b1ab3d1c3efb01b0d5e25b5f2