sentry-rails 5.23.0 → 5.28.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.
- checksums.yaml +4 -4
- data/Gemfile +15 -4
- data/Rakefile +11 -28
- data/bin/test +389 -0
- data/lib/sentry/rails/active_job.rb +55 -8
- data/lib/sentry/rails/background_worker.rb +11 -7
- data/lib/sentry/rails/configuration.rb +46 -4
- data/lib/sentry/rails/log_subscriber.rb +73 -0
- data/lib/sentry/rails/log_subscribers/action_controller_subscriber.rb +116 -0
- data/lib/sentry/rails/log_subscribers/action_mailer_subscriber.rb +88 -0
- data/lib/sentry/rails/log_subscribers/active_job_subscriber.rb +155 -0
- data/lib/sentry/rails/log_subscribers/active_record_subscriber.rb +134 -0
- data/lib/sentry/rails/log_subscribers/parameter_filter.rb +52 -0
- data/lib/sentry/rails/railtie.rb +12 -0
- data/lib/sentry/rails/structured_logging.rb +32 -0
- data/lib/sentry/rails/tracing/action_controller_subscriber.rb +1 -1
- data/lib/sentry/rails/tracing/active_storage_subscriber.rb +4 -1
- data/lib/sentry/rails/version.rb +1 -1
- data/lib/sentry/rails.rb +1 -0
- data/sentry-rails.gemspec +1 -1
- metadata +19 -11
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Sentry
|
|
4
|
+
module Rails
|
|
5
|
+
module LogSubscribers
|
|
6
|
+
# Shared utility module for filtering sensitive parameters in log subscribers.
|
|
7
|
+
#
|
|
8
|
+
# This module provides consistent parameter filtering across all Sentry Rails
|
|
9
|
+
# log subscribers, leveraging Rails' built-in parameter filtering when available.
|
|
10
|
+
# It automatically detects the correct Rails parameter filtering API based on
|
|
11
|
+
# the Rails version and includes the appropriate implementation module.
|
|
12
|
+
#
|
|
13
|
+
# @example Usage in a log subscriber
|
|
14
|
+
# class MySubscriber < Sentry::Rails::LogSubscriber
|
|
15
|
+
# include Sentry::Rails::LogSubscribers::ParameterFilter
|
|
16
|
+
#
|
|
17
|
+
# def my_event(event)
|
|
18
|
+
# if Sentry.configuration.send_default_pii && event.payload[:params]
|
|
19
|
+
# filtered_params = filter_sensitive_params(event.payload[:params])
|
|
20
|
+
# attributes[:params] = filtered_params unless filtered_params.empty?
|
|
21
|
+
# end
|
|
22
|
+
# end
|
|
23
|
+
# end
|
|
24
|
+
module ParameterFilter
|
|
25
|
+
EMPTY_HASH = {}.freeze
|
|
26
|
+
|
|
27
|
+
if ::Rails.version.to_f >= 6.0
|
|
28
|
+
def self.backend
|
|
29
|
+
ActiveSupport::ParameterFilter
|
|
30
|
+
end
|
|
31
|
+
else
|
|
32
|
+
def self.backend
|
|
33
|
+
ActionDispatch::Http::ParameterFilter
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Filter sensitive parameters from a hash, respecting Rails configuration.
|
|
38
|
+
#
|
|
39
|
+
# @param params [Hash] The parameters to filter
|
|
40
|
+
# @return [Hash] Filtered parameters with sensitive data removed
|
|
41
|
+
def filter_sensitive_params(params)
|
|
42
|
+
return EMPTY_HASH unless params.is_a?(Hash)
|
|
43
|
+
|
|
44
|
+
filter_parameters = ::Rails.application.config.filter_parameters
|
|
45
|
+
parameter_filter = ParameterFilter.backend.new(filter_parameters)
|
|
46
|
+
|
|
47
|
+
parameter_filter.filter(params)
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
data/lib/sentry/rails/railtie.rb
CHANGED
|
@@ -49,8 +49,14 @@ module Sentry
|
|
|
49
49
|
setup_backtrace_cleanup_callback
|
|
50
50
|
inject_breadcrumbs_logger
|
|
51
51
|
activate_tracing
|
|
52
|
+
activate_structured_logging
|
|
52
53
|
|
|
53
54
|
register_error_subscriber(app) if ::Rails.version.to_f >= 7.0 && Sentry.configuration.rails.register_error_subscriber
|
|
55
|
+
|
|
56
|
+
# Presence of ActiveJob is no longer a reliable cue
|
|
57
|
+
if defined?(Sentry::Rails::ActiveJobExtensions)
|
|
58
|
+
Sentry::Rails::ActiveJobExtensions::SentryReporter.register_event_handlers
|
|
59
|
+
end
|
|
54
60
|
end
|
|
55
61
|
|
|
56
62
|
runner do
|
|
@@ -133,6 +139,12 @@ module Sentry
|
|
|
133
139
|
end
|
|
134
140
|
end
|
|
135
141
|
|
|
142
|
+
def activate_structured_logging
|
|
143
|
+
if Sentry.configuration.rails.structured_logging.enabled? && Sentry.configuration.enable_logs
|
|
144
|
+
Sentry::Rails::StructuredLogging.attach(Sentry.configuration.rails.structured_logging)
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
|
|
136
148
|
def register_error_subscriber(app)
|
|
137
149
|
require "sentry/rails/error_subscriber"
|
|
138
150
|
app.executor.error_reporter.subscribe(Sentry::Rails::ErrorSubscriber.new)
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "sentry/rails/log_subscriber"
|
|
4
|
+
require "sentry/rails/log_subscribers/action_controller_subscriber"
|
|
5
|
+
require "sentry/rails/log_subscribers/active_record_subscriber"
|
|
6
|
+
require "sentry/rails/log_subscribers/active_job_subscriber"
|
|
7
|
+
require "sentry/rails/log_subscribers/action_mailer_subscriber"
|
|
8
|
+
|
|
9
|
+
module Sentry
|
|
10
|
+
module Rails
|
|
11
|
+
module StructuredLogging
|
|
12
|
+
class << self
|
|
13
|
+
def attach(config)
|
|
14
|
+
config.subscribers.each do |component, subscriber_class|
|
|
15
|
+
subscriber_class.attach_to component
|
|
16
|
+
end
|
|
17
|
+
rescue => e
|
|
18
|
+
Sentry.configuration.sdk_logger.error("Failed to attach structured loggers: #{e.message}")
|
|
19
|
+
Sentry.configuration.sdk_logger.error(e.backtrace.join("\n"))
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def detach(config)
|
|
23
|
+
config.subscribers.each do |component, subscriber_class|
|
|
24
|
+
subscriber_class.detach_from component
|
|
25
|
+
end
|
|
26
|
+
rescue => e
|
|
27
|
+
Sentry.configuration.sdk_logger.debug("Error during detaching loggers: #{e.message}")
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -14,7 +14,7 @@ module Sentry
|
|
|
14
14
|
SPAN_ORIGIN = "auto.view.rails"
|
|
15
15
|
|
|
16
16
|
def self.subscribe!
|
|
17
|
-
Sentry.
|
|
17
|
+
Sentry.sdk_logger.warn <<~MSG
|
|
18
18
|
DEPRECATION WARNING: sentry-rails has changed its approach on controller span recording and #{self.name} is now depreacted.
|
|
19
19
|
Please stop using or referencing #{self.name} as it will be removed in the next major release.
|
|
20
20
|
MSG
|
|
@@ -33,7 +33,10 @@ module Sentry
|
|
|
33
33
|
duration: duration
|
|
34
34
|
) do |span|
|
|
35
35
|
payload.each do |key, value|
|
|
36
|
-
|
|
36
|
+
next if key == START_TIMESTAMP_NAME
|
|
37
|
+
next if key == :key && !Sentry.configuration.send_default_pii
|
|
38
|
+
|
|
39
|
+
span.set_data(key, value)
|
|
37
40
|
end
|
|
38
41
|
end
|
|
39
42
|
end
|
data/lib/sentry/rails/version.rb
CHANGED
data/lib/sentry/rails.rb
CHANGED
data/sentry-rails.gemspec
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sentry-rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 5.
|
|
4
|
+
version: 5.28.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sentry Team
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: railties
|
|
@@ -29,21 +29,21 @@ dependencies:
|
|
|
29
29
|
requirements:
|
|
30
30
|
- - "~>"
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: 5.
|
|
32
|
+
version: 5.28.0
|
|
33
33
|
type: :runtime
|
|
34
34
|
prerelease: false
|
|
35
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
36
36
|
requirements:
|
|
37
37
|
- - "~>"
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: 5.
|
|
39
|
+
version: 5.28.0
|
|
40
40
|
description: A gem that provides Rails integration for the Sentry error logger
|
|
41
41
|
email: accounts@sentry.io
|
|
42
42
|
executables: []
|
|
43
43
|
extensions: []
|
|
44
44
|
extra_rdoc_files:
|
|
45
|
-
- README.md
|
|
46
45
|
- LICENSE.txt
|
|
46
|
+
- README.md
|
|
47
47
|
files:
|
|
48
48
|
- ".gitignore"
|
|
49
49
|
- ".rspec"
|
|
@@ -56,6 +56,7 @@ files:
|
|
|
56
56
|
- app/jobs/sentry/send_event_job.rb
|
|
57
57
|
- bin/console
|
|
58
58
|
- bin/setup
|
|
59
|
+
- bin/test
|
|
59
60
|
- lib/generators/sentry_generator.rb
|
|
60
61
|
- lib/sentry-rails.rb
|
|
61
62
|
- lib/sentry/rails.rb
|
|
@@ -72,9 +73,16 @@ files:
|
|
|
72
73
|
- lib/sentry/rails/engine.rb
|
|
73
74
|
- lib/sentry/rails/error_subscriber.rb
|
|
74
75
|
- lib/sentry/rails/instrument_payload_cleanup_helper.rb
|
|
76
|
+
- lib/sentry/rails/log_subscriber.rb
|
|
77
|
+
- lib/sentry/rails/log_subscribers/action_controller_subscriber.rb
|
|
78
|
+
- lib/sentry/rails/log_subscribers/action_mailer_subscriber.rb
|
|
79
|
+
- lib/sentry/rails/log_subscribers/active_job_subscriber.rb
|
|
80
|
+
- lib/sentry/rails/log_subscribers/active_record_subscriber.rb
|
|
81
|
+
- lib/sentry/rails/log_subscribers/parameter_filter.rb
|
|
75
82
|
- lib/sentry/rails/overrides/streaming_reporter.rb
|
|
76
83
|
- lib/sentry/rails/railtie.rb
|
|
77
84
|
- lib/sentry/rails/rescued_exception_interceptor.rb
|
|
85
|
+
- lib/sentry/rails/structured_logging.rb
|
|
78
86
|
- lib/sentry/rails/tracing.rb
|
|
79
87
|
- lib/sentry/rails/tracing/abstract_subscriber.rb
|
|
80
88
|
- lib/sentry/rails/tracing/action_controller_subscriber.rb
|
|
@@ -84,15 +92,15 @@ files:
|
|
|
84
92
|
- lib/sentry/rails/tracing/active_support_subscriber.rb
|
|
85
93
|
- lib/sentry/rails/version.rb
|
|
86
94
|
- sentry-rails.gemspec
|
|
87
|
-
homepage: https://github.com/getsentry/sentry-ruby/tree/5.
|
|
95
|
+
homepage: https://github.com/getsentry/sentry-ruby/tree/5.28.0/sentry-rails
|
|
88
96
|
licenses:
|
|
89
97
|
- MIT
|
|
90
98
|
metadata:
|
|
91
|
-
homepage_uri: https://github.com/getsentry/sentry-ruby/tree/5.
|
|
92
|
-
source_code_uri: https://github.com/getsentry/sentry-ruby/tree/5.
|
|
93
|
-
changelog_uri: https://github.com/getsentry/sentry-ruby/blob/5.
|
|
99
|
+
homepage_uri: https://github.com/getsentry/sentry-ruby/tree/5.28.0/sentry-rails
|
|
100
|
+
source_code_uri: https://github.com/getsentry/sentry-ruby/tree/5.28.0/sentry-rails
|
|
101
|
+
changelog_uri: https://github.com/getsentry/sentry-ruby/blob/5.28.0/CHANGELOG.md
|
|
94
102
|
bug_tracker_uri: https://github.com/getsentry/sentry-ruby/issues
|
|
95
|
-
documentation_uri: http://www.rubydoc.info/gems/sentry-rails/5.
|
|
103
|
+
documentation_uri: http://www.rubydoc.info/gems/sentry-rails/5.28.0
|
|
96
104
|
rdoc_options: []
|
|
97
105
|
require_paths:
|
|
98
106
|
- lib
|
|
@@ -107,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
107
115
|
- !ruby/object:Gem::Version
|
|
108
116
|
version: '0'
|
|
109
117
|
requirements: []
|
|
110
|
-
rubygems_version: 3.6.
|
|
118
|
+
rubygems_version: 3.6.9
|
|
111
119
|
specification_version: 4
|
|
112
120
|
summary: A gem that provides Rails integration for the Sentry error logger
|
|
113
121
|
test_files: []
|