sentry-rails 5.10.0 → 5.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -1
  3. data/Gemfile +36 -31
  4. data/README.md +1 -1
  5. data/Rakefile +13 -10
  6. data/app/jobs/sentry/send_event_job.rb +2 -1
  7. data/bin/console +1 -0
  8. data/lib/generators/sentry_generator.rb +31 -0
  9. data/lib/sentry/rails/action_cable.rb +12 -6
  10. data/lib/sentry/rails/active_job.rb +71 -10
  11. data/lib/sentry/rails/background_worker.rb +2 -0
  12. data/lib/sentry/rails/backtrace_cleaner.rb +7 -7
  13. data/lib/sentry/rails/breadcrumb/active_support_logger.rb +6 -64
  14. data/lib/sentry/rails/breadcrumb/monotonic_active_support_logger.rb +2 -0
  15. data/lib/sentry/rails/capture_exceptions.rb +11 -6
  16. data/lib/sentry/rails/configuration.rb +107 -18
  17. data/lib/sentry/rails/controller_methods.rb +2 -0
  18. data/lib/sentry/rails/controller_transaction.rb +9 -3
  19. data/lib/sentry/rails/engine.rb +2 -0
  20. data/lib/sentry/rails/error_subscriber.rb +9 -1
  21. data/lib/sentry/rails/instrument_payload_cleanup_helper.rb +2 -0
  22. data/lib/sentry/rails/overrides/streaming_reporter.rb +2 -0
  23. data/lib/sentry/rails/railtie.rb +17 -4
  24. data/lib/sentry/rails/rescued_exception_interceptor.rb +12 -1
  25. data/lib/sentry/rails/tracing/abstract_subscriber.rb +2 -1
  26. data/lib/sentry/rails/tracing/action_controller_subscriber.rb +6 -2
  27. data/lib/sentry/rails/tracing/action_view_subscriber.rb +11 -2
  28. data/lib/sentry/rails/tracing/active_record_subscriber.rb +89 -7
  29. data/lib/sentry/rails/tracing/active_storage_subscriber.rb +17 -4
  30. data/lib/sentry/rails/tracing/active_support_subscriber.rb +63 -0
  31. data/lib/sentry/rails/tracing.rb +2 -0
  32. data/lib/sentry/rails/version.rb +3 -1
  33. data/lib/sentry/rails.rb +2 -0
  34. data/lib/sentry-rails.rb +2 -0
  35. data/sentry-rails.gemspec +14 -6
  36. metadata +14 -13
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7eadae379dbfc72a3685f48b7379a52c1fea827eb4c57d1eba6565f87cad406f
4
- data.tar.gz: 81a628792cffda07caed69c4fc5191c77f27da32cfe70226bfac3aeda3951c33
3
+ metadata.gz: 8136167d60f6ee67885cdde939a5aa1e29f0e9f9bc1bd64b0ff4aecc29a477a9
4
+ data.tar.gz: d03846dced0b11fbe03df3b3386c01e2d4ff84d5cfc64dcaf33612f82f2de69a
5
5
  SHA512:
6
- metadata.gz: 0b8575d57dd6be491b3221c40a62864ac183a26274717f122a67d61300f093ff215e38ad182a301db9cc0f57e1d3a257e564bb845aca86429b96574baf901c2a
7
- data.tar.gz: 68e82698caa67fb3d5d7643e86379015dde236ffd38de7a560af0e207d48928643becc8918b7f4aa48cf533c849b4b6f3496f3cc9513f61408545e80e8811212
6
+ metadata.gz: '0900b1dd825499e01d9a5ce77c71bc7821581420abbb60ea8123fcdafed8d7fd9db53b8fb31bdcbbe445e95583c9b477b47f15bdeb58bc3988c54289f328d1bb'
7
+ data.tar.gz: 356eb3d7a526cb1bcd4ee56c3b32201fbbbfe58b0f6ea2cb8152fd7d732964522dea8bc83e08411271fc531c92a5cc9185b2a17dfd50d06153a1ca0f9a6ba87a
data/.gitignore CHANGED
@@ -5,7 +5,7 @@
5
5
  /doc/
6
6
  /pkg/
7
7
  /spec/reports/
