Skip to content

fix(rq): replace removed Job.get_id() with Job.id property#16682

Draft
gferrate wants to merge 4 commits intoDataDog:mainfrom
gferrate:fix/rq-job-get-id-removed
Draft

fix(rq): replace removed Job.get_id() with Job.id property#16682
gferrate wants to merge 4 commits intoDataDog:mainfrom
gferrate:fix/rq-job-get-id-removed

Conversation

@gferrate
Copy link

@gferrate gferrate commented Feb 27, 2026

Overview

Fixes an `AttributeError` in the RQ integration that occurs when using RQ 2.x. The `Job.get_id()` method was removed in RQ 2.0; the integration was calling it in three places when tagging spans with the job ID.

Motivation

RQ 2.0 was released in October 2024 and RQ 2.7.0 (the current latest) was released in February 2026. Any user who has upgraded RQ to 2.x will get an `AttributeError` on every traced job enqueue or execution, breaking their instrumentation entirely.

Change

Replace all three `job.get_id()` calls with `job.id`. The `id` property has been available since RQ 1.8.1 (our minimum supported version) — in 1.x it was literally `id = property(get_id, set_id)`, so this change is fully backwards compatible across the supported range (1.8.1 → 2.7.0).

Also updates `registry.yaml` to reflect the tested max version as 2.7.0.

Tests

  • Added `test_job_id_tag_on_enqueue_span`: explicitly asserts `job.id` tag on the enqueue span matches the job's actual ID.
  • Added `test_job_id_tag_on_worker_spans`: asserts `job.id` on both `rq.worker.perform_job` and `rq.job.perform` spans.
  • Added `test_custom_job_id_in_span_tags`: verifies a user-supplied job ID flows through to all span tags.

The existing snapshot tests ignored `meta.job.id`, so they would not have caught this at the assertion level — only at the `AttributeError` level when running against RQ 2.x.

Risks

  • Low. The change is a drop-in replacement; `job.id` and `job.get_id()` were identical in 1.x. No behaviour change is expected.
  • Potential secondary issue (not in this PR): `test_sync_worker_ttl` calls `job.get_status()` on a job whose Redis data has been deleted (`result_ttl=0`). In RQ 2.x `get_status()` may raise `InvalidJobOperation` instead of returning `None`. This is a test-only issue and does not affect the integration code.

Backport

This is a critical fix for all users on RQ 2.x. Backport to the most recent release branch is recommended.

RQ v2.x removed the standalone `get_id()` method, which causes a
`AttributeError` when the integration is enabled. The `id` property
has been available since v1.8.1 (the minimum supported version) and
is the canonical way to access job IDs across all supported versions.

Updates the tested max version in the registry to reflect v2.7.0
compatibility.
Add explicit assertions that job.id is set correctly on all three
instrumented span types (enqueue, worker.perform_job, job.perform),
including a test with a user-supplied custom job ID.

The existing snapshot tests ignored meta.job.id, so they would not
have caught the job.get_id() removal in RQ 2.x at the assertion level.
RQ 2.0 is the first major version with breaking changes (removed
Job.get_id()). Pin it explicitly alongside 1.8.1 and 1.10.0 so
regressions at the 1.x→2.x boundary are caught independently of
whatever latest resolves to.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant