sentry-ruby 5.23.0 → 5.26.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/.rspec +3 -1
- data/README.md +11 -6
- data/Rakefile +7 -11
- data/lib/sentry/background_worker.rb +2 -3
- data/lib/sentry/backpressure_monitor.rb +1 -1
- data/lib/sentry/breadcrumb.rb +5 -4
- data/lib/sentry/check_in_event.rb +2 -1
- data/lib/sentry/client.rb +84 -4
- data/lib/sentry/configuration.rb +37 -2
- data/lib/sentry/envelope/item.rb +1 -1
- data/lib/sentry/event.rb +2 -1
- data/lib/sentry/hub.rb +10 -0
- data/lib/sentry/interfaces/request.rb +1 -1
- data/lib/sentry/log_event.rb +206 -0
- data/lib/sentry/log_event_buffer.rb +75 -0
- data/lib/sentry/metrics/aggregator.rb +1 -1
- data/lib/sentry/profiler.rb +3 -2
- data/lib/sentry/propagation_context.rb +4 -4
- data/lib/sentry/scope.rb +13 -3
- data/lib/sentry/session_flusher.rb +1 -1
- data/lib/sentry/span.rb +4 -3
- data/lib/sentry/std_lib_logger.rb +50 -0
- data/lib/sentry/structured_logger.rb +138 -0
- data/lib/sentry/test_helper.rb +7 -0
- data/lib/sentry/threaded_periodic_worker.rb +3 -3
- data/lib/sentry/transaction.rb +1 -7
- data/lib/sentry/transport.rb +16 -8
- data/lib/sentry/utils/logging_helper.rb +10 -3
- data/lib/sentry/utils/uuid.rb +13 -0
- data/lib/sentry/vernier/profiler.rb +3 -2
- data/lib/sentry/version.rb +1 -1
- data/lib/sentry-ruby.rb +63 -4
- metadata +14 -9
data/lib/sentry-ruby.rb
CHANGED
@@ -11,7 +11,7 @@ require "sentry/utils/argument_checking_helper"
|
|
11
11
|
require "sentry/utils/encoding_helper"
|
12
12
|
require "sentry/utils/logging_helper"
|
13
13
|
require "sentry/configuration"
|
14
|
-
require "sentry/
|
14
|
+
require "sentry/structured_logger"
|
15
15
|
require "sentry/event"
|
16
16
|
require "sentry/error_event"
|
17
17
|
require "sentry/transaction_event"
|
@@ -54,6 +54,7 @@ module Sentry
|
|
54
54
|
|
55
55
|
GLOBALS = %i[
|
56
56
|
main_hub
|
57
|
+
logger
|
57
58
|
session_flusher
|
58
59
|
backpressure_monitor
|
59
60
|
metrics_aggregator
|
@@ -138,7 +139,7 @@ module Sentry
|
|
138
139
|
# @param version [String] version of the integration
|
139
140
|
def register_integration(name, version)
|
140
141
|
if initialized?
|
141
|
-
|
142
|
+
sdk_logger.warn(LOGGER_PROGNAME) do
|
142
143
|
<<~MSG
|
143
144
|
Integration '#{name}' is loaded after the SDK is initialized, which can cause unexpected behavior. Please make sure all integrations are loaded before SDK initialization.
|
144
145
|
MSG
|
@@ -238,6 +239,7 @@ module Sentry
|
|
238
239
|
def init(&block)
|
239
240
|
config = Configuration.new
|
240
241
|
yield(config) if block_given?
|
242
|
+
|
241
243
|
config.detect_release
|
242
244
|
apply_patches(config)
|
243
245
|
config.validate
|
@@ -489,6 +491,25 @@ module Sentry
|
|
489
491
|
get_current_hub.capture_check_in(slug, status, **options)
|
490
492
|
end
|
491
493
|
|
494
|
+
# Captures a log event and sends it to Sentry via the currently active hub.
|
495
|
+
# This is the underlying method used by the StructuredLogger class.
|
496
|
+
#
|
497
|
+
# @param message [String] the log message
|
498
|
+
# @param [Hash] options Extra log event options
|
499
|
+
# @option options [Symbol] level The log level (:trace, :debug, :info, :warn, :error, :fatal)
|
500
|
+
# @option options [Integer] severity The severity number according to the Sentry Logs Protocol
|
501
|
+
# @option options [Hash] Additional attributes to include with the log
|
502
|
+
#
|
503
|
+
# @example Direct usage (prefer using Sentry.logger instead)
|
504
|
+
# Sentry.capture_log("User logged in", level: :info, user_id: 123)
|
505
|
+
#
|
506
|
+
# @see https://develop.sentry.dev/sdk/telemetry/logs/ Sentry SDK Telemetry Logs Protocol
|
507
|
+
# @return [LogEvent, nil] The created log event or nil if logging is disabled
|
508
|
+
def capture_log(message, **options)
|
509
|
+
return unless initialized?
|
510
|
+
get_current_hub.capture_log_event(message, **options)
|
511
|
+
end
|
512
|
+
|
492
513
|
# Takes or initializes a new Sentry::Transaction and makes a sampling decision for it.
|
493
514
|
#
|
494
515
|
# @return [Transaction, nil]
|
@@ -593,6 +614,43 @@ module Sentry
|
|
593
614
|
get_current_hub.continue_trace(env, **options)
|
594
615
|
end
|
595
616
|
|
617
|
+
# Returns the structured logger instance that implements Sentry's SDK telemetry logs protocol.
|
618
|
+
#
|
619
|
+
# This logger is only available when logs are enabled in the configuration.
|
620
|
+
#
|
621
|
+
# @example Enable logs in configuration
|
622
|
+
# Sentry.init do |config|
|
623
|
+
# config.dsn = "YOUR_DSN"
|
624
|
+
# config.enable_logs = true
|
625
|
+
# end
|
626
|
+
#
|
627
|
+
# @example Basic usage
|
628
|
+
# Sentry.logger.info("User logged in successfully", user_id: 123)
|
629
|
+
# Sentry.logger.error("Failed to process payment",
|
630
|
+
# transaction_id: "tx_123",
|
631
|
+
# error_code: "PAYMENT_FAILED"
|
632
|
+
# )
|
633
|
+
#
|
634
|
+
# @see https://develop.sentry.dev/sdk/telemetry/logs/ Sentry SDK Telemetry Logs Protocol
|
635
|
+
#
|
636
|
+
# @return [StructuredLogger, nil] The structured logger instance or nil if logs are disabled
|
637
|
+
def logger
|
638
|
+
@logger ||=
|
639
|
+
if configuration.enable_logs
|
640
|
+
# Initialize the public-facing Structured Logger if logs are enabled
|
641
|
+
# This creates a StructuredLogger instance that implements Sentry's SDK telemetry logs protocol
|
642
|
+
# @see https://develop.sentry.dev/sdk/telemetry/logs/
|
643
|
+
StructuredLogger.new(configuration)
|
644
|
+
else
|
645
|
+
warn <<~STR
|
646
|
+
[sentry] `Sentry.logger` will no longer be used as internal SDK logger when `enable_logs` feature is turned on.
|
647
|
+
Use Sentry.configuration.sdk_logger for SDK-specific logging needs."
|
648
|
+
STR
|
649
|
+
|
650
|
+
configuration.sdk_logger
|
651
|
+
end
|
652
|
+
end
|
653
|
+
|
596
654
|
##### Helpers #####
|
597
655
|
|
598
656
|
# @!visibility private
|
@@ -604,8 +662,8 @@ module Sentry
|
|
604
662
|
end
|
605
663
|
|
606
664
|
# @!visibility private
|
607
|
-
def
|
608
|
-
configuration.
|
665
|
+
def sdk_logger
|
666
|
+
configuration.sdk_logger
|
609
667
|
end
|
610
668
|
|
611
669
|
# @!visibility private
|
@@ -632,3 +690,4 @@ require "sentry/puma"
|
|
632
690
|
require "sentry/graphql"
|
633
691
|
require "sentry/faraday"
|
634
692
|
require "sentry/excon"
|
693
|
+
require "sentry/std_lib_logger"
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sentry-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.26.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sentry Team
|
8
8
|
bindir: bin
|
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: concurrent-ruby
|
@@ -48,8 +48,8 @@ email: accounts@sentry.io
|
|
48
48
|
executables: []
|
49
49
|
extensions: []
|
50
50
|
extra_rdoc_files:
|
51
|
-
- README.md
|
52
51
|
- LICENSE.txt
|
52
|
+
- README.md
|
53
53
|
files:
|
54
54
|
- ".gitignore"
|
55
55
|
- ".rspec"
|
@@ -101,6 +101,8 @@ files:
|
|
101
101
|
- lib/sentry/interfaces/stacktrace_builder.rb
|
102
102
|
- lib/sentry/interfaces/threads.rb
|
103
103
|
- lib/sentry/linecache.rb
|
104
|
+
- lib/sentry/log_event.rb
|
105
|
+
- lib/sentry/log_event_buffer.rb
|
104
106
|
- lib/sentry/logger.rb
|
105
107
|
- lib/sentry/metrics.rb
|
106
108
|
- lib/sentry/metrics/aggregator.rb
|
@@ -127,6 +129,8 @@ files:
|
|
127
129
|
- lib/sentry/session.rb
|
128
130
|
- lib/sentry/session_flusher.rb
|
129
131
|
- lib/sentry/span.rb
|
132
|
+
- lib/sentry/std_lib_logger.rb
|
133
|
+
- lib/sentry/structured_logger.rb
|
130
134
|
- lib/sentry/test_helper.rb
|
131
135
|
- lib/sentry/threaded_periodic_worker.rb
|
132
136
|
- lib/sentry/transaction.rb
|
@@ -145,20 +149,21 @@ files:
|
|
145
149
|
- lib/sentry/utils/logging_helper.rb
|
146
150
|
- lib/sentry/utils/real_ip.rb
|
147
151
|
- lib/sentry/utils/request_id.rb
|
152
|
+
- lib/sentry/utils/uuid.rb
|
148
153
|
- lib/sentry/vernier/output.rb
|
149
154
|
- lib/sentry/vernier/profiler.rb
|
150
155
|
- lib/sentry/version.rb
|
151
156
|
- sentry-ruby-core.gemspec
|
152
157
|
- sentry-ruby.gemspec
|
153
|
-
homepage: https://github.com/getsentry/sentry-ruby/tree/5.
|
158
|
+
homepage: https://github.com/getsentry/sentry-ruby/tree/5.26.0/sentry-ruby
|
154
159
|
licenses:
|
155
160
|
- MIT
|
156
161
|
metadata:
|
157
|
-
homepage_uri: https://github.com/getsentry/sentry-ruby/tree/5.
|
158
|
-
source_code_uri: https://github.com/getsentry/sentry-ruby/tree/5.
|
159
|
-
changelog_uri: https://github.com/getsentry/sentry-ruby/blob/5.
|
162
|
+
homepage_uri: https://github.com/getsentry/sentry-ruby/tree/5.26.0/sentry-ruby
|
163
|
+
source_code_uri: https://github.com/getsentry/sentry-ruby/tree/5.26.0/sentry-ruby
|
164
|
+
changelog_uri: https://github.com/getsentry/sentry-ruby/blob/5.26.0/CHANGELOG.md
|
160
165
|
bug_tracker_uri: https://github.com/getsentry/sentry-ruby/issues
|
161
|
-
documentation_uri: http://www.rubydoc.info/gems/sentry-ruby/5.
|
166
|
+
documentation_uri: http://www.rubydoc.info/gems/sentry-ruby/5.26.0
|
162
167
|
rdoc_options: []
|
163
168
|
require_paths:
|
164
169
|
- lib
|
@@ -173,7 +178,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
173
178
|
- !ruby/object:Gem::Version
|
174
179
|
version: '0'
|
175
180
|
requirements: []
|
176
|
-
rubygems_version: 3.6.
|
181
|
+
rubygems_version: 3.6.7
|
177
182
|
specification_version: 4
|
178
183
|
summary: A gem that provides a client interface for the Sentry error logger
|
179
184
|
test_files: []
|