8
- /spec/dummy/test_rails_app/db
8
+ /spec/dummy/test_rails_app/db*
9
9
  /tmp/
10
10
 
11
11
  # rspec failure tracking
data/Gemfile CHANGED
@@ -1,57 +1,62 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source "https://rubygems.org"
2
4
  git_source(:github) { |name| "https://github.com/#{name}.git" }
3
5
 
6
+ eval_gemfile "../Gemfile"
7
+
4
8
  # Specify your gem's dependencies in sentry-ruby.gemspec
5
9
  gemspec
6
10
  gem "sentry-ruby", path: "../sentry-ruby"
7
11
 
8
12
  platform :jruby do
9
- gem 'activerecord-jdbcmysql-adapter'
13
+ gem "activerecord-jdbcmysql-adapter"
10
14
  gem "jdbc-sqlite3"
11
15
  end
12
16
 
17
+ ruby_version = Gem::Version.new(RUBY_VERSION)
18
+
13
19
  rails_version = ENV["RAILS_VERSION"]
14
- rails_version = "7.0.0" if rails_version.nil?
20
+ rails_version = "8.0.0" if rails_version.nil?
15
21
  rails_version = Gem::Version.new(rails_version)
16
22
 
17
- if rails_version < Gem::Version.new("6.0.0")
18
- gem "sqlite3", "~> 1.3.0", platform: :ruby
23
+ gem "rails", "~> #{rails_version}"
24
+
25
+ if rails_version >= Gem::Version.new("8.0.0")
26
+ gem "rspec-rails"
27
+ gem "sqlite3", "~> 2.1.1", platform: :ruby
28
+ elsif rails_version >= Gem::Version.new("7.1.0")
29
+ gem "rspec-rails"
30
+ gem "sqlite3", "~> 1.7.3", platform: :ruby
31
+ elsif rails_version >= Gem::Version.new("6.1.0")
32
+ gem "rspec-rails", "~> 4.0"
33
+
34
+ if ruby_version >= Gem::Version.new("2.7.0")
35
+ gem "sqlite3", "~> 1.7.3", platform: :ruby
36
+ else
37
+ gem "sqlite3", "~> 1.6.9", platform: :ruby
38
+ end
19
39
  else
20
- gem "sqlite3", platform: :ruby
40
+ gem "rspec-rails", "~> 4.0"
41
+ gem "psych", "~> 3.0.0"
42
+
43
+ if rails_version >= Gem::Version.new("6.0.0")
44
+ gem "sqlite3", "~> 1.4.0", platform: :ruby
45
+ else
46
+ gem "sqlite3", "~> 1.3.0", platform: :ruby
47
+ end
21
48
  end
22
49
 
23
- if rails_version > Gem::Version.new("7.0.0")
24
- gem "rails", github: "rails/rails"
25
- else
26
- gem "rails", "~> #{rails_version}"
50
+ if ruby_version < Gem::Version.new("2.5.0")
51
+ # https://github.com/flavorjones/loofah/pull/267
52
+ # loofah changed the required ruby version in a patch so we need to explicitly pin it
53
+ gem "loofah", "2.20.0"
27
54
  end
28
55
 
29
56
  gem "mini_magick"
30
57
 
31
58
  gem "sprockets-rails"
32
59
 
33
- gem "sidekiq"
34
-
35
- gem "rspec", "~> 3.0"
36
- gem "rspec-retry"
37
- gem "rspec-rails", "~> 4.0"
38
- gem 'simplecov'
39
- gem "simplecov-cobertura", "~> 1.4"
40
- gem "rexml"
41
-
42
- # https://github.com/flavorjones/loofah/pull/267
43
- # loofah changed the required ruby version in a patch so we need to explicitly pin it
44
- gem "loofah", "2.20.0" if RUBY_VERSION.to_f < 2.5
45
-
46
- gem "rake", "~> 12.0"
47
-
48
- if RUBY_VERSION.to_f >= 2.6
49
- gem "debug", github: "ruby/debug", platform: :ruby
50
- gem "irb"
51
- end
52
-
53
- gem "pry"
54
-
55
60
  gem "benchmark-ips"
56
61
  gem "benchmark_driver"
57
62
  gem "benchmark-ipsa"
data/README.md CHANGED
@@ -11,7 +11,7 @@
11
11
 
