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

patch

Open Ayush-developer opened this issue 2 months ago • 0 comments

Thanks for your Pull Request 🎉

Please keep these instructions in mind so we can review it more efficiently:

  • Issue Ref: -
    • https://github.com/getsentry/sentry-ruby/issues/2593#issuecomment-2789569242
    • https://github.com/getsentry/sentry-ruby/issues/2596
  • Whether it's a new feature or a bug fix, make sure they're covered by new test cases
  • If this PR contains any refactoring work, please give it its own commit(s)
  • Finally, please add an entry to the corresponding changelog
  • PR title should use conventional commit style (feat:, fix:, ref:, meta:)

Other Notes

Description

Describe your changes:

This introduces a custom Sentry integration for the concurrent-ruby library, ensuring proper hub and span propagation across background threads created by Concurrent::Promises.future and Concurrent::Promises::Promise.

Key changes:

Added a Sentry::ConcurrentRuby module that patches:

Concurrent::Promises.future

Concurrent::Promises::Future#on_resolution

Automatically propagates the current Sentry hub and active span to background threads.

Wraps each future/promise execution inside Sentry.with_child_span, creating a child span for async tasks.

Sets the child span as the current span for that thread to preserve the correct trace hierarchy.

Removes the need for manually calling Sentry.with_child_span inside individual futures.

Result:

image

Ayush-developer avatar Oct 05 '25 10:10 Ayush-developer