sentry-ruby 5.13.0 → 5.21.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +7 -18
  3. data/README.md +20 -10
  4. data/Rakefile +3 -1
  5. data/bin/console +2 -0
  6. data/lib/sentry/attachment.rb +40 -0
  7. data/lib/sentry/background_worker.rb +9 -2
  8. data/lib/sentry/backpressure_monitor.rb +45 -0
  9. data/lib/sentry/backtrace.rb +10 -8
  10. data/lib/sentry/baggage.rb +7 -7
  11. data/lib/sentry/breadcrumb/sentry_logger.rb +6 -6
  12. data/lib/sentry/check_in_event.rb +5 -5
  13. data/lib/sentry/client.rb +71 -18
  14. data/lib/sentry/configuration.rb +108 -32
  15. data/lib/sentry/core_ext/object/deep_dup.rb +1 -1
  16. data/lib/sentry/cron/configuration.rb +23 -0
  17. data/lib/sentry/cron/monitor_check_ins.rb +42 -26
  18. data/lib/sentry/cron/monitor_config.rb +1 -1
  19. data/lib/sentry/cron/monitor_schedule.rb +1 -1
  20. data/lib/sentry/dsn.rb +4 -4
  21. data/lib/sentry/envelope/item.rb +88 -0
  22. data/lib/sentry/envelope.rb +2 -68
  23. data/lib/sentry/error_event.rb +2 -2
  24. data/lib/sentry/event.rb +20 -46
  25. data/lib/sentry/faraday.rb +77 -0
  26. data/lib/sentry/graphql.rb +9 -0
  27. data/lib/sentry/hub.rb +25 -5
  28. data/lib/sentry/integrable.rb +4 -0
  29. data/lib/sentry/interface.rb +1 -0
  30. data/lib/sentry/interfaces/exception.rb +5 -3
  31. data/lib/sentry/interfaces/mechanism.rb +20 -0
  32. data/lib/sentry/interfaces/request.rb +7 -7
  33. data/lib/sentry/interfaces/single_exception.rb +10 -7
  34. data/lib/sentry/interfaces/stacktrace.rb +3 -1
  35. data/lib/sentry/interfaces/stacktrace_builder.rb +23 -2
  36. data/lib/sentry/logger.rb +1 -1
  37. data/lib/sentry/metrics/aggregator.rb +248 -0
  38. data/lib/sentry/metrics/configuration.rb +47 -0
  39. data/lib/sentry/metrics/counter_metric.rb +25 -0
  40. data/lib/sentry/metrics/distribution_metric.rb +25 -0
  41. data/lib/sentry/metrics/gauge_metric.rb +35 -0
  42. data/lib/sentry/metrics/local_aggregator.rb +53 -0
  43. data/lib/sentry/metrics/metric.rb +19 -0
  44. data/lib/sentry/metrics/set_metric.rb +28 -0
  45. data/lib/sentry/metrics/timing.rb +43 -0
  46. data/lib/sentry/metrics.rb +56 -0
  47. data/lib/sentry/net/http.rb +22 -39
  48. data/lib/sentry/profiler/helpers.rb +46 -0
  49. data/lib/sentry/profiler.rb +25 -56
  50. data/lib/sentry/propagation_context.rb +10 -9
  51. data/lib/sentry/puma.rb +1 -1
  52. data/lib/sentry/rack/capture_exceptions.rb +16 -4
  53. data/lib/sentry/rack.rb +2 -2
  54. data/lib/sentry/rake.rb +4 -15
  55. data/lib/sentry/redis.rb +2 -1
  56. data/lib/sentry/release_detector.rb +5 -5
  57. data/lib/sentry/scope.rb +48 -37
  58. data/lib/sentry/session.rb +2 -2
  59. data/lib/sentry/session_flusher.rb +7 -39
  60. data/lib/sentry/span.rb +46 -5
  61. data/lib/sentry/test_helper.rb +5 -2
  62. data/lib/sentry/threaded_periodic_worker.rb +39 -0
  63. data/lib/sentry/transaction.rb +27 -18
  64. data/lib/sentry/transaction_event.rb +6 -2
  65. data/lib/sentry/transport/configuration.rb +73 -1
  66. data/lib/sentry/transport/http_transport.rb +72 -41
  67. data/lib/sentry/transport/spotlight_transport.rb +50 -0
  68. data/lib/sentry/transport.rb +36 -41
  69. data/lib/sentry/utils/argument_checking_helper.rb +6 -0
  70. data/lib/sentry/utils/env_helper.rb +21 -0
  71. data/lib/sentry/utils/http_tracing.rb +41 -0
  72. data/lib/sentry/utils/logging_helper.rb +0 -4
  73. data/lib/sentry/utils/real_ip.rb +2 -2
  74. data/lib/sentry/utils/request_id.rb +1 -1
  75. data/lib/sentry/vernier/output.rb +89 -0
  76. data/lib/sentry/vernier/profiler.rb +125 -0
  77. data/lib/sentry/version.rb +1 -1
  78. data/lib/sentry-ruby.rb +61 -27
  79. data/sentry-ruby-core.gemspec +3 -1
  80. data/sentry-ruby.gemspec +15 -6
  81. metadata +47 -7
