appsignal 4.2.3-java → 4.3.0-java

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: 784861d0e654bc150f7aa6a6b7770d157ae56cb539102c3be3d43a74f23cb6d2
4
- data.tar.gz: 41664ff55a4afcf2b0d2bf8f0c5869e72490998305450169095020b48b33d7b9
3
+ metadata.gz: ad308b372920378c65259925e4fd0afd49223322dec0c6c8fc8faf6595435555
4
+ data.tar.gz: ccfb167b163279e59d1e1dfacc4e95b16577828d2b6b57b136ec85a92f26e4d6
5
5
  SHA512:
6
- metadata.gz: f818ffac31f93c26fb2f47731868c3c705687fef154bb8814e768abc2f02c42d2873e84c280f4661de5aa5ff2f2b49aa1af7c9967ca868d9e075d4873a9fbda8
7
- data.tar.gz: 37fc851eda0c8e730ba962239d6962cc1939bfb0109f7fd0c372a8635381fd986aeb4ec12711b5f82c7ca861b53c23ca73893b566449442bd3da1e6e5a93fe0d
6
+ metadata.gz: 7e77413d1932a70775f439ff79f03a1da817ad28c9fa8104a759aedb1007e60c2b2fba04756071683d9df8be088c1a6924b2858093b384c5ba9138cd7ac4da4f
7
+ data.tar.gz: 79c5a466dc6b9c162db83488a506add62ed1cf189d5bec4021a530b5cf82cd23c60ec05537ba04043c4b9565e479cb0e8c28e46228f7a9e319404fe41a6ca9fb
data/CHANGELOG.md CHANGED
@@ -1,5 +1,72 @@
1
1
  # AppSignal for Ruby gem Changelog
2
2
 
