opentelemetry-instrumentation-dagster
Automatic tracing for Dagster pipelines: pip install, run your pipeline through the opentelemetry-instrument launcher,
and every @op/@asset/@multi_asset/@asset_check/@dbt_assets gets a
span. No @traced() decorators, no code changes, no imports in your own
pipeline files at all.
# before
dagster dev -f definitions.py
# after: the same command behind the launcher. definitions.py is not touched.
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317 \
opentelemetry-instrument dagster dev -f definitions.py
What you get in your tracing backend:
- One span per step, named after the node Dagster runs (for example
warehouse__customers). - Dagster's identity on every span:
dagster.run_id,dagster.job_name,dagster.step_key,dagster.retry_number, and the asset keys. - A step's span is the child of its upstream step's span, even when steps run in different processes.
- The steps of one run share one trace, so a run reads as one tree.
- For
@dbt_assets, a child span per dbt node and per dbt test. - Log lines written through
context.logcarry the span'strace_idandspan_id, for a logger that reads them.
Built on dagster-otel
(same author) -- that project does the actual span creation via an explicit
@traced() decorator; this one's only job is applying it automatically
instead. See docs/design.md for why they're two separate
packages rather than one.
For metrics (run counts and durations, schedules and sensors, asset status), see
dagster-prometheus-exporter
(same author). It polls Dagster's GraphQL API, so it needs no change to your
pipeline either.
Table of Contents
- Installation
- Quick Start
- Usage
- How it works
- What's covered
- When it does not apply
- Configuration
multiprocess/k8s_job_executor- Compatibility
- Why a separate package
- Contributing
- Roadmap
- License
Installation
pip install opentelemetry-instrumentation-dagster
Quick Start
docker compose up -d brings up a local Jaeger (no other setup) so you can
see a real trace land within a couple of minutes.
examples/definitions.py is a plain Dagster job
and asset -- zero @traced() calls, zero dagster_otel/opentelemetry
imports, nothing at all:
git clone https://github.com/HirofumiTsuda/opentelemetry-instrumentation-dagster
cd opentelemetry-instrumentation-dagster
docker compose up -d
pip install opentelemetry-instrumentation-dagster
OTEL_SERVICE_NAME=quickstart \
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317 \
opentelemetry-instrument dagster asset materialize -f examples/definitions.py --select example_asset
Open http://localhost:16686 (Jaeger's UI), select the quickstart service,
and there's the span -- example_asset, from a file that never imported
this package or dagster-otel at all.
Teardown: docker compose down.
For @dbt_assets specifically, examples/dbt_workspace/definitions.py
runs the same zero-code approach against a real dbt project
(examples/jaffle_shop/) instead of a hand-written
toy asset -- see docs/design.md for the full verification
writeup (per-dbt-node child spans, name= support, and a gotcha in
generating the manifest from the wrong directory).
Usage
Same idea against your own pipeline: run your usual Dagster command through
the opentelemetry-instrument launcher instead of running it directly.
OTEL_SERVICE_NAME=my_pipeline \
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317 \
opentelemetry-instrument dagster dev -f definitions.py
That's the entire setup. Every @op/@asset/@multi_asset/@asset_check/
@dbt_assets in definitions.py gets a span automatically, with no
decorator, no import, no change to the file at all:
from dagster import asset, job, op
@op
def upstream_op(context) -> int:
return 1
@op
def downstream_op(context, x: int) -> int:
return x + 1
@asset
def my_asset(context) -> None:
...
@job
def my_job():
downstream_op(upstream_op())
The launcher works the same way in front of dagster job execute,
dagster-webserver, dagster-daemon, or any other Dagster entry point --
it's a drop-in prefix, not something specific to dagster dev.
How it works
opentelemetry-instrumentstarts Python and callsinstrument()before any of your code is imported. It finds this package through the standardopentelemetry_instrumentorentry point.instrument()wraps Dagster's own decorators (dagster.op,dagster.asset,dagster.multi_asset,dagster.asset_checkand a few more) with wrapt.- When your
definitions.pyis imported, each decorator call goes through that wrapper first. The wrapper appliesdagster_otel.traced()to your compute function, then hands it to Dagster as usual. - Dagster builds your ops and assets from the traced functions. Your files are unchanged, and the only parts of Dagster that are wrapped are those decorator factories.
@dbt_assets needs no patch of its own. It calls dagster.multi_asset internally, and the wrapper recognizes that call and uses dagster_otel.dbt.traced_dbt() for it. See docs/design.md for how.
What's covered
| Decorator | Status |
|---|---|
@op |
✅ Patched -- bare and @op(name=...) forms |
@asset |
✅ Patched -- bare and @asset(name=...)/key=/key_prefix= forms |
@multi_asset |
✅ Patched |
@asset_check |
✅ Patched. The span is named <asset>_<check>, like the step in Dagster's UI. |
@multi_asset_check |
✅ Patched -- one span for the step, with every check it evaluates in dagster.asset_check_keys |
@observable_source_asset |
✅ Patched -- bare and parameterized forms; the span covers the observation function when an observation job runs it |
@multi_observable_source_asset |
✅ Patched |
@dbt_assets (dagster_dbt) |
✅ Patched. One span for the step, plus a child span per dbt node and per dbt test, as with a manual @traced_dbt(). |
@graph_asset / @graph_multi_asset |
⬜ Not patched on purpose. The function only composes ops and never runs as a step. The ops it composes are traced. |
Across all of the above:
- Span names follow the node name Dagster actually runs, not the Python function's name. That covers
name=,key=/key_prefix=(e.g.warehouse__customersfor an asset-factory output),@multi_asset(name=...), and.alias(). - Compute functions without a
contextparameter (@asset def x(): ...) andasync deffunctions (coroutines and async generators) are traced like any other. - A function you already decorated with
@traced()/@traced_dbt()isn't wrapped a second time. Your own decorator, and its span name, win.
All of this comes from dagster-otel >= 0.6.0, which this package requires.
When it does not apply
dagster_dbtwas imported beforeinstrument()ran.@dbt_assetsis then not traced, becausedagster_dbtalready holds a reference to the unpatchedmulti_asset.instrument()warns when it sees this. Start throughopentelemetry-instrument, or callinstrument()before importingdagster_dbt.k8s_job_executor. Each step is a new Pod, so the launcher prefix cannot reach it. Bake the instrumentation into the image, see below.- You already have a
TracerProvider. A run with several independent root steps is split across traces unless that provider usesdagster-otel's ID generator, see Your ownTracerProvider. @graph_asset. Not patched, see the table above.OTEL_EXPORTER_OTLP_ENDPOINTis not set. Spans are created but not sent anywhere, so nothing shows up in your backend.
Configuration
Same standard OTel environment variables dagster-otel itself reads --
nothing this package adds on top:
| Variable | Purpose |
|---|---|
OTEL_SERVICE_NAME |
Names your service in the trace backend. |
OTEL_EXPORTER_OTLP_ENDPOINT (or ..._TRACES_ENDPOINT) |
Where to send spans (e.g. http://localhost:4317). Required -- without one of these set, no real exporter is attached at all. |
OTEL_EXPORTER_OTLP_TRACES_PROTOCOL / ..._PROTOCOL |
Transport to export over: grpc (default) or http/protobuf. |
OTEL_SDK_DISABLED |
Set to true to turn tracing off. Your functions run as they are: no spans, no run tags, no run-storage lookups (dagster-otel 0.5.2 and later). |
See dagster-otel's own README
for the full list and what each one actually does underneath -- this package
doesn't wrap or reinterpret any of it, just triggers the same traced()
that reads these itself.
Your own TracerProvider
Under opentelemetry-instrument, the SDK builds the provider from the variables above, and
nothing more is needed except one thing. A run with several independent root steps stays in
one trace only if that provider uses dagster-otel's ID generator. Select it by name:
OTEL_PYTHON_ID_GENERATOR=dagster_otel opentelemetry-instrument dagster ...
If you call instrument() yourself, pass the provider you want the spans sent to. It is the
standard tracer_provider argument, and nothing is installed globally:
DagsterInstrumentor().instrument(tracer_provider=my_provider)
Build my_provider with id_generator=dagster_otel.DeterministicRunIdGenerator(), or
dagster-otel logs a warning that a run can be split across traces. The provider stays set
after uninstrument(): functions that were already wrapped keep sending to it.
multiprocess/k8s_job_executor
Each step in a multiprocess-executed run runs in its own, freshly spawned
Python interpreter -- the opentelemetry-instrument launcher above already
handles this correctly (verified against a real run, see
docs/design.md), no extra setup needed.
k8s_job_executor is different: each step becomes a genuinely separate
Kubernetes Pod, and the launcher's usual mechanism can't propagate into a
brand new container the way it does into a spawned OS subprocess. This
needs the instrumentation baked into the container image itself instead --
no opentelemetry-instrument prefix anywhere, because nothing in your own
config controls the command k8s_job_executor constructs internally for
each step Pod.
Using this with k8s_job_executor
In your own Dockerfile, after installing this package, copy
opentelemetry-instrumentation's real sitecustomize.py into your venv's
site-packages root:
RUN site_packages="$(python -c 'import sysconfig; print(sysconfig.get_paths()["purelib"])')" && \
cp "$site_packages/opentelemetry/instrumentation/auto_instrumentation/sitecustomize.py" \
"$site_packages/sitecustomize.py"
Python auto-imports any module literally named sitecustomize found
directly in site-packages at interpreter startup -- so this alone is
enough, in every container built from that image, including every step Pod
k8s_job_executor launches from it. No PYTHONPATH, no .pth file, no
launcher prefix anywhere in your run config or Dockerfile CMD.
(If your build process makes a sysconfig-based path awkward -- e.g. a
venv at a path you already know ahead of time -- find /path/to/venv -maxdepth 4 -type d -name site-packages works just as well. Setting
PYTHONPATH explicitly via k8s_job_executor's env_vars run config is
an alternative to copying the file at all, if that fits your deployment
better.)
dev/kubernetes/ is a complete, real-cluster-verified
example of this exact pattern (Dockerfile, kind manifests, RBAC) --
written as this project's own verification harness, not a
copy-paste-ready deployment template, but the Dockerfile's approach is the
same one described above. See docs/design.md for the
full reasoning and the negative-control verification.
Compatibility
Depends on dagster-otel
>= 0.6.0 and dagster >= 1.10, the same Dagster floor as that project
(dagster-otel#86).
CI runs the test suite against both the locked Dagster version and the newest
1.10 patch, with its matching dagster-dbt. If you hit an incompatibility, open an issue.
Why a separate package
dagster-otel's whole pitch is tracing without monkeypatching Dagster
internals and without taking ownership of your op/asset definitions away
from you. Auto-instrumentation is the opposite trade: zero code changes, in
exchange for some framework patching and losing that per-function
visibility. Both are legitimate, but they're different products for
different people -- same split the OpenTelemetry Python ecosystem itself
uses (opentelemetry-instrumentation-flask, -django, etc. are all
separate packages from the manual API/SDK). See
docs/design.md for the full reasoning.
Contributing
Issues and PRs welcome -- open an issue for bugs, missing coverage, or a backend that doesn't work as expected.
Roadmap
-
@op/@asset/@multi_assetpatched, verified against real Dagster execution acrossmultiprocessandk8s_job_executor, both exported to a real Jaeger -
@asset_checkpatched (see What's covered) -
@dbt_assetscovered for free -- it callsmulti_assetinternally -
opentelemetry_instrumentorentry point resolution verified - Warn when
dagster_dbtis already imported beforeinstrument()runs - Verify
@dbt_assetsend-to-end against a real dbt project (#6, #28) - Dispatch
@dbt_assetscalls totraced_dbt()for per-dbt-node span granularity (#14) - Test that exceptions propagate correctly through the patched decorator (#11)
- Combined demo:
dagster-prometheus-exportermetrics + zero-code traces, through Grafana Tempo (#24) - Test the parameterized-decorator-without-name dispatch branch (#10)
- Test
uninstrument()for@asset/@multi_asset, not just@op(#9)
License
MIT
Metadata
Release files for opentelemetry-instrumentation-dagster 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| opentelemetry_instrumentation_dagster-0.4.0.tar.gz | 325.1 kB | With provenance | Details for opentelemetry_instrumentation_dagster-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| opentelemetry_instrumentation_dagster-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for opentelemetry_instrumentation_dagster-0.4.0-py3-none-any.whl |
Total release size: 338.6 kB
Release files / opentelemetry_instrumentation_dagster-0.4.0.tar.gz
| Download URL | opentelemetry_instrumentation_dagster-0.4.0.tar.gz |
|---|---|
| Size | 325.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d9be503a00847484747bd4d514fdce9457e607c20d64d5e300196c449f8d17fe
|
|
BLAKE2b-256 checksum How to use checksums |
3e05e25cd055edc7e281dc1519ef59eefc343ef69f1c10fa7c5b847619f88ac7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.
Transparency logRelease files / opentelemetry_instrumentation_dagster-0.4.0-py3-none-any.whl
| Download URL | opentelemetry_instrumentation_dagster-0.4.0-py3-none-any.whl |
|---|---|
| Size | 13.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
98f1459e993fdd4b56d539c951d2ca22148d624caf1c916f0682c27ca9c1a370
|
|
BLAKE2b-256 checksum How to use checksums |
d3534091d875bb23bcdc4252e154366779645c8caf48d7532b46a5c02aad04af
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.
Transparency logSecurity for opentelemetry-instrumentation-dagster 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for opentelemetry_instrumentation_dagster-0.4.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.