data/lib/sentry-ruby.rb CHANGED
@@ -20,12 +20,16 @@ require "sentry/span"
20
20
  require "sentry/transaction"
21
21
  require "sentry/hub"
22
22
  require "sentry/background_worker"
23
+ require "sentry/threaded_periodic_worker"
23
24
  require "sentry/session_flusher"
25
+ require "sentry/backpressure_monitor"
24
26
  require "sentry/cron/monitor_check_ins"
27
+ require "sentry/metrics"
28
+ require "sentry/vernier/profiler"
25
29
 
26
30
  [
27
31
  "sentry/rake",
28
- "sentry/rack",
32
+ "sentry/rack"
29
33
  ].each do |lib|
30
34
  begin
31
35
  require lib
@@ -38,11 +42,11 @@ module Sentry
38
42
 
39
43
  CAPTURED_SIGNATURE = :@__sentry_captured
40
44
 
41
- LOGGER_PROGNAME = "sentry".freeze
45
+ LOGGER_PROGNAME = "sentry"
42
46
 
43
- SENTRY_TRACE_HEADER_NAME = "sentry-trace".freeze
47
+ SENTRY_TRACE_HEADER_NAME = "sentry-trace"
44
48
 
45
- BAGGAGE_HEADER_NAME = "baggage".freeze
49
+ BAGGAGE_HEADER_NAME = "baggage"
46
50
 
47
51
  THREAD_LOCAL = :sentry_hub
48
52
 
@@ -65,13 +69,21 @@ module Sentry
65
69
  end
66
70
 
67
71
  # @!attribute [rw] background_worker
68
- # @return [BackgroundWorker, nil]
72
+ # @return [BackgroundWorker]
69
73
  attr_accessor :background_worker
70
74
 
71
75
  # @!attribute [r] session_flusher
72
76
  # @return [SessionFlusher, nil]
73
77
  attr_reader :session_flusher
74
78
 
79
+ # @!attribute [r] backpressure_monitor
80
+ # @return [BackpressureMonitor, nil]
81
+ attr_reader :backpressure_monitor
82
+
83
+ # @!attribute [r] metrics_aggregator
84
+ # @return [Metrics::Aggregator, nil]
85
+ attr_reader :metrics_aggregator
86
+
75
87
  ##### Patch Registration #####
76
88
 
77
89
  # @!visibility private
@@ -200,6 +212,13 @@ module Sentry
200
212
  get_current_scope.set_context(*args)
201
213
  end
202
214
 
215
+ # @!method add_attachment
216
+ # @!macro add_attachment
217
+ def add_attachment(**opts)
218
+ return unless initialized?
219
+ get_current_scope.add_attachment(**opts)
220
+ end
221
+
203
222
  ##### Main APIs #####
204
223
 
205
224
  # Initializes the SDK with given configuration.
@@ -217,17 +236,10 @@ module Sentry
217
236
  Thread.current.thread_variable_set(THREAD_LOCAL, hub)
218
237
  @main_hub = hub
219
238
  @background_worker = Sentry::BackgroundWorker.new(config)
