sentry-ruby 5.16.1 → 5.18.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -0
  3. data/README.md +10 -10
  4. data/Rakefile +1 -1
  5. data/bin/console +1 -0
  6. data/lib/sentry/background_worker.rb +1 -1
  7. data/lib/sentry/backpressure_monitor.rb +2 -32
  8. data/lib/sentry/backtrace.rb +7 -3
  9. data/lib/sentry/check_in_event.rb +1 -1
  10. data/lib/sentry/client.rb +42 -9
  11. data/lib/sentry/configuration.rb +20 -12
  12. data/lib/sentry/cron/monitor_schedule.rb +1 -1
  13. data/lib/sentry/dsn.rb +1 -1
  14. data/lib/sentry/envelope.rb +18 -1
  15. data/lib/sentry/error_event.rb +2 -2
  16. data/lib/sentry/event.rb +8 -8
  17. data/lib/sentry/graphql.rb +9 -0
  18. data/lib/sentry/hub.rb +13 -2
  19. data/lib/sentry/integrable.rb +4 -0
  20. data/lib/sentry/interface.rb +1 -0
  21. data/lib/sentry/interfaces/exception.rb +5 -3
  22. data/lib/sentry/interfaces/mechanism.rb +20 -0
  23. data/lib/sentry/interfaces/request.rb +2 -2
  24. data/lib/sentry/interfaces/single_exception.rb +6 -4
  25. data/lib/sentry/interfaces/stacktrace_builder.rb +8 -0
  26. data/lib/sentry/metrics/aggregator.rb +248 -0
  27. data/lib/sentry/metrics/configuration.rb +47 -0
  28. data/lib/sentry/metrics/counter_metric.rb +25 -0
  29. data/lib/sentry/metrics/distribution_metric.rb +25 -0
  30. data/lib/sentry/metrics/gauge_metric.rb +35 -0
  31. data/lib/sentry/metrics/local_aggregator.rb +53 -0
  32. data/lib/sentry/metrics/metric.rb +19 -0
  33. data/lib/sentry/metrics/set_metric.rb +28 -0
  34. data/lib/sentry/metrics/timing.rb +43 -0
  35. data/lib/sentry/metrics.rb +56 -0
  36. data/lib/sentry/net/http.rb +2 -1
  37. data/lib/sentry/propagation_context.rb +9 -8
  38. data/lib/sentry/puma.rb +1 -1
  39. data/lib/sentry/rack/capture_exceptions.rb +14 -2
  40. data/lib/sentry/rake.rb +3 -1
  41. data/lib/sentry/redis.rb +2 -1
  42. data/lib/sentry/scope.rb +21 -26
  43. data/lib/sentry/session.rb +2 -2
  44. data/lib/sentry/session_flusher.rb +6 -38
  45. data/lib/sentry/span.rb +39 -5
  46. data/lib/sentry/test_helper.rb +1 -1
  47. data/lib/sentry/threaded_periodic_worker.rb +39 -0
  48. data/lib/sentry/transaction.rb +15 -14
  49. data/lib/sentry/transaction_event.rb +5 -0
  50. data/lib/sentry/transport/configuration.rb +0 -1
  51. data/lib/sentry/transport.rb +8 -22
  52. data/lib/sentry/utils/argument_checking_helper.rb +6 -0
  53. data/lib/sentry/utils/logging_helper.rb +0 -4
  54. data/lib/sentry/utils/real_ip.rb +1 -1
  55. data/lib/sentry/utils/request_id.rb +1 -1
  56. data/lib/sentry/version.rb +1 -1
  57. data/lib/sentry-ruby.rb +26 -3
  58. data/sentry-ruby.gemspec +1 -0
  59. metadata +29 -2
@@ -3,7 +3,7 @@
3
3
  module Sentry
4
4
  module Utils
5
5
  module RequestId
6
- REQUEST_ID_HEADERS = %w(action_dispatch.request_id HTTP_X_REQUEST_ID).freeze
6
+ REQUEST_ID_HEADERS = %w[action_dispatch.request_id HTTP_X_REQUEST_ID].freeze
7
7
 
8
8
  # Request ID based on ActionDispatch::RequestId
9
9
  def self.read_from(env)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sentry
4
- VERSION = "5.16.1"
4
+ VERSION = "5.18.0"
5
5
  end
data/lib/sentry-ruby.rb CHANGED
@@ -20,13 +20,15 @@ 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"
24
25
  require "sentry/backpressure_monitor"
25
26
  require "sentry/cron/monitor_check_ins"
27
+ require "sentry/metrics"
26
28
 
27
29
  [
28
30
  "sentry/rake",
29
- "sentry/rack",
31
+ "sentry/rack"
30
32
  ].each do |lib|
31
33
  begin
32
34
  require lib
@@ -77,6 +79,10 @@ module Sentry
77
79
  # @return [BackpressureMonitor, nil]
78
80
  attr_reader :backpressure_monitor
79
81
 
