sentry-ruby 5.16.1 → 5.20.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -0
  3. data/README.md +20 -10
  4. data/Rakefile +1 -1
  5. data/bin/console +1 -0
  6. data/lib/sentry/attachment.rb +40 -0
  7. data/lib/sentry/background_worker.rb +1 -1
  8. data/lib/sentry/backpressure_monitor.rb +2 -32
  9. data/lib/sentry/backtrace.rb +8 -6
  10. data/lib/sentry/baggage.rb +6 -6
  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 +61 -11
  14. data/lib/sentry/configuration.rb +53 -25
  15. data/lib/sentry/core_ext/object/deep_dup.rb +1 -1
  16. data/lib/sentry/cron/monitor_check_ins.rb +1 -1
  17. data/lib/sentry/cron/monitor_config.rb +1 -1
  18. data/lib/sentry/cron/monitor_schedule.rb +1 -1
  19. data/lib/sentry/dsn.rb +4 -4
  20. data/lib/sentry/envelope.rb +19 -2
  21. data/lib/sentry/error_event.rb +2 -2
  22. data/lib/sentry/event.rb +20 -18
  23. data/lib/sentry/faraday.rb +77 -0
  24. data/lib/sentry/graphql.rb +9 -0
  25. data/lib/sentry/hub.rb +23 -3
  26. data/lib/sentry/integrable.rb +4 -0
  27. data/lib/sentry/interface.rb +1 -0
  28. data/lib/sentry/interfaces/exception.rb +5 -3
  29. data/lib/sentry/interfaces/mechanism.rb +20 -0
  30. data/lib/sentry/interfaces/request.rb +7 -7
  31. data/lib/sentry/interfaces/single_exception.rb +7 -5
  32. data/lib/sentry/interfaces/stacktrace.rb +3 -1
  33. data/lib/sentry/interfaces/stacktrace_builder.rb +23 -2
  34. data/lib/sentry/logger.rb +1 -1
  35. data/lib/sentry/metrics/aggregator.rb +248 -0
  36. data/lib/sentry/metrics/configuration.rb +47 -0
  37. data/lib/sentry/metrics/counter_metric.rb +25 -0
  38. data/lib/sentry/metrics/distribution_metric.rb +25 -0
  39. data/lib/sentry/metrics/gauge_metric.rb +35 -0
  40. data/lib/sentry/metrics/local_aggregator.rb +53 -0
  41. data/lib/sentry/metrics/metric.rb +19 -0
  42. data/lib/sentry/metrics/set_metric.rb +28 -0
  43. data/lib/sentry/metrics/timing.rb +43 -0
  44. data/lib/sentry/metrics.rb +56 -0
  45. data/lib/sentry/net/http.rb +18 -39
  46. data/lib/sentry/profiler.rb +19 -20
  47. data/lib/sentry/propagation_context.rb +10 -9
  48. data/lib/sentry/puma.rb +1 -1
  49. data/lib/sentry/rack/capture_exceptions.rb +15 -3
  50. data/lib/sentry/rack.rb +2 -2
  51. data/lib/sentry/rake.rb +4 -2
  52. data/lib/sentry/redis.rb +2 -1
  53. data/lib/sentry/release_detector.rb +4 -4
  54. data/lib/sentry/scope.rb +36 -26
  55. data/lib/sentry/session.rb +2 -2
  56. data/lib/sentry/session_flusher.rb +7 -39
  57. data/lib/sentry/span.rb +46 -5
  58. data/lib/sentry/test_helper.rb +3 -2
  59. data/lib/sentry/threaded_periodic_worker.rb +39 -0
  60. data/lib/sentry/transaction.rb +17 -15
  61. data/lib/sentry/transaction_event.rb +6 -1
  62. data/lib/sentry/transport/configuration.rb +0 -1
  63. data/lib/sentry/transport/http_transport.rb +12 -12
  64. data/lib/sentry/transport.rb +18 -26
  65. data/lib/sentry/utils/argument_checking_helper.rb +6 -0
  66. data/lib/sentry/utils/env_helper.rb +21 -0
  67. data/lib/sentry/utils/http_tracing.rb +41 -0
  68. data/lib/sentry/utils/logging_helper.rb +0 -4
  69. data/lib/sentry/utils/real_ip.rb +2 -2
  70. data/lib/sentry/utils/request_id.rb +1 -1
  71. data/lib/sentry/version.rb +1 -1
  72. data/lib/sentry-ruby.rb +34 -3
  73. data/sentry-ruby-core.gemspec +1 -1
  74. data/sentry-ruby.gemspec +13 -6
  75. metadata +40 -7
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
@@ -205,6 +211,13 @@ module Sentry
205
211
  get_current_scope.set_context(*args)
206
212
  end
207
213
 