220
-
221
- @session_flusher = if config.auto_session_tracking
222
- Sentry::SessionFlusher.new(config, client)
223
- else
224
- nil
225
- end
226
-
227
- if config.include_local_variables
228
- exception_locals_tp.enable
229
- end
230
-
239
+ @session_flusher = config.session_tracking? ? Sentry::SessionFlusher.new(config, client) : nil
240
+ @backpressure_monitor = config.enable_backpressure_handling ? Sentry::BackpressureMonitor.new(config, client) : nil
241
+ @metrics_aggregator = config.metrics.enabled ? Sentry::Metrics::Aggregator.new(config, client) : nil
242
+ exception_locals_tp.enable if config.include_local_variables
231
243
  at_exit { close }
232
244
  end
233
245
 
@@ -236,20 +248,33 @@ module Sentry
236
248
  #
237
249
  # @return [void]
238
250
  def close
239
- if @background_worker
240
- @background_worker.shutdown
241
- @background_worker = nil
242
- end
243
-
244
251
  if @session_flusher
252
+ @session_flusher.flush
245
253
  @session_flusher.kill
246
254
  @session_flusher = nil
247
255
  end
248
256
 
249
- if configuration&.include_local_variables
250
- exception_locals_tp.disable
257
+ if @backpressure_monitor
258
+ @backpressure_monitor.kill
259
+ @backpressure_monitor = nil
260
+ end
261
+
262
+ if @metrics_aggregator
263
+ @metrics_aggregator.flush(force: true)
264
+ @metrics_aggregator.kill
265
+ @metrics_aggregator = nil
251
266
  end
252
267
 
268
+ if client = get_current_client
269
+ client.flush
270
+
271
+ if client.configuration.include_local_variables
272
+ exception_locals_tp.disable
273
+ end
274
+ end
275
+
276
+ @background_worker.shutdown
277
+
253
278
  @main_hub = nil
254
279
  Thread.current.thread_variable_set(THREAD_LOCAL, nil)
255
280
  end
@@ -442,12 +467,10 @@ module Sentry
442
467
  # @option options [Integer] duration seconds elapsed since this monitor started
443
468
  # @option options [Cron::MonitorConfig] monitor_config configuration for this monitor
444
469
  #
445
- # @yieldparam scope [Scope]
446
- #
447
470
  # @return [String, nil] The {CheckInEvent#check_in_id} to use for later updates on the same slug
448
- def capture_check_in(slug, status, **options, &block)
471
+ def capture_check_in(slug, status, **options)
449
472
  return unless initialized?
450
- get_current_hub.capture_check_in(slug, status, **options, &block)
473
+ get_current_hub.capture_check_in(slug, status, **options)
451
474
  end
452
475
 
453
476
  # Takes or initializes a new Sentry::Transaction and makes a sampling decision for it.
@@ -536,6 +559,15 @@ module Sentry
536
559
  get_current_hub.get_trace_propagation_headers
537
560
  end
538
561
 
562
+ # Returns the a Hash containing sentry-trace and baggage.
563
+ # Can be either from the currently active span or the propagation context.
564
+ #
565
+ # @return [String]
566
+ def get_trace_propagation_meta
567
+ return "" unless initialized?
568
+ get_current_hub.get_trace_propagation_meta
569
+ end
570
+
539
571
  # Continue an incoming trace from a rack env like hash.
540
572
  #
541
573
  # @param env [Hash]
@@ -576,3 +608,5 @@ end
576
608
  require "sentry/net/http"
577
609
  require "sentry/redis"
578
610
  require "sentry/puma"
611
+ require "sentry/graphql"
612
+ require "sentry/faraday"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative "lib/sentry/version"
2
4
 
3
5
  Gem::Specification.new do |spec|
@@ -12,7 +14,7 @@ Gem::Specification.new do |spec|
12
14
  spec.platform = Gem::Platform::RUBY
13
15
  spec.required_ruby_version = '>= 2.4'
14
16
  spec.extra_rdoc_files = ["README.md", "LICENSE.txt"]
15
- spec.files = `git ls-files | grep -Ev '^(spec|benchmarks|examples)'`.split("\n")
17
+ spec.files = `git ls-files | grep -Ev '^(spec|benchmarks|examples|\.rubocop\.yml)'`.split("\n")
16
18
 
17
19
  spec.metadata["homepage_uri"] = spec.homepage
18
20
  spec.metadata["source_code_uri"] = spec.homepage
data/sentry-ruby.gemspec CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative "lib/sentry/version"
2
4
 
