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.
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/logger"
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
- logger.warn(LOGGER_PROGNAME) do
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 logger
608
- configuration.logger
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.23.0
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: 2025-03-11 00:00:00.000000000 Z
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.23.0/sentry-ruby
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.23.0/sentry-ruby
158
- source_code_uri: https://github.com/getsentry/sentry-ruby/tree/5.23.0/sentry-ruby
159
- changelog_uri: https://github.com/getsentry/sentry-ruby/blob/5.23.0/CHANGELOG.md
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.23.0
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.2
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: []