3
+ ## 4.3.0
4
+
5
+ _Published on 2024-12-20._
6
+
7
+ ### Added
8
+
9
+ - Add logger broadcasting. This change implements an alternative within `Appsignal::Logger` to `ActiveSupport::BroadcastLogger`, following the same interface. This enables a proper workaround to the issues with `ActiveSupport::BroadcastLogger` (([#49745](https://github.com/rails/rails/issues/49745), [#51883](https://github.com/rails/rails/issues/51883))) when used alongside tagged logging.
10
+
11
+ For example, to use tagged logging both in logs emitted by the default `Rails.logger` and in logs sent to AppSignal, replace the `Rails.logger` with an AppSignal logger that broadcasts to the default `Rails.logger`:
12
+
13
+ ```ruby
14
+ appsignal_logger = Appsignal::Logger.new("app")
15
+ appsignal_logger.broadcast_to(Rails.logger)
16
+ Rails.logger = ActiveSupport::TaggedLogging.new(appsignal_logger)
17
+ ```
18
+
19
+ (minor [5cb1464b](https://github.com/appsignal/appsignal-ruby/commit/5cb1464bcf12f043774fb55850e6b82aeba9c1ca))
20
+
21
+ ### Removed
22
+
23
+ - Remove tagged logging support from `Appsignal::Logger`.
24
+
25
+ Tagged logging is still supported by wrapping an instance of `Appsignal::Logger` with `ActiveSupport::TaggedLogging`:
26
+
27
+ ```ruby
28
+ appsignal_logger = Appsignal::Logger.new("rails")
29
+ tagged_logger = ActiveSupport::TaggedLogging.new(appsignal_logger)
30
+ Rails.logger = tagged_logger
31
+ ```
32
+
33
+ Removing this functionality allows for a workaround to issues within Rails ([#49745](https://github.com/rails/rails/issues/49745), [#51883](https://github.com/rails/rails/issues/51883)), where using the broadcast logger to log to more than one tagged logger results in incorrect behaviour of the tagged logging methods, resulting in breakage throughout Rails' internals:
34
+
35
+ ```ruby
36
+ # We use the built-in request ID middleware as an example that triggers
37
+ # the issue:
38
+ Rails.config.log_tags = [:request_id]
39
+
40
+ appsignal_logger = Appsignal::Logger.new("rails")
41
+ tagged_logger = ActiveSupport::TaggedLogging.new(appsignal_logger)
42
+
43
+ # This does not work correctly, because the default `Rails.logger` is a
44
+ # broadcast logger that is already broadcasting to a tagged logger.
45
+ # When asked to broadcast to a second tagged logger, the return value of
46
+ # `Rails.logger.tagged { ... }` will be incorrect, in turn causing the
47
+ # `RequestID` middleware, which uses it internally, to return broken
48
+ # Rack responses.
49
+ Rails.logger.broadcast_to(tagged_logger)
50
+ ```
51
+
52
+ By reverting the changes to our logger so that it is no longer a tagged logger, we enable a workaround to this issue:
53
+
54
+ ```ruby
55
+ Rails.config.log_tags = [:request_id]
56
+
57
+ appsignal_logger = Appsignal::Logger.new("rails")
58
+
59
+ # This works correctly, because `appsignal_logger` is not a tagged logger.
60
+ # Note that `appsignal_logger` will not have the `request_id` tags.
61
+ Rails.logger.broadcast_to(appsignal_logger)
62
+ ```
63
+
64
+ (patch [c061aa4e](https://github.com/appsignal/appsignal-ruby/commit/c061aa4e3f9485a1549ea90316534cddd36e238e))
65
+
66
+ ### Fixed
67
+
68
+ - Fix `#silence` implementation for `Appsignal::Logger`. (patch [d08a1cec](https://github.com/appsignal/appsignal-ruby/commit/d08a1cec705db71999afa9c4af36e244a7b6483a))
69
+
3
70
  ## 4.2.3
4
71
 
5
72
  _Published on 2024-12-17._
@@ -38,7 +38,7 @@ module Appsignal
38
38
  @mutex = Mutex.new
39
39
  @default_attributes = attributes
40
40
  @appsignal_attributes = {}
41
- @tags = []
41
+ @loggers = []
42
42
  end
43
43
 
44
44
  # We support the various methods in the Ruby
@@ -59,13 +59,14 @@ module Appsignal
59
59
  end
60
60
  return if message.nil?
61
61
 
62
- if @tags.any?
63
- formatted_tags = @tags.map { |tag| "[#{tag}]" }
64
- message = "#{formatted_tags.join(" ")} #{message}"
65
- end
66
-
67
62
  message = formatter.call(severity, Time.now, group, message) if formatter
68
63
 
64
+ @loggers.each do |logger|
65
+ logger.add(severity, message, group)
66
+ rescue
67
+ nil
68
+ end
69
+
69
70
  unless message.is_a?(String)
70
71
  Appsignal.internal_logger.warn(
71
72
  "Logger message was ignored, because it was not a String: #{message.inspect}"
@@ -150,41 +151,23 @@ module Appsignal
150
151
  add_with_attributes(FATAL, message, @group, attributes)
151
152
  end
152
153
 
153
- # Listen to ActiveSupport tagged logging tags set with `Rails.logger.tagged`.
154
- def tagged(tags)
155
- @tags.append(*tags)
156
- yield self
157
- ensure
158
- @tags.pop(tags.length)
159
- end
160
-
161
- # Listen to ActiveSupport tagged logging tags set with `Rails.config.log_tags`.
162
- def push_tags(*tags)
163
- @tags.append(*tags)
164
- end
165
-
166
- # Remove a set of ActiveSupport tagged logging tags set with `Rails.config.log_tags`.
167
- def pop_tags(count = 1)
168
- @tags.pop(count)
169
- end
170
-
171
- # Remove all ActiveSupport tagged logging tags set with `Rails.config.log_tags`.
172
- def clear_tags!
173
- @tags.clear
174
- end
175
-
176
154
  # When using ActiveSupport::TaggedLogging without the broadcast feature,
177
155
  # the passed logger is required to respond to the `silence` method.
178
- # In our case it behaves as the broadcast feature of the Rails logger, but
179
- # we don't have to check if the parent logger has the `silence` method defined
180
- # as our logger directly inherits from Ruby base logger.
181
156
  #
182
- # Links:
157
+ # Reference links:
183
158
  #
184
159
  # - https://github.com/rails/rails/blob/e11ebc04cfbe41c06cdfb70ee5a9fdbbd98bb263/activesupport/lib/active_support/logger.rb#L60-L76
185
- # - https://github.com/rails/rails/blob/main/activesupport/e11ebc04cfbe41c06cdfb70ee5a9fdbbd98bb263/active_support/logger_silence.rb
186
- def silence(_severity = ERROR, &block)
187
- block.call
160
+ # - https://github.com/rails/rails/blob/e11ebc04cfbe41c06cdfb70ee5a9fdbbd98bb263/activesupport/lib/active_support/logger_silence.rb
161
+ def silence(severity = ERROR, &block)
162
+ previous_level = @level
163
+ @level = severity
164
+ block.call(self)
165
+ ensure
166
+ @level = previous_level
167
+ end
168
+
169
+ def broadcast_to(logger)
170
+ @loggers << logger
188
171
  end
189
172
 
190
173
  private
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Appsignal
4
- VERSION = "4.2.3"
4
+ VERSION = "4.3.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appsignal
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.3
4
+ version: 4.3.0
5
5
  platform: java
6
6
  authors:
7
7
  - Robert Beekman
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2024-12-17 00:00:00.000000000 Z
13
+ date: 2024-12-20 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: logger