214
+ # @!method add_attachment
215
+ # @!macro add_attachment
216
+ def add_attachment(**opts)
217
+ return unless initialized?
218
+ get_current_scope.add_attachment(**opts)
219
+ end
220
+
208
221
  ##### Main APIs #####
209
222
 
210
223
  # Initializes the SDK with given configuration.
@@ -222,8 +235,9 @@ module Sentry
222
235
  Thread.current.thread_variable_set(THREAD_LOCAL, hub)
223
236
  @main_hub = hub
224
237
  @background_worker = Sentry::BackgroundWorker.new(config)
225
- @session_flusher = config.auto_session_tracking ? Sentry::SessionFlusher.new(config, client) : nil
238
+ @session_flusher = config.session_tracking? ? Sentry::SessionFlusher.new(config, client) : nil
226
239
  @backpressure_monitor = config.enable_backpressure_handling ? Sentry::BackpressureMonitor.new(config, client) : nil
240
+ @metrics_aggregator = config.metrics.enabled ? Sentry::Metrics::Aggregator.new(config, client) : nil
227
241
  exception_locals_tp.enable if config.include_local_variables
228
242
  at_exit { close }
229
243
  end
@@ -244,8 +258,14 @@ module Sentry
244
258
  @backpressure_monitor = nil
245
259
  end
246
260
 
261
+ if @metrics_aggregator
262
+ @metrics_aggregator.flush(force: true)
263
+ @metrics_aggregator.kill
264
+ @metrics_aggregator = nil
265
+ end
266
+
247
267
  if client = get_current_client
248
- client.transport.flush
268
+ client.flush
249
269
 
250
270
  if client.configuration.include_local_variables
251
271
  exception_locals_tp.disable
@@ -538,6 +558,15 @@ module Sentry
538
558
  get_current_hub.get_trace_propagation_headers
539
559
  end
540
560
 
561
+ # Returns the a Hash containing sentry-trace and baggage.
562
+ # Can be either from the currently active span or the propagation context.
563
+ #
564
+ # @return [String]
565
+ def get_trace_propagation_meta
566
+ return "" unless initialized?
567
+ get_current_hub.get_trace_propagation_meta
568
+ end
569
+
541
570
  # Continue an incoming trace from a rack env like hash.
542
571
  #
543
572
  # @param env [Hash]
@@ -578,3 +607,5 @@ end
578
607
  require "sentry/net/http"
579
608
  require "sentry/redis"
580
609
  require "sentry/puma"
610
+ require "sentry/graphql"
611
+ require "sentry/faraday"
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
12
12
  spec.platform = Gem::Platform::RUBY
13
13
  spec.required_ruby_version = '>= 2.4'
14
14
  spec.extra_rdoc_files = ["README.md", "LICENSE.txt"]
15
- spec.files = `git ls-files | grep -Ev '^(spec|benchmarks|examples)'`.split("\n")
15
+ spec.files = `git ls-files | grep -Ev '^(spec|benchmarks|examples|\.rubocop\.yml)'`.split("\n")
16
16
 
17
17
  spec.metadata["homepage_uri"] = spec.homepage
18
18
  spec.metadata["source_code_uri"] = spec.homepage
data/sentry-ruby.gemspec CHANGED
@@ -7,18 +7,25 @@ Gem::Specification.new do |spec|
7
7
  spec.description = spec.summary = "A gem that provides a client interface for the Sentry error logger"
8
8
  spec.email = "accounts@sentry.io"
9
9
  spec.license = 'MIT'
10
- spec.homepage = "https://github.com/getsentry/sentry-ruby"
11
10
 
12
11
  spec.platform = Gem::Platform::RUBY
13
12
  spec.required_ruby_version = '>= 2.4'
14
13
  spec.extra_rdoc_files = ["README.md", "LICENSE.txt"]
15
- spec.files = `git ls-files | grep -Ev '^(spec|benchmarks|examples)'`.split("\n")
14
+ spec.files = `git ls-files | grep -Ev '^(spec|benchmarks|examples|\.rubocop\.yml)'`.split("\n")
16
15
 
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"
16
+ github_root_uri = 'https://github.com/getsentry/sentry-ruby'
17
+ spec.homepage = "#{github_root_uri}/tree/#{spec.version}/#{spec.name}"
18
+
19
+ spec.metadata = {
20
+ "homepage_uri" => spec.homepage,
21
+ "source_code_uri" => spec.homepage,
22
+ "changelog_uri" => "#{github_root_uri}/blob/#{spec.version}/CHANGELOG.md",
23
+ "bug_tracker_uri" => "#{github_root_uri}/issues",
24
+ "documentation_uri" => "http://www.rubydoc.info/gems/#{spec.name}/#{spec.version}"
25
+ }
20
26
 
21
27
  spec.require_paths = ["lib"]
22
28
 
