Skip to content

feat(active_job): add spans and events for Continuation#2361

Open
bdewater-thatch wants to merge 5 commits into
open-telemetry:mainfrom
thatch-health:activejob-steps
Open

feat(active_job): add spans and events for Continuation#2361
bdewater-thatch wants to merge 5 commits into
open-telemetry:mainfrom
thatch-health:activejob-steps

Conversation

@bdewater-thatch
Copy link
Copy Markdown
Contributor

Rails 8.1 added Active Job Continuation for interruptible and resumable jobs. This PR adds instrumentation for the events emitted when the step DSL is used: https://edgeguides.rubyonrails.org/active_support_instrumentation.html#active-job

Add tracing support for Rails 8.1 Active Job Continuation steps.
Each step in a continuable job gets its own child span under the
perform span, with attributes for step name, cursor, resumed, and
interrupted state.
Record a span event on the perform (ingress) span when a continuable
job resumes from a previous execution, with attributes for resumption
count, description, and completed steps.
…tion

Record a span event on the perform span when a previously completed
step is skipped during a resumed continuable job execution, including
the step name as an attribute.
Record a span event on the current span when a continuable job is
interrupted, with attributes for the interrupt reason, description,
and completed steps.

attributes = {
'messaging.active_job.continuation.reason' => payload[:reason].to_s,
'messaging.active_job.continuation.description' => payload[:description]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
'messaging.active_job.continuation.description' => payload[:description]
'rails.active_job.continuation.description' => payload[:description]


attributes = @mapper.call(payload).merge(
'messaging.active_job.step.name' => step_name,
'messaging.active_job.step.resumed' => step.resumed?
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
'messaging.active_job.step.resumed' => step.resumed?
'rails.active_job.step.resumed' => step.resumed?

Perhaps even

Suggested change
'messaging.active_job.step.resumed' => step.resumed?
'rails.active_job.step.state' => step.resumed? 'resumed' : 'started'

Ideally we would either use rails.active_job.continuation.resumptions so that it can be connected or drop the attribute and use just the event. I think the first option would be better.

Copy link
Copy Markdown
Contributor Author

@bdewater-thatch bdewater-thatch May 22, 2026

Choose a reason for hiding this comment

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

Not entirely following this one - are you suggesting to keep state and add resumptions, or replace the former by the latter? Resumptions are counted at the job level, not the step level.

Copy link
Copy Markdown
Contributor

@thompson-tomo thompson-tomo left a comment

Choose a reason for hiding this comment

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

Telemetry definition LGTM, thanks for making the changes. Will like for someone else to have another review of especially the coding patterns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants