Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: Datadog APM Not Propagating Traces for Sidekiq Pro Batch Callbacks #4485

Open
sundars1995 opened this issue Mar 12, 2025 · 0 comments
Labels
bug Involves a bug community Was opened by a community member

Comments

@sundars1995
Copy link

sundars1995 commented Mar 12, 2025

Tracer Version(s)

2.12.1

Ruby Version(s)

ruby 3.1.6p260 (2024-05-29 revision a777087be6) [arm64-darwin24]

Relevent Library and Version(s)

sidekiq 6.0, sidekiq pro

Bug Report

We are integrating Datadog APM tracing into our Rails application, which makes heavy use of Sidekiq Pro batch jobs. The default Sidekiq tracing instrumentation works well for most jobs, but we are encountering issues with tracing Sidekiq Pro batch callbacks (on_successon_complete).

Observed Issue

  • When a Sidekiq batch completes, its callbacks (such as on_success and on_complete) are treated as separate traces rather than being linked to the parent trace.

  • This is especially problematic because our batch jobs have deep nesting, where callbacks can create new batches and trigger further callbacks.

  • The result is that the entire process is fragmented into multiple traces, making it difficult to correlate jobs under a single trace.

Expected Behavior

  • The callback jobs should inherit and propagate the parent batch trace, ensuring all related jobs are under a single distributed trace.

Reproduction Code

Reproduction Workflow

  1. parent job creates a Sidekiq Pro batch job.

  2. The batch job enqueues multiple nested jobs.

  3. Upon batch completion, an **on_complete** callback is triggered.

  4. This callback schedules another batch job, which follows the same pattern.

  5. Each batch's callback job is treated as a new trace, breaking the trace propagation.

Parent Job
   ├── Batch 1
   │      ├── Nested Job A
   │      ├── Nested Job B
   │      └── (on_complete Callback → Creates Batch 2)
   │
   ├── Batch 2
   │      ├── Nested Job C
   │      ├── Nested Job D
   │      └── (on_complete Callback → Creates Batch 3)
   │
   ├── Batch 3
   │      ├── Nested Job E
   │      ├── Nested Job F
   │      └── (on_complete Callback → ...)
   └── (on_complete Callback -> )

Configuration Block

Datadog.configure do |c|
  c.tracing.instrument :sidekiq, distributed_tracing: true
end

Error Logs

No response

Operating System

No response

How does Datadog help you?

Our company currently uses datadog extensively for logging and we are instrumenting APM traces along with RUM for distributed tracing for all our applications.

@sundars1995 sundars1995 added bug Involves a bug community Was opened by a community member labels Mar 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Involves a bug community Was opened by a community member
Projects
None yet
Development

No branches or pull requests

1 participant