Skip to content

Commit

Permalink
Use Sentry.with_child_span in the tracing subscribers
Browse files Browse the repository at this point in the history
  • Loading branch information
st0012 committed Apr 4, 2022
1 parent 91122fa commit fb9d3ab
Showing 1 changed file with 6 additions and 9 deletions.
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

0 comments on commit fb9d3ab

Please sign in to comment.