3
5
  Gem::Specification.new do |spec|
@@ -7,18 +9,25 @@ Gem::Specification.new do |spec|
7
9
  spec.description = spec.summary = "A gem that provides a client interface for the Sentry error logger"
8
10
  spec.email = "accounts@sentry.io"
9
11
  spec.license = 'MIT'
10
- spec.homepage = "https://github.com/getsentry/sentry-ruby"
11
12
 
12
13
  spec.platform = Gem::Platform::RUBY
13
14
  spec.required_ruby_version = '>= 2.4'
14
15
  spec.extra_rdoc_files = ["README.md", "LICENSE.txt"]
15
- spec.files = `git ls-files | grep -Ev '^(spec|benchmarks|examples)'`.split("\n")
16
+ spec.files = `git ls-files | grep -Ev '^(spec|benchmarks|examples|\.rubocop\.yml)'`.split("\n")
17
+
18
+ github_root_uri = 'https://github.com/getsentry/sentry-ruby'
19
+ spec.homepage = "#{github_root_uri}/tree/#{spec.version}/#{spec.name}"
16
20
 
17
- spec.metadata["homepage_uri"] = spec.homepage
18
- spec.metadata["source_code_uri"] = spec.homepage
19
- spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/master/CHANGELOG.md"
21
+ spec.metadata = {
22
+ "homepage_uri" => spec.homepage,
23
+ "source_code_uri" => spec.homepage,
24
+ "changelog_uri" => "#{github_root_uri}/blob/#{spec.version}/CHANGELOG.md",
25
+ "bug_tracker_uri" => "#{github_root_uri}/issues",
26
+ "documentation_uri" => "http://www.rubydoc.info/gems/#{spec.name}/#{spec.version}"
27
+ }
20
28
 
21
29
  spec.require_paths = ["lib"]
22
30
 
23
- spec.add_dependency "concurrent-ruby", '~> 1.0', '>= 1.0.2'
31
+ spec.add_dependency "concurrent-ruby", "~> 1.0", ">= 1.0.2"
32
+ spec.add_dependency "bigdecimal"
24
33
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sentry-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.13.0
4
+ version: 5.21.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sentry Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-09 00:00:00.000000000 Z
11
+ date: 2024-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -30,6 +30,20 @@ dependencies:
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
32
  version: 1.0.2
33
+ - !ruby/object:Gem::Dependency
34
+ name: bigdecimal
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
33
47
  description: A gem that provides a client interface for the Sentry error logger
34
48
  email: accounts@sentry.io
35
49
  executables: []
@@ -50,7 +64,9 @@ files:
50
64
  - bin/console
51
65
  - bin/setup
52
66
  - lib/sentry-ruby.rb
67
+ - lib/sentry/attachment.rb
53
68
  - lib/sentry/background_worker.rb
69
+ - lib/sentry/backpressure_monitor.rb
54
70
  - lib/sentry/backtrace.rb
55
71
  - lib/sentry/baggage.rb
56
72
  - lib/sentry/breadcrumb.rb
@@ -61,18 +77,23 @@ files:
61
77
  - lib/sentry/configuration.rb
62
78
  - lib/sentry/core_ext/object/deep_dup.rb
63
79
  - lib/sentry/core_ext/object/duplicable.rb
80
+ - lib/sentry/cron/configuration.rb
64
81
  - lib/sentry/cron/monitor_check_ins.rb
65
82
  - lib/sentry/cron/monitor_config.rb
66
83
  - lib/sentry/cron/monitor_schedule.rb
67
84
  - lib/sentry/dsn.rb
68
85
  - lib/sentry/envelope.rb
86
+ - lib/sentry/envelope/item.rb
69
87
  - lib/sentry/error_event.rb
70
88
  - lib/sentry/event.rb
71
89
  - lib/sentry/exceptions.rb
90
+ - lib/sentry/faraday.rb
91
+ - lib/sentry/graphql.rb
72
92
  - lib/sentry/hub.rb
73
93
  - lib/sentry/integrable.rb
74
94
  - lib/sentry/interface.rb
75
95
  - lib/sentry/interfaces/exception.rb
96
+ - lib/sentry/interfaces/mechanism.rb
76
97
  - lib/sentry/interfaces/request.rb