82
+ # @!attribute [r] metrics_aggregator
83
+ # @return [Metrics::Aggregator, nil]
84
+ attr_reader :metrics_aggregator
85
+
80
86
  ##### Patch Registration #####
81
87
 
82
88
  # @!visibility private
@@ -222,8 +228,9 @@ module Sentry
222
228
  Thread.current.thread_variable_set(THREAD_LOCAL, hub)
223
229
  @main_hub = hub
224
230
  @background_worker = Sentry::BackgroundWorker.new(config)
225
- @session_flusher = config.auto_session_tracking ? Sentry::SessionFlusher.new(config, client) : nil
231
+ @session_flusher = config.session_tracking? ? Sentry::SessionFlusher.new(config, client) : nil
226
232
  @backpressure_monitor = config.enable_backpressure_handling ? Sentry::BackpressureMonitor.new(config, client) : nil
233
+ @metrics_aggregator = config.metrics.enabled ? Sentry::Metrics::Aggregator.new(config, client) : nil
227
234
  exception_locals_tp.enable if config.include_local_variables
228
235
  at_exit { close }
229
236
  end
@@ -244,8 +251,14 @@ module Sentry
244
251
  @backpressure_monitor = nil
245
252
  end
246
253
 
254
+ if @metrics_aggregator
255
+ @metrics_aggregator.flush(force: true)
256
+ @metrics_aggregator.kill
257
+ @metrics_aggregator = nil
258
+ end
259
+
247
260
  if client = get_current_client
248
- client.transport.flush
261
+ client.flush
249
262
 
250
263
  if client.configuration.include_local_variables
251
264
  exception_locals_tp.disable
@@ -538,6 +551,15 @@ module Sentry
538
551
  get_current_hub.get_trace_propagation_headers
539
552
  end
540
553
 
554
+ # Returns the a Hash containing sentry-trace and baggage.
555
+ # Can be either from the currently active span or the propagation context.
556
+ #
557
+ # @return [String]
558
+ def get_trace_propagation_meta
559
+ return '' unless initialized?
560
+ get_current_hub.get_trace_propagation_meta
561
+ end
562
+
541
563
  # Continue an incoming trace from a rack env like hash.
542
564
  #
543
565
  # @param env [Hash]
@@ -578,3 +600,4 @@ end
578
600
  require "sentry/net/http"
579
601
  require "sentry/redis"
580
602
  require "sentry/puma"
603
+ require "sentry/graphql"
data/sentry-ruby.gemspec CHANGED
@@ -21,4 +21,5 @@ Gem::Specification.new do |spec|
21
21
  spec.require_paths = ["lib"]
22
22
 
23
23
  spec.add_dependency "concurrent-ruby", '~> 1.0', '>= 1.0.2'
24
+ spec.add_dependency "bigdecimal"
24
25
  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.16.1
4
+ version: 5.18.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: 2024-01-09 00:00:00.000000000 Z
11
+ date: 2024-06-25 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: []
@@ -71,10 +85,12 @@ files:
71
85
  - lib/sentry/error_event.rb
72
86
  - lib/sentry/event.rb
73
87
  - lib/sentry/exceptions.rb
88
+ - lib/sentry/graphql.rb
74
89
  - lib/sentry/hub.rb
75
90
  - lib/sentry/integrable.rb
76
91
  - lib/sentry/interface.rb
77
92
  - lib/sentry/interfaces/exception.rb
93
+ - lib/sentry/interfaces/mechanism.rb
78
94
  - lib/sentry/interfaces/request.rb
79
95
  - lib/sentry/interfaces/single_exception.rb
80
96
  - lib/sentry/interfaces/stacktrace.rb
@@ -82,6 +98,16 @@ files:
82
98
  - lib/sentry/interfaces/threads.rb
83
99
  - lib/sentry/linecache.rb
84
100
  - lib/sentry/logger.rb
101
+ - lib/sentry/metrics.rb
102
+ - lib/sentry/metrics/aggregator.rb
103
+ - lib/sentry/metrics/configuration.rb
104
+ - lib/sentry/metrics/counter_metric.rb
105
+ - lib/sentry/metrics/distribution_metric.rb
106
+ - lib/sentry/metrics/gauge_metric.rb
107
+ - lib/sentry/metrics/local_aggregator.rb
108
+ - lib/sentry/metrics/metric.rb
109
+ - lib/sentry/metrics/set_metric.rb
110
+ - lib/sentry/metrics/timing.rb
85
111
  - lib/sentry/net/http.rb
86
112
  - lib/sentry/profiler.rb
87
113
  - lib/sentry/propagation_context.rb
@@ -96,6 +122,7 @@ files:
96
122
  - lib/sentry/session_flusher.rb
97
123
  - lib/sentry/span.rb
98
124
  - lib/sentry/test_helper.rb
125
+ - lib/sentry/threaded_periodic_worker.rb
99
126
  - lib/sentry/transaction.rb
100
127
  - lib/sentry/transaction_event.rb
101
128
  - lib/sentry/transport.rb