sentry-ruby 5.27.0 → 5.27.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b489d374f24123e3e62626462b08bfa3ea1d0a8c03f7332dd8d353860b065bdf
4
- data.tar.gz: f6548949011e59234ce7b90c04f6a3cc95fb0876e93ac598907f6fac7ccd4560
3
+ metadata.gz: e22f6e466bbb07f16fcec111522500b84246820d9cdfbbbe055fab491de4a5b1
4
+ data.tar.gz: fae1030444c280ce570da19bad7e922fa734838bd7b5e16620bba19d21137cd1
5
5
  SHA512:
6
- metadata.gz: 0f02b67848b924a4fe9827ca5abfb3010035ebe41194d0859bd412b1effce07018c261fd59b1eb28efb9721452985ef6895efb4ba5fa297d82fc58c880d1c5ae
7
- data.tar.gz: 1a8f620b58693aa0b30a81b9fdbdd94f78761c519fb49bbb9a57f6bb82296de8d248f3e537718ebb5325f730abac55da0ebd446db86d9e196f56532db1414097
6
+ metadata.gz: 9872cecd24210d7085c9a7f3e8b58daba0d630f7a4c37ba8b23db062b077ad6c388544e6bde57cf2383ab7e81839501272a52fc0499c0320acd085dd1f4010a0
7
+ data.tar.gz: 99e0504418c5b0ecddc3a84558935076c50f948937a5545c91451dec1bfa885a078f5141ad38290d8bab082a19ed355010bf945ca29faa25ca9f086a6777ba96
data/lib/sentry/client.rb CHANGED
@@ -195,9 +195,10 @@ module Sentry
195
195
  def event_from_log(message, level:, **options)
196
196
  return unless configuration.sending_allowed?
197
197
 
198
- attributes = options.reject { |k, _| k == :level || k == :severity }
198
+ attributes = options.reject { |k, _| k == :level || k == :severity || k == :origin }
199
+ origin = options[:origin]
199
200
 
200
- LogEvent.new(level: level, body: message, attributes: attributes)
201
+ LogEvent.new(level: level, body: message, attributes: attributes, origin: origin)
201
202
  end
202
203
 
203
204
  # Initializes an Event object with the given Transaction object.
@@ -29,9 +29,12 @@ module Sentry
29
29
  "sentry.address" => :server_name,
30
30
  "sentry.sdk.name" => :sdk_name,
31
31
  "sentry.sdk.version" => :sdk_version,
32
- "sentry.message.template" => :template
32
+ "sentry.message.template" => :template,
33
+ "sentry.origin" => :origin
33
34
  }
34
35
 
36
+ PARAMETER_PREFIX = "sentry.message.parameter"
37
+
35
38
  USER_ATTRIBUTES = {
36
39
  "user.id" => :user_id,
37
40
  "user.name" => :user_username,
@@ -40,7 +43,7 @@ module Sentry
40
43
 
41
44
  LEVELS = %i[trace debug info warn error fatal].freeze
42
45
 
43
- attr_accessor :level, :body, :template, :attributes, :user
46
+ attr_accessor :level, :body, :template, :attributes, :user, :origin
44
47
 
45
48
  attr_reader :configuration, *(SERIALIZEABLE_ATTRIBUTES - %i[level body attributes])
46
49
 
@@ -51,6 +54,7 @@ module Sentry
51
54
  parent_span_id
52
55
  sdk_name
53
56
  sdk_version
57
+ template
54
58
  timestamp
55
59
  trace_id
56
60
  user_id
@@ -79,6 +83,7 @@ module Sentry
79
83
  @template = @body if is_template?
80
84
  @attributes = options[:attributes] || DEFAULT_ATTRIBUTES
81
85
  @user = options[:user] || {}
86
+ @origin = options[:origin]
82
87
  @contexts = {}
83
88
  end
84
89
 
@@ -146,6 +151,10 @@ module Sentry
146
151
  user[:email]
147
152
  end
148
153
 
154
+ def serialize_template
155
+ template if has_parameters?
156
+ end
157
+
149
158
  def serialize_attributes
150
159
  hash = {}
151
160
 
@@ -185,11 +194,11 @@ module Sentry
185
194
 
186
195
  if parameters.is_a?(Hash)
187
196
  parameters.each do |key, value|
188
- attributes["sentry.message.parameter.#{key}"] = value
197
+ attributes["#{PARAMETER_PREFIX}.#{key}"] = value
189
198
  end
190
199
  else
191
200
  parameters.each_with_index do |param, index|
192
- attributes["sentry.message.parameter.#{index}"] = param
201
+ attributes["#{PARAMETER_PREFIX}.#{index}"] = param
193
202
  end
194
203
  end
195
204
  end
@@ -202,5 +211,9 @@ module Sentry
202
211
  def is_template?
203
212
  body.include?("%s") || TOKEN_REGEXP.match?(body)
204
213
  end
214
+
215
+ def has_parameters?
216
+ attributes.keys.any? { |key| key.start_with?(PARAMETER_PREFIX) }
217
+ end
205
218
  end
206
219
  end
@@ -12,11 +12,16 @@ module Sentry
12
12
  4 => :fatal
13
13
  }.freeze