77
98
  - lib/sentry/interfaces/single_exception.rb
78
99
  - lib/sentry/interfaces/stacktrace.rb
@@ -80,8 +101,19 @@ files:
80
101
  - lib/sentry/interfaces/threads.rb
81
102
  - lib/sentry/linecache.rb
82
103
  - lib/sentry/logger.rb
104
+ - lib/sentry/metrics.rb
105
+ - lib/sentry/metrics/aggregator.rb
106
+ - lib/sentry/metrics/configuration.rb
107
+ - lib/sentry/metrics/counter_metric.rb
108
+ - lib/sentry/metrics/distribution_metric.rb
109
+ - lib/sentry/metrics/gauge_metric.rb
110
+ - lib/sentry/metrics/local_aggregator.rb
111
+ - lib/sentry/metrics/metric.rb
112
+ - lib/sentry/metrics/set_metric.rb
113
+ - lib/sentry/metrics/timing.rb
83
114
  - lib/sentry/net/http.rb
84
115
  - lib/sentry/profiler.rb
116
+ - lib/sentry/profiler/helpers.rb
85
117
  - lib/sentry/propagation_context.rb
86
118
  - lib/sentry/puma.rb
87
119
  - lib/sentry/rack.rb
@@ -94,29 +126,37 @@ files:
94
126
  - lib/sentry/session_flusher.rb
95
127
  - lib/sentry/span.rb
96
128
  - lib/sentry/test_helper.rb
129
+ - lib/sentry/threaded_periodic_worker.rb
97
130
  - lib/sentry/transaction.rb
98
131
  - lib/sentry/transaction_event.rb
99
132
  - lib/sentry/transport.rb
100
133
  - lib/sentry/transport/configuration.rb
101
134
  - lib/sentry/transport/dummy_transport.rb
102
135
  - lib/sentry/transport/http_transport.rb
136
+ - lib/sentry/transport/spotlight_transport.rb
103
137
  - lib/sentry/utils/argument_checking_helper.rb
104
138
  - lib/sentry/utils/custom_inspection.rb
105
139
  - lib/sentry/utils/encoding_helper.rb
140
+ - lib/sentry/utils/env_helper.rb
106
141
  - lib/sentry/utils/exception_cause_chain.rb
142
+ - lib/sentry/utils/http_tracing.rb
107
143
  - lib/sentry/utils/logging_helper.rb
108
144
  - lib/sentry/utils/real_ip.rb
109
145
  - lib/sentry/utils/request_id.rb
146
+ - lib/sentry/vernier/output.rb
147
+ - lib/sentry/vernier/profiler.rb
110
148
  - lib/sentry/version.rb
111
149
  - sentry-ruby-core.gemspec
112
150
  - sentry-ruby.gemspec
113
- homepage: https://github.com/getsentry/sentry-ruby
151
+ homepage: https://github.com/getsentry/sentry-ruby/tree/5.21.0/sentry-ruby
114
152
  licenses:
115
153
  - MIT
116
154
  metadata:
117
- homepage_uri: https://github.com/getsentry/sentry-ruby
118
- source_code_uri: https://github.com/getsentry/sentry-ruby
119
- changelog_uri: https://github.com/getsentry/sentry-ruby/blob/master/CHANGELOG.md
155
+ homepage_uri: https://github.com/getsentry/sentry-ruby/tree/5.21.0/sentry-ruby
156
+ source_code_uri: https://github.com/getsentry/sentry-ruby/tree/5.21.0/sentry-ruby
157
+ changelog_uri: https://github.com/getsentry/sentry-ruby/blob/5.21.0/CHANGELOG.md
158
+ bug_tracker_uri: https://github.com/getsentry/sentry-ruby/issues
159
+ documentation_uri: http://www.rubydoc.info/gems/sentry-ruby/5.21.0
120
160
  post_install_message:
121
161
  rdoc_options: []
122
162
  require_paths:
@@ -132,7 +172,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
132
172
  - !ruby/object:Gem::Version
133
173
  version: '0'
134
174
  requirements: []
135
- rubygems_version: 3.1.6
175
+ rubygems_version: 3.5.16
136
176
  signing_key:
137
177
  specification_version: 4
138
178
  summary: A gem that provides a client interface for the Sentry error logger