sentry-rails 4.7.2 → 4.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +12 -4
- data/app/jobs/sentry/send_event_job.rb +2 -2
- data/lib/sentry/rails/action_cable.rb +96 -0
- data/lib/sentry/rails/active_job.rb +28 -38
- data/lib/sentry/rails/background_worker.rb +4 -6
- data/lib/sentry/rails/configuration.rb +3 -1
- data/lib/sentry/rails/instrument_payload_cleanup_helper.rb +1 -1
- data/lib/sentry/rails/railtie.rb +14 -1
- data/lib/sentry/rails/rescued_exception_interceptor.rb +0 -16
- data/lib/sentry/rails/tracing/abstract_subscriber.rb +20 -12
- data/lib/sentry/rails/tracing/action_controller_subscriber.rb +3 -3
- data/lib/sentry/rails/tracing/action_view_subscriber.rb +3 -3
- data/lib/sentry/rails/tracing/active_record_subscriber.rb +3 -3
- data/lib/sentry/rails/tracing/active_storage_subscriber.rb +34 -0
- data/lib/sentry/rails/tracing.rb +16 -4
- data/lib/sentry/rails/version.rb +1 -1
- data/lib/sentry/rails.rb +1 -1
- data/sentry-rails.gemspec +1 -1
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6da9817b3be6ac851ff62a6da80d638fc75d4c170825e9a925a7e5be5f973cb1
|
4
|
+
data.tar.gz: 7f5f80ab0dbf75bbe9773aef1ac180ab014b0f3b19b33983dd3ab38c20ec0f8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e1650da3dc176bb53ff5e47d919996bc8445e80973cb8baef071fcfdf30f237bc73ade309e45d94396926d9f0138c3b2ed4563f8c9cc2238ea00c7204bac032
|
7
|
+
data.tar.gz: b59164c5df42130717d2217358cf7f072c0fa9fbda35c5361a87ed96a83abf41b32c94ffd3430031c3fe22354e24ee637ebff390651e360bdb328375a3e354da
|
data/Gemfile
CHANGED
@@ -6,17 +6,23 @@ gem "sentry-ruby", path: "../sentry-ruby"
|
|
6
6
|
|
7
7
|
rails_version = ENV["RAILS_VERSION"]
|
8
8
|
rails_version = "6.1.0" if rails_version.nil?
|
9
|
+
rails_version = Gem::Version.new(rails_version)
|
9
10
|
|
10
11
|
gem 'activerecord-jdbcmysql-adapter', platform: :jruby
|
11
12
|
gem "jdbc-sqlite3", platform: :jruby
|
12
13
|
|
13
|
-
if rails_version
|
14
|
+
if rails_version < Gem::Version.new("6.0.0")
|
14
15
|
gem "sqlite3", "~> 1.3.0", platform: :ruby
|
15
16
|
else
|
16
17
|
gem "sqlite3", platform: :ruby
|
17
18
|
end
|
18
19
|
|
19
|
-
|
20
|
+
if rails_version >= Gem::Version.new("7.0.0")
|
21
|
+
gem "rails", github: "rails/rails", branch: "7-0-stable"
|
22
|
+
else
|
23
|
+
gem "rails", "~> #{rails_version}"
|
24
|
+
end
|
25
|
+
|
20
26
|
gem "sprockets-rails"
|
21
27
|
|
22
28
|
gem "sidekiq"
|
@@ -24,12 +30,14 @@ gem "sidekiq"
|
|
24
30
|
gem "rspec", "~> 3.0"
|
25
31
|
gem "rspec-retry"
|
26
32
|
gem "rspec-rails", "~> 4.0"
|
27
|
-
gem
|
33
|
+
gem 'simplecov'
|
34
|
+
gem "simplecov-cobertura", "~> 1.4"
|
35
|
+
gem "rexml"
|
28
36
|
|
29
37
|
gem "rake", "~> 12.0"
|
30
38
|
|
31
39
|
gem "object_tracer"
|
32
|
-
gem "debug", github: "ruby/debug" if RUBY_VERSION.to_f >= 2.6
|
40
|
+
gem "debug", github: "ruby/debug", platform: :ruby if RUBY_VERSION.to_f >= 2.6
|
33
41
|
gem "pry"
|
34
42
|
|
35
43
|
gem "benchmark-ips"
|
@@ -16,8 +16,8 @@ if defined?(ActiveJob)
|
|
16
16
|
discard_on ActiveJob::DeserializationError
|
17
17
|
else
|
18
18
|
# mimic what discard_on does for Rails 5.0
|
19
|
-
rescue_from ActiveJob::DeserializationError do
|
20
|
-
logger.error "Discarded #{self.class} due to a #{exception}. The original exception was #{
|
19
|
+
rescue_from ActiveJob::DeserializationError do |exception|
|
20
|
+
logger.error "Discarded #{self.class} due to a #{exception}. The original exception was #{exception.cause.inspect}."
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
@@ -0,0 +1,96 @@
|
|
1
|
+
module Sentry
|
2
|
+
module Rails
|
3
|
+
module ActionCableExtensions
|
4
|
+
class ErrorHandler
|
5
|
+
class << self
|
6
|
+
def capture(connection, transaction_name:, extra_context: nil, &block)
|
7
|
+
return block.call unless Sentry.initialized?
|
8
|
+
# ActionCable's ConnectionStub (for testing) doesn't implement the exact same interfaces as Connection::Base.
|
9
|
+
# One thing that's missing is `env`. So calling `connection.env` direclty will fail in test environments when `stub_connection` is used.
|
10
|
+
# See https://github.com/getsentry/sentry-ruby/pull/1684 for more information.
|
11
|
+
env = connection.respond_to?(:env) ? connection.env : {}
|
12
|
+
|
13
|
+
Sentry.with_scope do |scope|
|
14
|
+
scope.set_rack_env(env)
|
15
|
+
scope.set_context("action_cable", extra_context) if extra_context
|
16
|
+
scope.set_transaction_name(transaction_name)
|
17
|
+
transaction = start_transaction(env, scope.transaction_name)
|
18
|
+
scope.set_span(transaction) if transaction
|
19
|
+
|
20
|
+
begin
|
21
|
+
block.call
|
22
|
+
finish_transaction(transaction, 200)
|
23
|
+
rescue Exception => e # rubocop:disable Lint/RescueException
|
24
|
+
Sentry::Rails.capture_exception(e)
|
25
|
+
finish_transaction(transaction, 500)
|
26
|
+
|
27
|
+
raise
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def start_transaction(env, transaction_name)
|
33
|
+
sentry_trace = env["HTTP_SENTRY_TRACE"]
|
34
|
+
options = { name: transaction_name, op: "rails.action_cable".freeze }
|
35
|
+
transaction = Sentry::Transaction.from_sentry_trace(sentry_trace, **options) if sentry_trace
|
36
|
+
Sentry.start_transaction(transaction: transaction, **options)
|
37
|
+
end
|
38
|
+
|
39
|
+
def finish_transaction(transaction, status_code)
|
40
|
+
return unless transaction
|
41
|
+
|
42
|
+
transaction.set_http_status(status_code)
|
43
|
+
transaction.finish
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
module Connection
|
49
|
+
private
|
50
|
+
|
51
|
+
def handle_open
|
52
|
+
ErrorHandler.capture(self, transaction_name: "#{self.class.name}#connect") do
|
53
|
+
super
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def handle_close
|
58
|
+
ErrorHandler.capture(self, transaction_name: "#{self.class.name}#disconnect") do
|
59
|
+
super
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
module Channel
|
65
|
+
module Subscriptions
|
66
|
+
def self.included(base)
|
67
|
+
base.class_eval do
|
68
|
+
set_callback :subscribe, :around, ->(_, block) { sentry_capture(:subscribed, &block) }, prepend: true
|
69
|
+
set_callback :unsubscribe, :around, ->(_, block) { sentry_capture(:unsubscribed, &block) }, prepend: true
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
private
|
74
|
+
|
75
|
+
def sentry_capture(hook, &block)
|
76
|
+
extra_context = { params: params }
|
77
|
+
|
78
|
+
ErrorHandler.capture(connection, transaction_name: "#{self.class.name}##{hook}", extra_context: extra_context, &block)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
module Actions
|
83
|
+
private
|
84
|
+
|
85
|
+
def dispatch_action(action, data)
|
86
|
+
extra_context = { params: params, data: data }
|
87
|
+
|
88
|
+
ErrorHandler.capture(connection, transaction_name: "#{self.class.name}##{action}", extra_context: extra_context) do
|
89
|
+
super
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -1,28 +1,22 @@
|
|
1
1
|
module Sentry
|
2
2
|
module Rails
|
3
3
|
module ActiveJobExtensions
|
4
|
-
def
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
Sentry.with_scope do |scope|
|
12
|
-
capture_and_reraise_with_sentry(job, scope, block)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
else
|
16
|
-
block.call
|
4
|
+
def perform_now
|
5
|
+
if !Sentry.initialized? || already_supported_by_sentry_integration?
|
6
|
+
super
|
7
|
+
else
|
8
|
+
Sentry.with_scope do |scope|
|
9
|
+
capture_and_reraise_with_sentry(scope) do
|
10
|
+
super
|
17
11
|
end
|
18
12
|
end
|
19
13
|
end
|
20
14
|
end
|
21
15
|
|
22
|
-
def capture_and_reraise_with_sentry(
|
23
|
-
scope.set_transaction_name(
|
16
|
+
def capture_and_reraise_with_sentry(scope, &block)
|
17
|
+
scope.set_transaction_name(self.class.name)
|
24
18
|
transaction =
|
25
|
-
if
|
19
|
+
if is_a?(::Sentry::SendEventJob)
|
26
20
|
nil
|
27
21
|
else
|
28
22
|
Sentry.start_transaction(name: scope.transaction_name, op: "active_job")
|
@@ -30,50 +24,46 @@ module Sentry
|
|
30
24
|
|
31
25
|
scope.set_span(transaction) if transaction
|
32
26
|
|
33
|
-
block.call
|
27
|
+
return_value = block.call
|
34
28
|
|
35
|
-
|
29
|
+
finish_sentry_transaction(transaction, 200)
|
30
|
+
|
31
|
+
return_value
|
36
32
|
rescue Exception => e # rubocop:disable Lint/RescueException
|
37
|
-
|
38
|
-
finish_transaction(transaction, 500)
|
39
|
-
return rescue_handler_result if rescue_handler_result
|
33
|
+
finish_sentry_transaction(transaction, 500)
|
40
34
|
|
41
35
|
Sentry::Rails.capture_exception(
|
42
36
|
e,
|
43
|
-
extra: sentry_context
|
37
|
+
extra: sentry_context,
|
44
38
|
tags: {
|
45
|
-
job_id:
|
46
|
-
provider_job_id:
|
39
|
+
job_id: job_id,
|
40
|
+
provider_job_id:provider_job_id
|
47
41
|
}
|
48
42
|
)
|
49
43
|
raise e
|
50
44
|
end
|
51
45
|
|
52
|
-
def
|
46
|
+
def finish_sentry_transaction(transaction, status)
|
53
47
|
return unless transaction
|
54
48
|
|
55
49
|
transaction.set_http_status(status)
|
56
50
|
transaction.finish
|
57
51
|
end
|
58
52
|
|
59
|
-
def
|
60
|
-
Sentry.configuration.rails.skippable_job_adapters.include?(
|
53
|
+
def already_supported_by_sentry_integration?
|
54
|
+
Sentry.configuration.rails.skippable_job_adapters.include?(self.class.queue_adapter.class.to_s)
|
61
55
|
end
|
62
56
|
|
63
|
-
def sentry_context
|
57
|
+
def sentry_context
|
64
58
|
{
|
65
|
-
active_job:
|
66
|
-
arguments:
|
67
|
-
scheduled_at:
|
68
|
-
job_id:
|
69
|
-
provider_job_id:
|
70
|
-
locale:
|
59
|
+
active_job: self.class.name,
|
60
|
+
arguments: arguments,
|
61
|
+
scheduled_at: scheduled_at,
|
62
|
+
job_id: job_id,
|
63
|
+
provider_job_id: provider_job_id,
|
64
|
+
locale: locale
|
71
65
|
}
|
72
66
|
end
|
73
67
|
end
|
74
68
|
end
|
75
69
|
end
|
76
|
-
|
77
|
-
class ActiveJob::Base
|
78
|
-
include Sentry::Rails::ActiveJobExtensions
|
79
|
-
end
|
@@ -1,11 +1,9 @@
|
|
1
1
|
module Sentry
|
2
2
|
class BackgroundWorker
|
3
|
-
def
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
block.call
|
8
|
-
end
|
3
|
+
def _perform(&block)
|
4
|
+
# make sure the background worker returns AR connection if it accidentally acquire one during serialization
|
5
|
+
ActiveRecord::Base.connection_pool.with_connection do
|
6
|
+
block.call
|
9
7
|
end
|
10
8
|
end
|
11
9
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require "sentry/rails/tracing/action_controller_subscriber"
|
2
2
|
require "sentry/rails/tracing/action_view_subscriber"
|
3
3
|
require "sentry/rails/tracing/active_record_subscriber"
|
4
|
+
require "sentry/rails/tracing/active_storage_subscriber"
|
4
5
|
|
5
6
|
module Sentry
|
6
7
|
class Configuration
|
@@ -59,7 +60,8 @@ module Sentry
|
|
59
60
|
@tracing_subscribers = Set.new([
|
60
61
|
Sentry::Rails::Tracing::ActionControllerSubscriber,
|
61
62
|
Sentry::Rails::Tracing::ActionViewSubscriber,
|
62
|
-
Sentry::Rails::Tracing::ActiveRecordSubscriber
|
63
|
+
Sentry::Rails::Tracing::ActiveRecordSubscriber,
|
64
|
+
Sentry::Rails::Tracing::ActiveStorageSubscriber
|
63
65
|
])
|
64
66
|
end
|
65
67
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Sentry
|
2
2
|
module Rails
|
3
3
|
module InstrumentPayloadCleanupHelper
|
4
|
-
IGNORED_DATA_TYPES = [:request, :response, :headers, :exception, :exception_object]
|
4
|
+
IGNORED_DATA_TYPES = [:request, :response, :headers, :exception, :exception_object, Tracing::START_TIMESTAMP_NAME]
|
5
5
|
|
6
6
|
def cleanup_data(data)
|
7
7
|
IGNORED_DATA_TYPES.each do |key|
|
data/lib/sentry/rails/railtie.rb
CHANGED
@@ -7,7 +7,7 @@ module Sentry
|
|
7
7
|
# middlewares can't be injected after initialize
|
8
8
|
initializer "sentry.use_rack_middleware" do |app|
|
9
9
|
# placed after all the file-sending middlewares so we can avoid unnecessary transactions
|
10
|
-
app.config.middleware.insert_after ActionDispatch::
|
10
|
+
app.config.middleware.insert_after ActionDispatch::ShowExceptions, Sentry::Rails::CaptureExceptions
|
11
11
|
# need to place as close to DebugExceptions as possible to intercept most of the exceptions, including those raised by middlewares
|
12
12
|
app.config.middleware.insert_after ActionDispatch::DebugExceptions, Sentry::Rails::RescuedExceptionInterceptor
|
13
13
|
end
|
@@ -22,6 +22,19 @@ module Sentry
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
+
initializer "sentry.extend_action_cable", before: :eager_load! do |app|
|
26
|
+
ActiveSupport.on_load(:action_cable_connection) do
|
27
|
+
require "sentry/rails/action_cable"
|
28
|
+
prepend Sentry::Rails::ActionCableExtensions::Connection
|
29
|
+
end
|
30
|
+
|
31
|
+
ActiveSupport.on_load(:action_cable_channel) do
|
32
|
+
require "sentry/rails/action_cable"
|
33
|
+
include Sentry::Rails::ActionCableExtensions::Channel::Subscriptions
|
34
|
+
prepend Sentry::Rails::ActionCableExtensions::Channel::Actions
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
25
38
|
config.after_initialize do |app|
|
26
39
|
next unless Sentry.initialized?
|
27
40
|
|
@@ -11,22 +11,6 @@ module Sentry
|
|
11
11
|
begin
|
12
12
|
@app.call(env)
|
13
13
|
rescue => e
|
14
|
-
request = ActionDispatch::Request.new(env)
|
15
|
-
|
16
|
-
# Rails' ShowExceptions#render_exception will mutate env for the exceptions app
|
17
|
-
# so we need to hold a copy of env to report the accurate data (like request's url)
|
18
|
-
if request.show_exceptions?
|
19
|
-
scope = Sentry.get_current_scope
|
20
|
-
copied_env = scope.rack_env.dup
|
21
|
-
copied_env["sentry.original_transaction"] = scope.transaction_name
|
22
|
-
scope.set_rack_env(copied_env)
|
23
|
-
|
24
|
-
if report_rescued_exceptions?
|
25
|
-
Sentry::Rails.capture_exception(e)
|
26
|
-
env["sentry.already_captured"] = true
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
14
|
env["sentry.rescued_exception"] = e if report_rescued_exceptions?
|
31
15
|
raise e
|
32
16
|
end
|
@@ -9,22 +9,30 @@ module Sentry
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def unsubscribe!
|
12
|
-
|
12
|
+
self::EVENT_NAMES.each do |name|
|
13
|
+
ActiveSupport::Notifications.unsubscribe(name)
|
14
|
+
end
|
13
15
|
end
|
14
16
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
17
|
+
if ::Rails.version.to_i == 5
|
18
|
+
def subscribe_to_event(event_names)
|
19
|
+
event_names.each do |event_name|
|
20
|
+
ActiveSupport::Notifications.subscribe(event_name) do |*args|
|
21
|
+
next unless Tracing.get_current_transaction
|
19
22
|
|
20
|
-
|
21
|
-
|
23
|
+
event = ActiveSupport::Notifications::Event.new(*args)
|
24
|
+
yield(event_name, event.duration, event.payload)
|
25
|
+
end
|
22
26
|
end
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
27
|
+
end
|
28
|
+
else
|
29
|
+
def subscribe_to_event(event_names)
|
30
|
+
event_names.each do |event_name|
|
31
|
+
ActiveSupport::Notifications.subscribe(event_name) do |event|
|
32
|
+
next unless Tracing.get_current_transaction
|
33
|
+
|
34
|
+
yield(event_name, event.duration, event.payload)
|
35
|
+
end
|
28
36
|
end
|
29
37
|
end
|
30
38
|
end
|
@@ -7,16 +7,16 @@ module Sentry
|
|
7
7
|
class ActionControllerSubscriber < AbstractSubscriber
|
8
8
|
extend InstrumentPayloadCleanupHelper
|
9
9
|
|
10
|
-
|
10
|
+
EVENT_NAMES = ["process_action.action_controller"].freeze
|
11
11
|
|
12
12
|
def self.subscribe!
|
13
|
-
subscribe_to_event(
|
13
|
+
subscribe_to_event(EVENT_NAMES) do |event_name, duration, payload|
|
14
14
|
controller = payload[:controller]
|
15
15
|
action = payload[:action]
|
16
16
|
|
17
17
|
record_on_current_span(
|
18
18
|
op: event_name,
|
19
|
-
start_timestamp: payload[
|
19
|
+
start_timestamp: payload[START_TIMESTAMP_NAME],
|
20
20
|
description: "#{controller}##{action}",
|
21
21
|
duration: duration
|
22
22
|
) do |span|
|
@@ -4,11 +4,11 @@ module Sentry
|
|
4
4
|
module Rails
|
5
5
|
module Tracing
|
6
6
|
class ActionViewSubscriber < AbstractSubscriber
|
7
|
-
|
7
|
+
EVENT_NAMES = ["render_template.action_view"].freeze
|
8
8
|
|
9
9
|
def self.subscribe!
|
10
|
-
subscribe_to_event(
|
11
|
-
record_on_current_span(op: event_name, start_timestamp: payload[
|
10
|
+
subscribe_to_event(EVENT_NAMES) do |event_name, duration, payload|
|
11
|
+
record_on_current_span(op: event_name, start_timestamp: payload[START_TIMESTAMP_NAME], description: payload[:identifier], duration: duration)
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
@@ -4,14 +4,14 @@ module Sentry
|
|
4
4
|
module Rails
|
5
5
|
module Tracing
|
6
6
|
class ActiveRecordSubscriber < AbstractSubscriber
|
7
|
-
|
7
|
+
EVENT_NAMES = ["sql.active_record"].freeze
|
8
8
|
EXCLUDED_EVENTS = ["SCHEMA", "TRANSACTION"].freeze
|
9
9
|
|
10
10
|
def self.subscribe!
|
11
|
-
subscribe_to_event(
|
11
|
+
subscribe_to_event(EVENT_NAMES) do |event_name, duration, payload|
|
12
12
|
next if EXCLUDED_EVENTS.include? payload[:name]
|
13
13
|
|
14
|
-
record_on_current_span(op: event_name, start_timestamp: payload[
|
14
|
+
record_on_current_span(op: event_name, start_timestamp: payload[START_TIMESTAMP_NAME], description: payload[:sql], duration: duration) do |span|
|
15
15
|
span.set_data(:connection_id, payload[:connection_id])
|
16
16
|
end
|
17
17
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require "sentry/rails/tracing/abstract_subscriber"
|
2
|
+
|
3
|
+
module Sentry
|
4
|
+
module Rails
|
5
|
+
module Tracing
|
6
|
+
class ActiveStorageSubscriber < AbstractSubscriber
|
7
|
+
EVENT_NAMES = %w(
|
8
|
+
service_upload.active_storage
|
9
|
+
service_download.active_storage
|
10
|
+
service_streaming_download.active_storage
|
11
|
+
service_download_chunk.active_storage
|
12
|
+
service_delete.active_storage
|
13
|
+
service_delete_prefixed.active_storage
|
14
|
+
service_exist.active_storage
|
15
|
+
service_url.active_storage
|
16
|
+
service_mirror.active_storage
|
17
|
+
service_update_metadata.active_storage
|
18
|
+
preview.active_storage
|
19
|
+
analyze.active_storage
|
20
|
+
).freeze
|
21
|
+
|
22
|
+
def self.subscribe!
|
23
|
+
subscribe_to_event(EVENT_NAMES) do |event_name, duration, payload|
|
24
|
+
record_on_current_span(op: event_name, start_timestamp: payload[START_TIMESTAMP_NAME], description: payload[:service], duration: duration) do |span|
|
25
|
+
payload.each do |key, value|
|
26
|
+
span.set_data(key, value) unless key == START_TIMESTAMP_NAME
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/sentry/rails/tracing.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
module Sentry
|
2
2
|
module Rails
|
3
3
|
module Tracing
|
4
|
+
START_TIMESTAMP_NAME = :sentry_start_timestamp
|
5
|
+
|
4
6
|
def self.register_subscribers(subscribers)
|
5
7
|
@subscribers = subscribers
|
6
8
|
end
|
@@ -9,11 +11,19 @@ module Sentry
|
|
9
11
|
@subscribers
|
10
12
|
end
|
11
13
|
|
14
|
+
def self.subscribed_tracing_events
|
15
|
+
@subscribed_tracing_events ||= []
|
16
|
+
end
|
17
|
+
|
12
18
|
def self.subscribe_tracing_events
|
13
19
|
# need to avoid duplicated subscription
|
14
20
|
return if @subscribed
|
15
21
|
|
16
|
-
subscribers.each
|
22
|
+
subscribers.each do |subscriber|
|
23
|
+
subscriber.subscribe!
|
24
|
+
@subscribed_tracing_events ||= []
|
25
|
+
@subscribed_tracing_events += subscriber::EVENT_NAMES
|
26
|
+
end
|
17
27
|
|
18
28
|
@subscribed = true
|
19
29
|
end
|
@@ -22,6 +32,7 @@ module Sentry
|
|
22
32
|
return unless @subscribed
|
23
33
|
|
24
34
|
subscribers.each(&:unsubscribe!)
|
35
|
+
subscribed_tracing_events.clear
|
25
36
|
|
26
37
|
@subscribed = false
|
27
38
|
end
|
@@ -35,9 +46,10 @@ module Sentry
|
|
35
46
|
|
36
47
|
SentryNotificationExtension.module_eval do
|
37
48
|
def instrument(name, payload = {}, &block)
|
38
|
-
|
39
|
-
|
40
|
-
|
49
|
+
# only inject timestamp to the events the SDK subscribes to
|
50
|
+
if Tracing.subscribed_tracing_events.include?(name)
|
51
|
+
payload[START_TIMESTAMP_NAME] = Time.now.utc.to_f if name[0] != "!" && payload.is_a?(Hash)
|
52
|
+
end
|
41
53
|
|
42
54
|
super(name, payload, &block)
|
43
55
|
end
|
data/lib/sentry/rails/version.rb
CHANGED
data/lib/sentry/rails.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
require "rails"
|
2
2
|
require "sentry-ruby"
|
3
3
|
require "sentry/integrable"
|
4
|
+
require "sentry/rails/tracing"
|
4
5
|
require "sentry/rails/configuration"
|
5
6
|
require "sentry/rails/engine"
|
6
7
|
require "sentry/rails/railtie"
|
7
|
-
require "sentry/rails/tracing"
|
8
8
|
|
9
9
|
module Sentry
|
10
10
|
module Rails
|
data/sentry-rails.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sentry-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.9.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sentry Team
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 4.
|
33
|
+
version: 4.9.2
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 4.
|
40
|
+
version: 4.9.2
|
41
41
|
description: A gem that provides Rails integration for the Sentry error logger
|
42
42
|
email: accounts@sentry.io
|
43
43
|
executables: []
|
@@ -60,6 +60,7 @@ files:
|
|
60
60
|
- bin/setup
|
61
61
|
- lib/sentry-rails.rb
|
62
62
|
- lib/sentry/rails.rb
|
63
|
+
- lib/sentry/rails/action_cable.rb
|
63
64
|
- lib/sentry/rails/active_job.rb
|
64
65
|
- lib/sentry/rails/background_worker.rb
|
65
66
|
- lib/sentry/rails/backtrace_cleaner.rb
|
@@ -79,6 +80,7 @@ files:
|
|
79
80
|
- lib/sentry/rails/tracing/action_controller_subscriber.rb
|
80
81
|
- lib/sentry/rails/tracing/action_view_subscriber.rb
|
81
82
|
- lib/sentry/rails/tracing/active_record_subscriber.rb
|
83
|
+
- lib/sentry/rails/tracing/active_storage_subscriber.rb
|
82
84
|
- lib/sentry/rails/version.rb
|
83
85
|
- sentry-rails.gemspec
|
84
86
|
homepage: https://github.com/getsentry/sentry-ruby
|