sentry-ruby icon indicating copy to clipboard operation
sentry-ruby copied to clipboard

Add child_spans for Sidekiq Queue instrumentation

Open frederikspang opened this issue 1 year ago • 5 comments

Implements #2322 for Sidekiq.

Description

Adds support for Sentry Queues page (With predefined span op names)

https://docs.sentry.io/platforms/ruby/guides/sidekiq/tracing/instrumentation/custom-instrumentation/queues-module/

Screenshot 2024-09-16 at 15 45 15

frederikspang avatar Sep 16 '24 13:09 frederikspang

Oh wow, exactly what I was looking for 😅 🙌

can we somehow help to get this shipped? 💪

rwojsznis avatar Oct 02 '24 10:10 rwojsznis

@solnic I've added two basic specs. Latency is a bit difficult, without introducing some timecop kind of tool. Which we do have in sentry-ruby, so we could just introduce it here if we wanted to.

frederikspang avatar Oct 17 '24 11:10 frederikspang

@solnic After looking at these, I think queue.process may actually replace op: queue.sidekiq instead of being a child span. They will always be redundant - But we should set origin or some other field to sidekiq, description or name maybe, to differentiate the processor. (ie. using another processor alongside Sidekiq - or doing queries in Sentry UI across applications)

image

frederikspang avatar Oct 17 '24 18:10 frederikspang

Looks like it needs a changelog too

nateberkopec avatar Oct 21 '24 01:10 nateberkopec

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 98.16%. Comparing base (27d7384) to head (5e000c6). Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2403   +/-   ##
=======================================
  Coverage   98.15%   98.16%           
=======================================
  Files         126      126           
  Lines        4728     4741   +13     
=======================================
+ Hits         4641     4654   +13     
  Misses         87       87           
Components Coverage Δ
sentry-ruby 98.51% <ø> (ø)
sentry-rails 97.05% <ø> (ø)
sentry-sidekiq 97.63% <100.00%> (+0.15%) :arrow_up:
sentry-resque 92.85% <ø> (ø)
sentry-delayed_job 95.65% <ø> (ø)
sentry-opentelemetry 99.31% <ø> (ø)
Files with missing lines Coverage Δ
...iq/lib/sentry/sidekiq/sentry_context_middleware.rb 98.21% <100.00%> (+0.53%) :arrow_up:

codecov[bot] avatar Oct 21 '24 20:10 codecov[bot]

@solnic After looking at these, I think queue.process may actually replace op: queue.sidekiq instead of being a child span. They will always be redundant

  • But we should set origin or some other field to sidekiq, description or name maybe, to differentiate the processor. (ie. using another processor alongside Sidekiq - or doing queries in Sentry UI across applications)

I've been testing this out and I don't see queue.sidekiq/queue.process. This is what I see instead:

Screenshot 2024-10-25 at 14 51 35

solnic avatar Oct 25 '24 13:10 solnic

Latency is a bit difficult, without introducing some timecop kind of tool. Which we do have in sentry-ruby, so we could just introduce it here if we wanted to.

Thanks for adding the specs. I think it would be good to use timecop there actually.

solnic avatar Oct 25 '24 13:10 solnic

@solnic After looking at these, I think queue.process may actually replace op: queue.sidekiq instead of being a child span. They will always be redundant

  • But we should set origin or some other field to sidekiq, description or name maybe, to differentiate the processor. (ie. using another processor alongside Sidekiq - or doing queries in Sentry UI across applications)

I've been testing this out and I don't see queue.sidekiq/queue.process. This is what I see instead:

Screenshot 2024-10-25 at 14 51 35

You're right! I changed that after my comment, before your review here:

https://github.com/getsentry/sentry-ruby/pull/2403/commits/cd3a1df20eb357498f91bf4217c1667e4d4839aa

I'll have a look at the other comments as soon as possible.

frederikspang avatar Oct 25 '24 13:10 frederikspang

@solnic I have updated PR with feedback adjusted!

Edit: I see specs are broken. I'll look into that as well!

frederikspang avatar Oct 27 '24 12:10 frederikspang

@solnic The specs failing seems related to https://github.com/sidekiq/sidekiq/pull/6430 - Was able to reproduce locally, after clearing Lock file and bundle install again.

Somewhat unrelated to this PR, although it's noisy.

frederikspang avatar Oct 28 '24 09:10 frederikspang

@solnic The specs failing seems related to sidekiq/sidekiq#6430 - Was able to reproduce locally, after clearing Lock file and bundle install again.

Somewhat unrelated to this PR, although it's noisy.

Please update to the latest master. I just checked locally and it passes. Once CI is green I'll merge it in.

solnic avatar Oct 28 '24 16:10 solnic

@solnic Done!

frederikspang avatar Oct 28 '24 22:10 frederikspang

🙌 Thanks everyone! This is such a great feature.

nateberkopec avatar Oct 31 '24 00:10 nateberkopec