12
12
 
13
13
  [![Gem Version](https://img.shields.io/gem/v/sentry-rails.svg)](https://rubygems.org/gems/sentry-rails)
14
- ![Build Status](https://github.com/getsentry/sentry-ruby/workflows/sentry-rails%20Test/badge.svg)
14
+ ![Build Status](https://github.com/getsentry/sentry-ruby/actions/workflows/sentry_rails_test.yml/badge.svg)
15
15
  [![Coverage Status](https://img.shields.io/codecov/c/github/getsentry/sentry-ruby/master?logo=codecov)](https://codecov.io/gh/getsentry/sentry-ruby/branch/master)
16
16
  [![Gem](https://img.shields.io/gem/dt/sentry-rails.svg)](https://rubygems.org/gems/sentry-rails/)
17
17
  [![SemVer](https://api.dependabot.com/badges/compatibility_score?dependency-name=sentry-rails&package-manager=bundler&version-scheme=semver)](https://dependabot.com/compatibility-score.html?dependency-name=sentry-rails&package-manager=bundler&version-scheme=semver)
data/Rakefile CHANGED
@@ -1,14 +1,17 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
4
+ require_relative "../lib/sentry/test/rake_tasks"
3
5
 
4
- RSpec::Core::RakeTask.new(:spec).tap do |task|
5
- task.rspec_opts = "--order rand"
6
- end
6
+ Sentry::Test::RakeTasks.define_spec_tasks(
7
+ spec_pattern: "spec/sentry/**/*_spec.rb",
8
+ spec_rspec_opts: "--order rand --format progress",
9
+ isolated_specs_pattern: "spec/isolated/**/*_spec.rb",
10
+ isolated_rspec_opts: "--format progress"
11
+ )
7
12
 
8
- task :isolated_specs do
9
- Dir["spec/isolated/*"].each do |file|
10
- sh "bundle exec ruby #{file}"
11
- end
12
- end
13
+ Sentry::Test::RakeTasks.define_versioned_specs_task(
14
+ rspec_opts: "--order rand --format progress"
15
+ )
13
16
 
14
- task :default => [:spec, :isolated_specs]
17
+ task default: [:spec, :"spec:versioned", :"spec:isolated"]
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  if defined?(ActiveJob)
2
4
  module Sentry
3
5
  parent_job =
@@ -31,4 +33,3 @@ else
31
33
  class SendEventJob; end
32
34
  end
33
35
  end
34
-
data/bin/console CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require "bundler/setup"
4
5
  require "sentry/ruby"
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails/generators/base"
4
+
5
+ class SentryGenerator < ::Rails::Generators::Base
6
+ class_option :dsn, type: :string, desc: "Sentry DSN"
7
+
8
+ class_option :inject_meta, type: :boolean, default: true, desc: "Inject meta tag into layout"
9
+
10
+ def copy_initializer_file
11
+ dsn = options[:dsn] ? "'#{options[:dsn]}'" : "ENV['SENTRY_DSN']"
12
+
13
+ create_file "config/initializers/sentry.rb", <<~RUBY
14
+ # frozen_string_literal: true
15
+
16
+ Sentry.init do |config|
17
+ config.breadcrumbs_logger = [:active_support_logger]
18
+ config.dsn = #{dsn}
19
+ config.traces_sample_rate = 1.0
20
+ end
21
+ RUBY
22
+ end
23
+
24
+ def inject_code_into_layout
25
+ return unless options[:inject_meta]
26
+
27
+ inject_into_file "app/views/layouts/application.html.erb", before: "</head>\n" do
28
+ " <%= Sentry.get_trace_propagation_meta.html_safe %>\n "
29
+ end
30
+ end
31
+ end
@@ -1,8 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Sentry
2
4
  module Rails
3
5
  module ActionCableExtensions
4
6
  class ErrorHandler
5
- OP_NAME = "websocket.server".freeze
7
+ OP_NAME = "websocket.server"
8
+ SPAN_ORIGIN = "auto.http.rails.actioncable"
6
9
 
7
10
  class << self
8
11
  def capture(connection, transaction_name:, extra_context: nil, &block)
@@ -33,11 +36,14 @@ module Sentry
33
36
  end
34
37
 
35
38
  def start_transaction(env, scope)
36
- sentry_trace = env["HTTP_SENTRY_TRACE"]
37
- baggage = env["HTTP_BAGGAGE"]
38
-
39
- options = { name: scope.transaction_name, source: scope.transaction_source, op: OP_NAME }
40
- transaction = Sentry::Transaction.from_sentry_trace(sentry_trace, baggage: baggage, **options) if sentry_trace
39
+ options = {
40
+ name: scope.transaction_name,
41
+ source: scope.transaction_source,
42
+ op: OP_NAME,
43
+ origin: SPAN_ORIGIN
44
+ }
45
+
46
+ transaction = Sentry.continue_trace(env, **options)
41
47
  Sentry.start_transaction(transaction: transaction, **options)
42
48
  end
43
49
 
@@ -1,3 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "set"
4
+
1
5
  module Sentry
2
6
  module Rails
3
7
  module ActiveJobExtensions
@@ -16,7 +20,12 @@ module Sentry
16
20
  end
17
21
 
18
22
  class SentryReporter
19
- OP_NAME = "queue.active_job".freeze
23
+ OP_NAME = "queue.active_job"
24
+ SPAN_ORIGIN = "auto.queue.active_job"
25
+
26
+ EVENT_HANDLERS = {
27
+ "enqueue_retry.active_job" => :retry_handler
28
+ }
20
29
 
21
30
  class << self
22
31
  def record(job, &block)
@@ -27,7 +36,12 @@ module Sentry
27
36
  if job.is_a?(::Sentry::SendEventJob)
28
37
  nil
29
38
  else
30
- Sentry.start_transaction(name: scope.transaction_name, source: scope.transaction_source, op: OP_NAME)
39
+ Sentry.start_transaction(
40
+ name: scope.transaction_name,
41
+ source: scope.transaction_source,
42
+ op: OP_NAME,
43
+ origin: SPAN_ORIGIN
44
+ )
31
45
  end
32
46
 
33
47
  scope.set_span(transaction) if transaction
@@ -38,19 +52,54 @@ module Sentry
38
52
  rescue Exception => e # rubocop:disable Lint/RescueException
39
53
  finish_sentry_transaction(transaction, 500)
40
54
 
41
- Sentry::Rails.capture_exception(
42
- e,
43
- extra: sentry_context(job),
44
- tags: {
45
- job_id: job.job_id,
46
- provider_job_id: job.provider_job_id
47
- }
48
- )
55
+ capture_exception(job, e)
56
+
49
57
  raise
50
58
  end
51
59
  end
52
60
  end
53
61
 
62
+ def capture_exception(job, e)
63
+ Sentry::Rails.capture_exception(
64
+ e,
65
+ extra: sentry_context(job),
66
+ tags: {
67
+ job_id: job.job_id,
68
+ provider_job_id: job.provider_job_id
69
+ }
70
+ )
71
+ end
72
+
73
+ def register_event_handlers
74
+ EVENT_HANDLERS.each do |name, handler|
75
+ subscribers << ActiveSupport::Notifications.subscribe(name) do |*args|
76
+ public_send(handler, *args)
77
+ end
78
+ end
79
+ end
80
+
81
+ def detach_event_handlers
82
+ subscribers.each do |subscriber|
83
+ ActiveSupport::Notifications.unsubscribe(subscriber)
84
+ end
85
+ subscribers.clear
86
+ end
87
+
88
+ # This handler does not capture error unless `active_job_report_on_retry_error` is true
89
+ def retry_handler(*args)
90
+ handle_error_event(*args) do |job, error|
91
+ return if !Sentry.initialized? || job.already_supported_by_sentry_integration?
92
+ return unless Sentry.configuration.rails.active_job_report_on_retry_error
93
+
94
+ capture_exception(job, error)
95
+ end
96
+ end
97
+
98
+ def handle_error_event(*args)
99
+ event = ActiveSupport::Notifications::Event.new(*args)
100
+ yield(event.payload[:job], event.payload[:error])
101
+ end
102
+
54
103
  def finish_sentry_transaction(transaction, status)
55
104
  return unless transaction
56
105
 
@@ -71,6 +120,12 @@ module Sentry
71
120
 
72
121
  def sentry_serialize_arguments(argument)
73
122
  case argument
123
+ when Range
124
+ if (argument.begin || argument.end).is_a?(ActiveSupport::TimeWithZone)
125
+ argument.to_s
126
+ else
127
+ argument.map { |v| sentry_serialize_arguments(v) }
128
+ end
74
129
  when Hash
75
130
  argument.transform_values { |v| sentry_serialize_arguments(v) }
76
131
  when Array, Enumerable
@@ -81,6 +136,12 @@ module Sentry
81
136
  argument
82
137
  end
83
138
  end
139
+
140
+ private
141
+
142
+ def subscribers
143
+ @__subscribers__ ||= Set.new
144
+ end
84
145
  end
85
146
  end
86
147
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Sentry
2
4
  class BackgroundWorker
3
5
  def _perform(&block)
@@ -1,21 +1,21 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "active_support/backtrace_cleaner"
2
4
  require "active_support/core_ext/string/access"
3
5
 
4
6
  module Sentry
5
7
  module Rails
6
8
  class BacktraceCleaner < ActiveSupport::BacktraceCleaner
7
- APP_DIRS_PATTERN = /\A(?:\.\/)?(?:app|config|lib|test|\(\w*\))/.freeze
8
- RENDER_TEMPLATE_PATTERN = /:in `.*_\w+_{2,3}\d+_\d+'/.freeze
9
+ APP_DIRS_PATTERN = /\A(?:\.\/)?(?:app|config|lib|test|\(\w*\))/
10
+ RENDER_TEMPLATE_PATTERN = /:in (?:`|').*_\w+_{2,3}\d+_\d+'/
9
11
 
10
12
  def initialize
11
13
  super
12
- # we don't want any default silencers because they're too aggressive
14
+ # We don't want any default silencers because they're too aggressive
13
15
  remove_silencers!
16
+ # We don't want any default filters because Rails 7.2 starts shortening the paths. See #2472
17
+ remove_filters!
14
18
 
15
- @root = "#{Sentry.configuration.project_root}/"
16
- add_filter do |line|
17
- line.start_with?(@root) ? line.from(@root.size) : line
18
- end
19
19
  add_filter do |line|
20
20
  if line =~ RENDER_TEMPLATE_PATTERN
21
21
  line.sub(RENDER_TEMPLATE_PATTERN, "")
@@ -1,76 +1,16 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Sentry
2
4
  module Rails
3
5
  module Breadcrumb
4
6
  module ActiveSupportLogger
5
- ALLOWED_LIST = {
6
- # action_controller
7
- "write_fragment.action_controller" => %i[key],
8
- "read_fragment.action_controller" => %i[key],
9
- "exist_fragment?.action_controller" => %i[key],
10
- "expire_fragment.action_controller" => %i[key],
11
- "start_processing.action_controller" => %i[controller action params format method path],
12
- "process_action.action_controller" => %i[controller action params format method path status view_runtime db_runtime],
13
- "send_file.action_controller" => %i[path],
14
- "redirect_to.action_controller" => %i[status location],
15
- "halted_callback.action_controller" => %i[filter],
16
- # action_dispatch
17
- "process_middleware.action_dispatch" => %i[middleware],
18
- # action_view
19
- "render_template.action_view" => %i[identifier layout],
20
- "render_partial.action_view" => %i[identifier],
21
- "render_collection.action_view" => %i[identifier count cache_hits],
22
- "render_layout.action_view" => %i[identifier],
23
- # active_record
24
- "sql.active_record" => %i[sql name statement_name cached],
25
- "instantiation.active_record" => %i[record_count class_name],
26
- # action_mailer
27
- # not including to, from, or subject..etc. because of PII concern
28
- "deliver.action_mailer" => %i[mailer date perform_deliveries],
29
- "process.action_mailer" => %i[mailer action params],
30
- # active_support
31
- "cache_read.active_support" => %i[key store hit],
32
- "cache_generate.active_support" => %i[key store],
33
- "cache_fetch_hit.active_support" => %i[key store],
34
- "cache_write.active_support" => %i[key store],
35
- "cache_delete.active_support" => %i[key store],
36
- "cache_exist?.active_support" => %i[key store],
37
- # active_job
38
- "enqueue_at.active_job" => %i[],
39
- "enqueue.active_job" => %i[],
40
- "enqueue_retry.active_job" => %i[],
41
- "perform_start.active_job" => %i[],
42
- "perform.active_job" => %i[],
43
- "retry_stopped.active_job" => %i[],
44
- "discard.active_job" => %i[],
45
- # action_cable
46
- "perform_action.action_cable" => %i[channel_class action],
47
- "transmit.action_cable" => %i[channel_class],
48
- "transmit_subscription_confirmation.action_cable" => %i[channel_class],
49
- "transmit_subscription_rejection.action_cable" => %i[channel_class],
50
- "broadcast.action_cable" => %i[broadcasting],
51
- # active_storage
52
- "service_upload.active_storage" => %i[service key checksum],
53
- "service_streaming_download.active_storage" => %i[service key],
54
- "service_download_chunk.active_storage" => %i[service key],
55
- "service_download.active_storage" => %i[service key],
56
- "service_delete.active_storage" => %i[service key],
57
- "service_delete_prefixed.active_storage" => %i[service prefix],
58
- "service_exist.active_storage" => %i[service key exist],
59
- "service_url.active_storage" => %i[service key url],
60
- "service_update_metadata.active_storage" => %i[service key],
61
- "preview.active_storage" => %i[key],
62
- "analyze.active_storage" => %i[analyzer],
63
- }.freeze
64
-
65
7
  class << self
66
8
  def add(name, started, _finished, _unique_id, data)
67
9
  # skip Rails' internal events
68
10
  return if name.start_with?("!")
69
11
 
70
- allowed_keys = ALLOWED_LIST[name]
71
-
72
12
  if data.is_a?(Hash)
73
- data = data.slice(*allowed_keys)
13
+ data = data.slice(*@allowed_keys[name])
74
14
  end
75
15
 
76
16
  crumb = Sentry::Breadcrumb.new(
@@ -81,7 +21,9 @@ module Sentry
81
21
  Sentry.add_breadcrumb(crumb)
82
22
  end
83
23
 
84
- def inject
24
+ def inject(allowed_keys)
25
+ @allowed_keys = allowed_keys
26
+
85
27
  @subscriber = ::ActiveSupport::Notifications.subscribe(/.*/) do |name, started, finished, unique_id, data|
86
28
  # we only record events that has a started timestamp
87
29
  if started.is_a?(Time)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "sentry/rails/instrument_payload_cleanup_helper"
2
4
 
3
5
  module Sentry
@@ -1,7 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Sentry
2
4
  module Rails
3
5
  class CaptureExceptions < Sentry::Rack::CaptureExceptions
4
6
  RAILS_7_1 = Gem::Version.new(::Rails.version) >= Gem::Version.new("7.1.0.alpha")
7
+ SPAN_ORIGIN = "auto.http.rails"
5
8
 
6
9
  def initialize(_)
7
10
  super
@@ -19,7 +22,7 @@ module Sentry
19
22
  end
20
23
 
21
24
  def transaction_op
22
- "http.server".freeze
25
+ "http.server"
23
26
  end
24
27
 
25
28
  def capture_exception(exception, env)
@@ -32,16 +35,18 @@ module Sentry
32
35
  end
33
36
 
34
37
  def start_transaction(env, scope)
35
- sentry_trace = env["HTTP_SENTRY_TRACE"]
36
- baggage = env["HTTP_BAGGAGE"]
37
-
38
- options = { name: scope.transaction_name, source: scope.transaction_source, op: transaction_op }
38
+ options = {
39
+ name: scope.transaction_name,
40
+ source: scope.transaction_source,
41
+ op: transaction_op,
42
+ origin: SPAN_ORIGIN
43
+ }
39
44
 
40
45
  if @assets_regexp && scope.transaction_name.match?(@assets_regexp)
41
46
  options.merge!(sampled: false)
42
47
  end
43
48
 
44
- transaction = Sentry::Transaction.from_sentry_trace(sentry_trace, baggage: baggage, **options) if sentry_trace
49
+ transaction = Sentry.continue_trace(env, **options)
45
50
  Sentry.start_transaction(transaction: transaction, custom_sampling_context: { env: env }, **options)
46
51
  end
47
52