14
14
 
15
+ ORIGIN = "auto.logger.ruby.std_logger"
16
+
15
17
  def add(severity, message = nil, progname = nil, &block)
16
18
  result = super
17
19
 
18
20
  return unless Sentry.initialized? && Sentry.get_current_hub
19
21
 
22
+ # Only process logs that meet or exceed the logger's level
23
+ return result if severity < level
24
+
20
25
  # exclude sentry SDK logs -- to prevent recursive log action,
21
26
  # do not process internal logs again
22
27
  if message.nil? && progname != Sentry::Logger::PROGNAME
@@ -32,7 +37,7 @@ module Sentry
32
37
  message = message.to_s.strip
33
38
 
34
39
  if !message.nil? && message != Sentry::Logger::PROGNAME && method = SEVERITY_MAP[severity]
35
- Sentry.logger.send(method, message)
40
+ Sentry.logger.send(method, message, origin: ORIGIN)
36
41
  end
37
42
  end
38
43
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sentry
4
- VERSION = "5.27.0"
4
+ VERSION = "5.27.1"
5
5
  end
data/lib/sentry-ruby.rb CHANGED
@@ -500,6 +500,7 @@ module Sentry
500
500
  # @param [Hash] options Extra log event options
501
501
  # @option options [Symbol] level The log level (:trace, :debug, :info, :warn, :error, :fatal)
502
502
  # @option options [Integer] severity The severity number according to the Sentry Logs Protocol
503
+ # @option options [String] origin The origin of the log event (e.g., "auto.db.rails", "manual")
503
504
  # @option options [Hash] Additional attributes to include with the log
504
505
  #
505
506
  # @example Direct usage (prefer using Sentry.logger instead)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sentry-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.27.0
4
+ version: 5.27.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sentry Team
@@ -158,15 +158,15 @@ files:
158
158
  - lib/sentry/version.rb
159
159
  - sentry-ruby-core.gemspec
160
160
  - sentry-ruby.gemspec
161
- homepage: https://github.com/getsentry/sentry-ruby/tree/5.27.0/sentry-ruby
161
+ homepage: https://github.com/getsentry/sentry-ruby/tree/5.27.1/sentry-ruby
162
162
  licenses:
163
163
  - MIT
164
164
  metadata:
165
- homepage_uri: https://github.com/getsentry/sentry-ruby/tree/5.27.0/sentry-ruby
166
- source_code_uri: https://github.com/getsentry/sentry-ruby/tree/5.27.0/sentry-ruby
167
- changelog_uri: https://github.com/getsentry/sentry-ruby/blob/5.27.0/CHANGELOG.md
165
+ homepage_uri: https://github.com/getsentry/sentry-ruby/tree/5.27.1/sentry-ruby
166
+ source_code_uri: https://github.com/getsentry/sentry-ruby/tree/5.27.1/sentry-ruby
167
+ changelog_uri: https://github.com/getsentry/sentry-ruby/blob/5.27.1/CHANGELOG.md
168
168
  bug_tracker_uri: https://github.com/getsentry/sentry-ruby/issues
169
- documentation_uri: http://www.rubydoc.info/gems/sentry-ruby/5.27.0
169
+ documentation_uri: http://www.rubydoc.info/gems/sentry-ruby/5.27.1
170
170
  rdoc_options: []
171
171
  require_paths:
172
172
  - lib