Skip to content

Record the Delayed Job enqueue as a producer span - #1538

Merged
unflxw merged 2 commits into
wip-otel-reworkfrom
delayed-job-collector-mode
Jul 16, 2026
Merged

Record the Delayed Job enqueue as a producer span#1538
unflxw merged 2 commits into
wip-otel-reworkfrom
delayed-job-collector-mode

Conversation

@unflxw

@unflxw unflxw commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Builds on #1537. This branch is cut from #1535 and cherry-picks that PR's commit, so the collector-mode change can be reviewed against the OpenTelemetry branch here. Once #1537 merges to main and wip-otel-rework is rebased on top of it, the first commit drops out and only the second remains.

Delayed Job is the one background-job backend with no metadata envelope to carry trace context: its payload is a YAML dump of the user's own object, so linking the enqueue to the perform would mean mutating that object and re-serialising it. OpenTelemetry's own Delayed Job instrumentation reaches the same conclusion, so we match it — a PRODUCER span on enqueue and a CONSUMER span on perform, no wire propagation, and the two are not linked. Active Job over Delayed Job still links, through the Active Job __otel_headers layer.

Both commits are tested against Delayed Job's own in-memory test backend (under the new delayed_job gemfile), driving the real enqueue and perform lifecycle in agent and collector mode.

Record the Delayed Job enqueue as a producer span

In collector mode the enqueue.delayed_job event now opens a producer
span, matching the other job backends and OpenTelemetry's own Delayed
Job instrumentation. Delayed Job has no envelope to carry trace context
across the enqueue/perform boundary, so -- like OpenTelemetry -- nothing
is injected and the producer and consumer spans are not linked.

Dual-modes the Delayed Job specs so the collector-mode span shapes are
covered alongside the agent-mode ones.

@backlog-helper

backlog-helper Bot commented Jul 9, 2026

Copy link
Copy Markdown

✔️ All good!

New issue guide | Backlog management | Rules | Feedback

@unflxw unflxw closed this Jul 9, 2026
@unflxw unflxw reopened this Jul 9, 2026
@unflxw
unflxw force-pushed the delayed-job-collector-mode branch 2 times, most recently from ca5860d to a91de42 Compare July 9, 2026 17:29
Enqueuing a Delayed Job now records an `enqueue.delayed_job` event on
the active transaction, so enqueues made from a web request or another
job show up in the event timeline. Delayed Job was the only background
job backend still missing this.

Test it against Delayed Job's in-memory test backend under a new
`delayed_job` gemfile, driving the real enqueue and perform lifecycle
rather than a stubbed one.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds Delayed Job enqueue instrumentation to AppSignal, including collector-mode OpenTelemetry semantics by recording the enqueue as a PRODUCER span (without trace-context propagation, matching OTel’s Delayed Job approach). This closes the gap where Delayed Job previously lacked enqueue timeline visibility compared to other job backends.

Changes:

  • Add around(:enqueue) instrumentation in DelayedJobPlugin to record enqueue.delayed_job with :opentelemetry_kind => :producer.
  • Replace the Delayed Job integration spec with end-to-end coverage using Delayed Job’s in-memory test backend, covering agent + collector modes.
  • Add delayed_job gemfiles and CI/build-matrix entries to run the new integration specs.

Reviewed changes

Copilot reviewed 8 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
spec/support/stubs/delayed_job.rb (Content not provided in prompt) Delayed Job test stubs/support adjustments.
spec/support/helpers/dependency_helper.rb Add delayed_job_present? to gate specs on bundle contents.
spec/lib/appsignal/integrations/delayed_job_plugin_spec.rb New end-to-end Delayed Job enqueue/perform specs (agent + collector).
spec/lib/appsignal/hooks/delayed_job_spec.rb Make hook installation deterministic by installing directly and hiding constants in the “without” case.
lib/appsignal/integrations/delayed_job_plugin.rb Record enqueue.delayed_job and mark it as a producer span in collector mode.
gemfiles/delayed_job.gemfile New gemfile to run Delayed Job integration tests.
gemfiles/delayed_job-collector.gemfile Generated collector overlay gemfile for Delayed Job.
build_matrix.yml Add delayed_job gemfile variant to the build matrix.
.github/workflows/ci.yml Generated CI workflow updates to include delayed_job jobs.
.changesets/add-delayed-job-enqueue-instrumentation.md Changeset documenting the new enqueue instrumentation (minor bump).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread spec/lib/appsignal/integrations/delayed_job_plugin_spec.rb Outdated
@tombruijn tombruijn added the enhancement An improvement to an existing feature. label Jul 10, 2026
In collector mode the `enqueue.delayed_job` event now opens a producer
span, matching the other job backends and OpenTelemetry's own Delayed
Job instrumentation. Delayed Job has no envelope to carry trace context
across the enqueue/perform boundary, so -- like OpenTelemetry -- nothing
is injected and the producer and consumer spans are not linked.

Dual-modes the Delayed Job specs so the collector-mode span shapes are
covered alongside the agent-mode ones.
@unflxw
unflxw force-pushed the delayed-job-collector-mode branch from 13eba8d to a84a4a2 Compare July 10, 2026 06:47
@backlog-helper

This comment has been minimized.

@unflxw
unflxw force-pushed the wip-otel-rework branch 2 times, most recently from 31d2771 to c220cce Compare July 13, 2026 12:41
@backlog-helper

This comment has been minimized.

1 similar comment
@backlog-helper

This comment has been minimized.

@backlog-helper

Copy link
Copy Markdown

This is a message from the daily scheduled checks.

New issue guide | Backlog management | Rules | Feedback

@unflxw
unflxw merged commit b260823 into wip-otel-rework Jul 16, 2026
420 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement An improvement to an existing feature.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants