Skip to content

Conversation

agrobbin
Copy link
Contributor

What does this PR do?
Instead of using around_perform, we now do the same thing that Active Job itself does to tag logs with [ActiveJob], the job class name, and job ID, which is wrapping perform_now.

Motivation:
The current Active Job integration injects a log correlation tag into the logger via around_perform, which is too late to pick up the following logs:

[ActiveJob] [FooJob] [540c4718-6668-4f3c-9411-ca52a4cffd15] Performing FooJob (Job ID: 540c4718-6668-4f3c-9411-ca52a4cffd15) from Sidekiq(default) enqueued at 2025-09-26T02:17:44.160363327Z with arguments: #<GlobalID:0x00007f0fae88cb50 @uri=#<URI::GID gid://foo-rails/Foo/019983cf-8422-72d5-85b7-f3dc09a4887e>>
[ActiveJob] [FooJob] [540c4718-6668-4f3c-9411-ca52a4cffd15] Performed FooJob (Job ID: 540c4718-6668-4f3c-9411-ca52a4cffd15) from Sidekiq(default) in 990.29ms

Change log entry

Additional Notes:

How to test the change?
I looked for an existing test to exercise this, but was unable to find one, and didn't see any tests specifically related to Active Job itself.

The current Active Job integration injects a log correlation tag into the logger via `around_perform`, which is too late to pick up the following logs:

```
[ActiveJob] [FooJob] [540c4718-6668-4f3c-9411-ca52a4cffd15] Performing FooJob (Job ID: 540c4718-6668-4f3c-9411-ca52a4cffd15) from Sidekiq(default) enqueued at 2025-09-26T02:17:44.160363327Z with arguments: #<GlobalID:0x00007f0fae88cb50 @uri=#<URI::GID gid://foo-rails/Foo/019983cf-8422-72d5-85b7-f3dc09a4887e>>
[ActiveJob] [FooJob] [540c4718-6668-4f3c-9411-ca52a4cffd15] Performed FooJob (Job ID: 540c4718-6668-4f3c-9411-ca52a4cffd15) from Sidekiq(default) in 990.29ms
```

Instead of using `around_perform`, we now do the same thing that [Active Job itself](https://github.com/rails/rails/blob/v8.0.3/activejob/lib/active_job/logging.rb#L31-L33) does to tag logs with `[ActiveJob]`, the job class name, and job ID, which is wrapping `perform_now`.
@agrobbin agrobbin requested review from a team as code owners September 26, 2025 02:31
@agrobbin agrobbin requested a review from vpellan September 26, 2025 02:31
@github-actions github-actions bot added integrations Involves tracing integrations tracing labels Sep 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrations Involves tracing integrations tracing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant