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

Backport "[PROF-9650] Enable endpoint profiling for Sidekiq and similar background job processors" to 1.x-stable #3619

Merged
merged 2 commits into from
May 7, 2024

Conversation

ivoanjo
Copy link
Member

@ivoanjo ivoanjo commented May 1, 2024

What does this PR do?

This PR backports #3610 to the 1.x-stable branch. See original PR for more details.

Motivation:

We want to release this profiling feature in the 1.x-stable series as well.

Additional Notes:

I cherry-picked the upstream commits with no other changes.

How to test the change?

See original PR for details.

This simplifies a bit the `trace_identifiers_for` and centralizes the
logic for collecting or not the resource.
…und job processors

**What does this PR do?**

We have an opt-in list for which kinds of traces we collect the
resource from; this PR extends that list with the `worker` type
used by background consumers such as Sidekiq.

**Motivation:**

Enable profiling for Sidekiq and similar background job processors.

**Additional Notes:**

We also collect a few Sidekiq internal things (such as
`sidekiq.job_fetch`, `sidekiq.scheduled_poller_wait`,
`sidekiq.scheduled_push`, `sidekiq.stop` and `sidekiq.heartbeat`).

We discussed if it would make sense to hide them or not, but for now
we decided to still show them.

**How to test the change?**

This change includes test coverage; I also booted up sidekiq and tested
manually using the following script:

```ruby
 # Running redis:
 # * `docker-compose up redis`
 # Running server:
 # * `DD_SERVICE=sidekiq-testing DD_ENV=staging DD_PROFILING_ENABLED=true bundle exec sidekiq -r ./sidekiq.rb`
 # Running client:
 # * `DD_TRACE_ENABLED=false DD_TRACING_ENABLED=false be ddprofrb exec irb -r ./sidekiq.rb`
 # * `ThisIsASidekiqJob.perform_async("hello", 10)`

require "sidekiq"
require 'datadog'

Datadog.configure { |c| c.tracing.instrument :sidekiq }

class ThisIsASidekiqJob
  include Sidekiq::Job

  def perform(some_arg = "potato", how_long = 1)
    puts "Start of job!"
    sleep how_long
    puts "End of job!"
  end
end
```
@ivoanjo ivoanjo requested a review from a team as a code owner May 1, 2024 14:41
@ivoanjo ivoanjo added this to the 1.23.0 milestone May 1, 2024
@github-actions github-actions bot added the profiling Involves Datadog profiling label May 1, 2024
@ivoanjo ivoanjo requested review from a team and removed request for a team May 1, 2024 14:42
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.25%. Comparing base (09ba2b0) to head (88679cc).
Report is 1 commits behind head on 1.x-stable.

Additional details and impacted files
@@             Coverage Diff             @@
##           1.x-stable    #3619   +/-   ##
===========================================
  Coverage       98.24%   98.25%           
===========================================
  Files            1255     1255           
  Lines           74569    74572    +3     
  Branches         3540     3540           
===========================================
+ Hits            73262    73267    +5     
+ Misses           1307     1305    -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ivoanjo ivoanjo merged commit a592744 into 1.x-stable May 7, 2024
195 checks passed
@ivoanjo ivoanjo deleted the ivoanjo/backport-pr3610 branch May 7, 2024 10:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
profiling Involves Datadog profiling
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants