opentelemetry-instrumentation-absurd
OpenTelemetry instrumentation for the Absurd
durable-task SDK (absurd-sdk).
Absurd (absurd_sdk.AsyncAbsurd) is a Postgres-backed durable task queue: a producer
spawn()s a task and a worker work_batch() claims and runs the registered handler, possibly
in a different process. Without instrumentation the two halves live in separate traces, so a
task's execution cannot be linked back to whatever spawned it.
This instrumentor follows the standard producer/consumer span shape for a task queue:
AsyncAbsurd.spawn()is wrapped to open aCLIENTspan named after the task and inject the current trace context into the task'sheaders. Absurd persists headers on the task row and hands them back to the handler viactx.headers.AsyncAbsurd.register_task()is wrapped so every registered handler runs inside arunning:<task>SERVERspan whose parent is extracted from those headers.
The two spans share one trace, so a task's execution is linked back to whatever spawned it — even when the spawner and the worker run in different processes.
trigger (your span)
└── report CLIENT ← spawn() (process A)
└── running:report SERVER ← handler (process B)
Installation
pip install opentelemetry-instrumentation-absurd
# or
uv add opentelemetry-instrumentation-absurd
Usage
Install the instrumentor once per process, on both the spawn side and the worker side:
from opentelemetry.instrumentation.absurd import AbsurdInstrumentor
AbsurdInstrumentor().instrument()
That is all — no changes to your spawn() calls or task handlers are required. Only
AsyncAbsurd is instrumented.
You can pass an explicit TracerProvider:
AbsurdInstrumentor().instrument(tracer_provider=my_tracer_provider)
Because this package ships an
opentelemetry_instrumentor entry point,
it is also picked up automatically by opentelemetry-instrument:
opentelemetry-instrument python your_app.py
Producer / consumer example
import asyncio
from absurd_sdk import AsyncAbsurd
from opentelemetry.instrumentation.absurd import AbsurdInstrumentor
AbsurdInstrumentor().instrument()
app = AsyncAbsurd('postgresql://localhost/absurd', queue_name='workflows')
@app.register_task(name='report')
async def report(params, ctx):
# Runs inside a `running:report` SERVER span parented to the spawner.
return {'value': params['value'] * 2}
async def main() -> None:
# Opens a `report` CLIENT span and injects the trace context into the task headers.
await app.spawn('report', {'value': 7}, queue='workflows')
asyncio.run(main())
Span attributes
Both spans carry these attributes (set when available):
| Attribute | Span | Description |
|---|---|---|
absurd.task.name |
CLIENT + SERVER | The registered task name. |
absurd.queue |
CLIENT + SERVER | The queue the task was spawned on. |
absurd.task.id |
CLIENT + SERVER | The task UUID (stringified). |
absurd.run.id |
CLIENT | The run UUID assigned by spawn(). |
absurd.task.attempt |
SERVER | The current attempt number of the run. |
absurd.task.idempotency_key |
CLIENT | Set only when an idempotency key is given. |
The trace context is propagated through the task headers under the
otel.absurd.context key using the globally configured OpenTelemetry propagator (W3C
traceparent by default), so any caller headers you pass are preserved.
How it works
spawn() and the registered handler are wrapped with wrapt.
On spawn() the current context is injected into a fresh carrier nested under a single header
key; the worker extracts that carrier and parents its SERVER span to the spawner's CLIENT
span. If a task was spawned before instrumentation (no carrier present), the handler still runs
in its own SERVER span — it just starts a new trace.
Compatibility
- Python 3.10+
absurd-sdk >= 0.4.0opentelemetry-api >= 1.0
Development
make install # uv sync --all-groups
make test # uv run pytest
make check # ruff check + ruff format --check
AI disclaimer
This code was written with the help of AI.
License
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file opentelemetry_instrumentation_absurd-0.1.0.tar.gz.
File metadata
- Download URL: opentelemetry_instrumentation_absurd-0.1.0.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6c5086707b0c24e1d53c562134504db8fbe8454476ca4ecfb27fe2829a644d3f
|
|
| MD5 |
8a3bab14083e0a08c89787159345a959
|
|
| BLAKE2b-256 |
743484b4ccdb2d00a905b044e4a6acaf25efbd40de314c8b8047a7757979d1b5
|
Provenance
The following attestation bundles were made for opentelemetry_instrumentation_absurd-0.1.0.tar.gz:
Publisher:
release.yml on jirikuncar/opentelemetry-instrumentation-absurd
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
opentelemetry_instrumentation_absurd-0.1.0.tar.gz -
Subject digest:
6c5086707b0c24e1d53c562134504db8fbe8454476ca4ecfb27fe2829a644d3f - Sigstore transparency entry: 2288470080
- Sigstore integration time:
-
Permalink:
jirikuncar/opentelemetry-instrumentation-absurd@d9bfd844d91c2a767c6ea1f69e6ad8666f922b19 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/jirikuncar
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d9bfd844d91c2a767c6ea1f69e6ad8666f922b19 -
Trigger Event:
release
-
Statement type:
File details
Details for the file opentelemetry_instrumentation_absurd-0.1.0-py3-none-any.whl.
File metadata
- Download URL: opentelemetry_instrumentation_absurd-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8df44d213a3e8248a3e7b7ac192936bd43516ddf43d5a0fc4a85b78153652ece
|
|
| MD5 |
8e8030ff575aae5296a2447c75d9bb60
|
|
| BLAKE2b-256 |
9ec7ffd1454d1bd1899061531096c159c9f0509bafcedd78104772de00505d0f
|
Provenance
The following attestation bundles were made for opentelemetry_instrumentation_absurd-0.1.0-py3-none-any.whl:
Publisher:
release.yml on jirikuncar/opentelemetry-instrumentation-absurd
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
opentelemetry_instrumentation_absurd-0.1.0-py3-none-any.whl -
Subject digest:
8df44d213a3e8248a3e7b7ac192936bd43516ddf43d5a0fc4a85b78153652ece - Sigstore transparency entry: 2288470205
- Sigstore integration time:
-
Permalink:
jirikuncar/opentelemetry-instrumentation-absurd@d9bfd844d91c2a767c6ea1f69e6ad8666f922b19 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/jirikuncar
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d9bfd844d91c2a767c6ea1f69e6ad8666f922b19 -
Trigger Event:
release
-
Statement type: