From 600599d5c8a52e8d7e215685ace37458c590a782 Mon Sep 17 00:00:00 2001 From: Neel Shah Date: Wed, 16 Aug 2023 13:19:17 +0200 Subject: [PATCH] Use continue_trace in sentry-rails --- CHANGELOG.md | 3 ++- sentry-rails/lib/sentry/rails/action_cable.rb | 5 +---- sentry-rails/lib/sentry/rails/capture_exceptions.rb | 5 +---- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ccc9825e6..6a5a10329 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,8 @@ config.trace_propagation_targets = [/example.com/, 'foobar.org/api/v2'] ``` - Tracing without Performance - - Implement `PropagationContext` on `Scope` and add `Sentry.get_trace_propagation_headers` API [#2084](https://github.com/getsentry/sentry-ruby/pull/2084) + - Implement `PropagationContext` on `Scope` and add new `Sentry.get_trace_propagation_headers` API [#2084](https://github.com/getsentry/sentry-ruby/pull/2084) + - Add new `Sentry.continue_trace` API [#2089](https://github.com/getsentry/sentry-ruby/pull/2089) The SDK now supports connecting arbitrary events (Errors / Transactions / Replays) across distributed services and not just Transactions. To continue an incoming trace starting with this version of the SDK, use `Sentry.continue_trace` as follows. diff --git a/sentry-rails/lib/sentry/rails/action_cable.rb b/sentry-rails/lib/sentry/rails/action_cable.rb index 5bf01f5da..155377466 100644 --- a/sentry-rails/lib/sentry/rails/action_cable.rb +++ b/sentry-rails/lib/sentry/rails/action_cable.rb @@ -33,11 +33,8 @@ def capture(connection, transaction_name:, extra_context: nil, &block) end def start_transaction(env, scope) - sentry_trace = env["HTTP_SENTRY_TRACE"] - baggage = env["HTTP_BAGGAGE"] - options = { name: scope.transaction_name, source: scope.transaction_source, op: OP_NAME } - transaction = Sentry::Transaction.from_sentry_trace(sentry_trace, baggage: baggage, **options) if sentry_trace + transaction = Sentry.continue_trace(env, **options) Sentry.start_transaction(transaction: transaction, **options) end diff --git a/sentry-rails/lib/sentry/rails/capture_exceptions.rb b/sentry-rails/lib/sentry/rails/capture_exceptions.rb index a145d53dd..8d93784ed 100644 --- a/sentry-rails/lib/sentry/rails/capture_exceptions.rb +++ b/sentry-rails/lib/sentry/rails/capture_exceptions.rb @@ -32,16 +32,13 @@ def capture_exception(exception, env) end def start_transaction(env, scope) - sentry_trace = env["HTTP_SENTRY_TRACE"] - baggage = env["HTTP_BAGGAGE"] - options = { name: scope.transaction_name, source: scope.transaction_source, op: transaction_op } if @assets_regexp && scope.transaction_name.match?(@assets_regexp) options.merge!(sampled: false) end - transaction = Sentry::Transaction.from_sentry_trace(sentry_trace, baggage: baggage, **options) if sentry_trace + transaction = Sentry.continue_trace(env, **options) Sentry.start_transaction(transaction: transaction, custom_sampling_context: { env: env }, **options) end