Skip to content
2 changes: 1 addition & 1 deletion ddtrace/contrib/integration_registry/registry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ integrations:
tested_versions_by_dependency:
rq:
min: 1.8.1
max: 1.16.2
max: 2.7.0

- integration_name: sanic
is_external_package: true
Expand Down
6 changes: 3 additions & 3 deletions ddtrace/contrib/internal/rq/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def traced_queue_enqueue_job(rq, pin, func, instance, args, kwargs):
COMPONENT: config.rq.integration_name,
SPAN_KIND: SpanKind.PRODUCER,
QUEUE_NAME: instance.name,
JOB_ID: job.get_id(),
JOB_ID: job.id,
JOB_FUNC_NAME: job.func_name,
},
) as ctx,
Expand Down Expand Up @@ -122,7 +122,7 @@ def traced_perform_job(rq, pin, func, instance, args, kwargs):
integration_config=config.rq_worker,
distributed_headers=job.meta,
activate_distributed_headers=True,
tags={COMPONENT: config.rq.integration_name, SPAN_KIND: SpanKind.CONSUMER, JOB_ID: job.get_id()},
tags={COMPONENT: config.rq.integration_name, SPAN_KIND: SpanKind.CONSUMER, JOB_ID: job.id},
) as ctx,
ctx.span,
):
Expand Down Expand Up @@ -154,7 +154,7 @@ def traced_job_perform(rq, pin, func, instance, args, kwargs):
span_name="rq.job.perform",
resource=job.func_name,
pin=pin,
tags={COMPONENT: config.rq.integration_name, JOB_ID: job.get_id()},
tags={COMPONENT: config.rq.integration_name, JOB_ID: job.id},
) as ctx,
ctx.span,
):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
fixes:
- |
rq: Fixes an ``AttributeError`` caused by ``Job.get_id()`` being removed in
`RQ 2.0 <https://github.com/rq/rq/releases/tag/v2.0>`_. The integration now
uses the ``job.id`` property, which has been available since RQ 1.8.1 and is
the canonical way to access a job's identifier across all supported versions. #16682
1 change: 1 addition & 0 deletions riotfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2164,6 +2164,7 @@ def select_pys(min_version: str = MIN_PYTHON_VERSION, max_version: str = MAX_PYT
"rq": [
"~=1.8.1",
"~=1.10.0",
"~=2.0.0", # first major version; removed Job.get_id() in favour of job.id property
latest,
],
# https://github.com/rq/rq/issues/1469 rq [1.0,1.8] is incompatible with click 8.0+
Expand Down
6 changes: 6 additions & 0 deletions tests/contrib/rq/test_rq.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ def test_worker_class_job(queue):
worker.work(burst=True)


@snapshot(ignores=[i for i in snapshot_ignores if i != "meta.job.id"])
def test_custom_job_id_in_span_tags(sync_queue):
"""Verify a user-supplied job ID is propagated correctly to all span tags."""
sync_queue.enqueue(job_add1, 1, job_id="my-custom-job-id")


@pytest.mark.parametrize("distributed_tracing_enabled", [False, None])
@pytest.mark.parametrize("worker_service_name", [None, "custom-worker-service"])
def test_enqueue(queue, distributed_tracing_enabled, worker_service_name):
Expand Down
Loading