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

Fix sentry-rails's tracing spans not nesting issue #1784

Merged
merged 5 commits into from
Apr 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
- [Discussion thread and explanation on the decision](https://github.com/rails/rails/pull/43625#issuecomment-1072514175)
- Check if ActiveRecord connection exists before calling AR connection pool [#1769](https://github.com/getsentry/sentry-ruby/pull/1769)
- Fixes [#1745](https://github.com/getsentry/sentry-ruby/issues/1745)
- Fix `sentry-rails`'s tracing spans not nesting issue - [#1784](https://github.com/getsentry/sentry-ruby/pull/1784)
- Fixes [#1723](https://github.com/getsentry/sentry-ruby/issues/1723)
- Update `config.transport.proxy` to allow String and URI values as previously supported by `sentry-ruby` versions <= 4.8 using Faraday
- Fixes [#1782](https://github.com/getsentry/sentry-ruby/issues/1782)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<%= csrf_meta_tags %>
<%= csp_meta_tag %>

<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
<%# <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %1> %>
<%# <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %1> %>
</head>

<body>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class CreatePosts < ActiveRecord::Migration[7.0]
def change
create_table :posts do |t|
t.string :title
t.text :content

t.timestamps
end
end
end
21 changes: 21 additions & 0 deletions sentry-rails/examples/rails-7.0/db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 6 additions & 9 deletions sentry-rails/lib/sentry/rails/tracing/abstract_subscriber.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,12 @@ def subscribe_to_event(event_names)
def record_on_current_span(duration:, **options)
return unless options[:start_timestamp]

scope = Sentry.get_current_scope
transaction = scope.get_transaction
return unless transaction && transaction.sampled

span = transaction.start_child(**options)
# duration in ActiveSupport is computed in millisecond
# so we need to covert it as second before calculating the timestamp
span.set_timestamp(span.start_timestamp + duration / 1000)
yield(span) if block_given?
Sentry.with_child_span(**options) do |child_span|
# duration in ActiveSupport is computed in millisecond
# so we need to covert it as second before calculating the timestamp
child_span.set_timestamp(child_span.start_timestamp + duration / 1000)
yield(child_span) if block_given?
end
end
end
end
Expand Down