23
- spec.add_dependency "concurrent-ruby", '~> 1.0', '>= 1.0.2'
29
+ spec.add_dependency "concurrent-ruby", "~> 1.0", ">= 1.0.2"
30
+ spec.add_dependency "bigdecimal"
24
31
  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.20.1
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-09-27 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,6 +64,7 @@ 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
54
69
  - lib/sentry/backpressure_monitor.rb
55
70
  - lib/sentry/backtrace.rb
@@ -71,10 +86,13 @@ files:
71
86
  - lib/sentry/error_event.rb
72
87
  - lib/sentry/event.rb
73
88
  - lib/sentry/exceptions.rb
89
+ - lib/sentry/faraday.rb
90
+ - lib/sentry/graphql.rb
74
91
  - lib/sentry/hub.rb
75
92
  - lib/sentry/integrable.rb
76
93
  - lib/sentry/interface.rb
77
94
  - lib/sentry/interfaces/exception.rb
95
+ - lib/sentry/interfaces/mechanism.rb
78
96
  - lib/sentry/interfaces/request.rb
79
97
  - lib/sentry/interfaces/single_exception.rb
80
98
  - lib/sentry/interfaces/stacktrace.rb
@@ -82,6 +100,16 @@ files:
82
100
  - lib/sentry/interfaces/threads.rb
83
101
  - lib/sentry/linecache.rb
84
102
  - lib/sentry/logger.rb
103
+ - lib/sentry/metrics.rb
104
+ - lib/sentry/metrics/aggregator.rb
105
+ - lib/sentry/metrics/configuration.rb
106
+ - lib/sentry/metrics/counter_metric.rb
107
+ - lib/sentry/metrics/distribution_metric.rb
108
+ - lib/sentry/metrics/gauge_metric.rb
109
+ - lib/sentry/metrics/local_aggregator.rb
110
+ - lib/sentry/metrics/metric.rb
111
+ - lib/sentry/metrics/set_metric.rb
112
+ - lib/sentry/metrics/timing.rb
85
113
  - lib/sentry/net/http.rb
86
114
  - lib/sentry/profiler.rb
87
115
  - lib/sentry/propagation_context.rb
@@ -96,6 +124,7 @@ files:
96
124
  - lib/sentry/session_flusher.rb
97
125
  - lib/sentry/span.rb
98
126
  - lib/sentry/test_helper.rb
127
+ - lib/sentry/threaded_periodic_worker.rb
99
128
  - lib/sentry/transaction.rb
100
129
  - lib/sentry/transaction_event.rb
101
130
  - lib/sentry/transport.rb
@@ -106,20 +135,24 @@ files:
106
135
  - lib/sentry/utils/argument_checking_helper.rb
107
136
  - lib/sentry/utils/custom_inspection.rb
108
137
  - lib/sentry/utils/encoding_helper.rb
138
+ - lib/sentry/utils/env_helper.rb
109
139
  - lib/sentry/utils/exception_cause_chain.rb
140
+ - lib/sentry/utils/http_tracing.rb
110
141
  - lib/sentry/utils/logging_helper.rb
111
142
  - lib/sentry/utils/real_ip.rb
112
143
  - lib/sentry/utils/request_id.rb
113
144
  - lib/sentry/version.rb
114
145
  - sentry-ruby-core.gemspec
115
146
  - sentry-ruby.gemspec
116
- homepage: https://github.com/getsentry/sentry-ruby
147
+ homepage: https://github.com/getsentry/sentry-ruby/tree/5.20.1/sentry-ruby
117
148
  licenses:
118
149
  - MIT
119
150
  metadata:
120
- homepage_uri: https://github.com/getsentry/sentry-ruby
121
- source_code_uri: https://github.com/getsentry/sentry-ruby
122
- changelog_uri: https://github.com/getsentry/sentry-ruby/blob/master/CHANGELOG.md
151
+ homepage_uri: https://github.com/getsentry/sentry-ruby/tree/5.20.1/sentry-ruby
152
+ source_code_uri: https://github.com/getsentry/sentry-ruby/tree/5.20.1/sentry-ruby
153
+ changelog_uri: https://github.com/getsentry/sentry-ruby/blob/5.20.1/CHANGELOG.md
154
+ bug_tracker_uri: https://github.com/getsentry/sentry-ruby/issues
155
+ documentation_uri: http://www.rubydoc.info/gems/sentry-ruby/5.20.1
123
156
  post_install_message:
124
157
  rdoc_options: []
125
158
  require_paths:
@@ -135,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
168
  - !ruby/object:Gem::Version
136
169
  version: '0'
137
170
  requirements: []
138
- rubygems_version: 3.1.6
171
+ rubygems_version: 3.5.16
139
172
  signing_key:
140
173
  specification_version: 4
141
174
  summary: A gem that provides a client interface for the Sentry error logger