appsignal 4.2.1 → 4.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c0f3461c34bdd14c14cc7e54507d5d0fc6c366576e24aba129c10dac29ccd6ec
4
- data.tar.gz: 72bfe73112c365ec22375fed9a3e3c0283295d18442f346ffcee6461578aa487
3
+ metadata.gz: a73498e46bc368404ec2ceb9936aa95e607d824b8b3294f435be1b11468104ab
4
+ data.tar.gz: 40a601b88ad6f2922ed089aee5c2775a9f232a446cf45a2e749b710763672f50
5
5
  SHA512:
6
- metadata.gz: bc6b19f3ae38745112b86d5693fee5a3ab42798c13e7c75344e1249ad8f0580b30095e5de9365ee51bc5d8604f577b7f3c4002f62cec0ae5dd81f049b0725bf8
7
- data.tar.gz: 536707fdd072fba73fd710ac2cd503c4f3bc79cf09b0d0afb1b2cc7aa7441d2fd07ff5a24586f390195f92aeeda356b2829f433863e10c18551b3151a5aa9f15
6
+ metadata.gz: a988dd091887d786e0aee5d21ec10204d1d82054e52d7dc973cf751d17e33793a968716187b14ee3276a373b9f70323d3b2d8663acf5c23b8e05136e0c00bce6
7
+ data.tar.gz: efa4ee5f181c43a483845ab92dc641aa11e23a19e375931f44a7e0d33811caf5a1f0f41fcb71010f0ae67efb35cb87577004f01563ce1557dafa6a3dd8423b7b
data/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # AppSignal for Ruby gem Changelog
2
2
 
3
+ ## 4.2.2
4
+
5
+ _Published on 2024-12-16._
6
+
7
+ ### Added
8
+
9
+ - Support Rails/ActiveSupport tagged logging. When tags are set in apps using `Rails.logger.tagged { ... }` or with the `Rails.application.config.log_tags = [...]` config option, these tags are now included in the collected log messages.
10
+
11
+ ```ruby
12
+ Rails.logger.tagged(["Tag 1", "Tag 2"]) { Rails.logger.info("My message") }
13
+ ```
14
+
15
+ Reports this log message:
16
+
17
+ > [Tag 1] [Tag 2] My message
18
+
19
+ (patch [41e1e8f0](https://github.com/appsignal/appsignal-ruby/commit/41e1e8f076025da2420cb43c53b5f7211ae45de8))
20
+
21
+ ### Fixed
22
+
23
+ - Fix a thread safety issue where sending check-in events simultaneously from different threads would cause several check-in schedulers to be initialised internally. This could cause some of the scheduled check-in events to never be sent to AppSignal when `Appsignal.stop` is called. (patch [c372a3f9](https://github.com/appsignal/appsignal-ruby/commit/c372a3f998b78ef5ef259be39fe198433d6ca95e))
24
+
3
25
  ## 4.2.1
4
26
 
5
27
  _Published on 2024-12-04._
data/build_matrix.yml CHANGED
@@ -88,6 +88,7 @@ matrix:
88
88
  - "rails-8.0"
89
89
 
90
90
  ruby:
91
+ - ruby: "3.4.0-rc1"
91
92
  - ruby: "3.3.4"
92
93
  - ruby: "3.2.5"
93
94
  - ruby: "3.1.6"
@@ -102,6 +103,7 @@ matrix:
102
103
  - gem: "dry-monitor"
103
104
  only:
104
105
  ruby:
106
+ - "3.4.0-rc1"
105
107
  - "3.3.4"
106
108
  - "3.2.5"
107
109
  - "3.1.6"
@@ -110,6 +112,7 @@ matrix:
110
112
  - gem: "hanami-2.0"
111
113
  only:
112
114
  ruby:
115
+ - "3.4.0-rc1"
113
116
  - "3.3.4"
114
117
  - "3.2.5"
115
118
  - "3.1.6"
@@ -117,6 +120,7 @@ matrix:
117
120
  - gem: "hanami-2.1"
118
121
  only:
119
122
  ruby:
123
+ - "3.4.0-rc1"
120
124
  - "3.3.4"
121
125
  - "3.2.5"
122
126
  - "3.1.6"
@@ -124,6 +128,7 @@ matrix:
124
128
  - gem: "hanami-2.2"
125
129
  only:
126
130
  ruby:
131
+ - "3.4.0-rc1"
127
132
  - "3.3.4"
128
133
  - "3.2.5"
129
134
  - "3.1.6"
@@ -132,6 +137,7 @@ matrix:
132
137
  - gem: "psych-3"
133
138
  only:
134
139
  ruby:
140
+ - "3.4.0-rc1"
135
141
  - "3.3.4"
136
142
  - "3.2.5"
137
143
  - "3.1.6"
@@ -140,6 +146,7 @@ matrix:
140
146
  - gem: "psych-4"
141
147
  only:
142
148
  ruby:
149
+ - "3.4.0-rc1"
143
150
  - "3.3.4"
144
151
  - "3.2.5"
145
152
  - "3.1.6"
@@ -165,6 +172,7 @@ matrix:
165
172
  - gem: "rails-7.0"
166
173
  only:
167
174
  ruby:
175
+ - "3.4.0-rc1"
168
176
  - "3.3.4"
169
177
  - "3.2.5"
170
178
  - "3.1.6"
@@ -174,6 +182,7 @@ matrix:
174
182
  - gem: "rails-7.1"
175
183
  only:
176
184
  ruby:
185
+ - "3.4.0-rc1"
177
186
  - "3.3.4"
178
187
  - "3.2.5"
179
188
  - "3.1.6"
@@ -182,6 +191,7 @@ matrix:
182
191
  - gem: "rails-7.2"
183
192
  only:
184
193
  ruby:
194
+ - "3.4.0-rc1"
185
195
  - "3.3.4"
186
196
  - "3.2.5"
187
197
  - "3.1.6"
@@ -189,6 +199,7 @@ matrix:
189
199
  - gem: "rails-8.0"
190
200
  only:
191
201
  ruby:
202
+ - "3.4.0-rc1"
192
203
  - "3.3.4"
193
204
  - "3.2.5"
194
205
  - gem: "sequel"
@@ -95,7 +95,11 @@ module Appsignal
95
95
  description = Event.describe(events)
96
96
 
97
97
  begin
98
- response = CheckIn.transmitter.transmit(events, :format => :ndjson)
98
+ @transmitter ||= Transmitter.new(
99
+ "#{Appsignal.config[:logging_endpoint]}/check_ins/json"
100
+ )
101
+
102
+ response = @transmitter.transmit(events, :format => :ndjson)
99
103
 
100
104
  if (200...300).include?(response.code.to_i)
101
105
  Appsignal.internal_logger.debug("Transmitted #{description}")
@@ -3,6 +3,8 @@
3
3
  module Appsignal
4
4
  module CheckIn
5
5
  HEARTBEAT_CONTINUOUS_INTERVAL_SECONDS = 30
6
+ NEW_SCHEDULER_MUTEX = Mutex.new
7
+
6
8
  class << self
7
9
  # @api private
8
10
  def continuous_heartbeats
@@ -82,16 +84,15 @@ module Appsignal
82
84
  scheduler.schedule(event)
83
85
  end
84
86
 
85
- # @api private
86
- def transmitter
87
- @transmitter ||= Transmitter.new(
88
- "#{Appsignal.config[:logging_endpoint]}/check_ins/json"
89
- )
90
- end
91
-
92
87
  # @api private
93
88
  def scheduler
94
- @scheduler ||= Scheduler.new
89
+ return @scheduler if @scheduler
90
+
91
+ NEW_SCHEDULER_MUTEX.synchronize do
92
+ @scheduler ||= Scheduler.new
93
+ end
94
+
95
+ @scheduler
95
96
  end
96
97
 
97
98
  # @api private
@@ -37,6 +37,8 @@ module Appsignal
37
37
  @format = format
38
38
  @mutex = Mutex.new
39
39
  @default_attributes = attributes
40
+ @appsignal_attributes = {}
41
+ @tags = []
40
42
  end
41
43
 
42
44
  # We support the various methods in the Ruby
@@ -57,6 +59,11 @@ module Appsignal
57
59
  end
58
60
  return if message.nil?
59
61
 
62
+ if @tags.any?
63
+ formatted_tags = @tags.map { |tag| "[#{tag}]" }
64
+ message = "#{formatted_tags.join(" ")} #{message}"
65
+ end
66
+
60
67
  message = formatter.call(severity, Time.now, group, message) if formatter
61
68
 
62
69
  unless message.is_a?(String)
@@ -143,6 +150,29 @@ module Appsignal
143
150
  add_with_attributes(FATAL, message, @group, attributes)
144
151
  end
145
152
 
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
+
146
176
  # When using ActiveSupport::TaggedLogging without the broadcast feature,
147
177
  # the passed logger is required to respond to the `silence` method.
148
178
  # In our case it behaves as the broadcast feature of the Rails logger, but
@@ -159,17 +189,13 @@ module Appsignal
159
189
 
160
190
  private
161
191
 
162
- attr_reader :default_attributes
192
+ attr_reader :default_attributes, :appsignal_attributes
163
193
 
164
194
  def add_with_attributes(severity, message, group, attributes)
165
- Thread.current[:appsignal_logger_attributes] = default_attributes.merge(attributes)
195
+ @appsignal_attributes = default_attributes.merge(attributes)
166
196
  add(severity, message, group)
167
197
  ensure
168
- Thread.current[:appsignal_logger_attributes] = nil
169
- end
170
-
171
- def appsignal_attributes
172
- Thread.current.fetch(:appsignal_logger_attributes, {})
198
+ @appsignal_attributes = {}
173
199
  end
174
200
  end
175
201
  end
@@ -59,7 +59,11 @@ module Appsignal
59
59
  is_sidekiq7 = self.class.sidekiq7_and_greater?
60
60
  @adapter = is_sidekiq7 ? Sidekiq7Adapter : Sidekiq6Adapter
61
61
 
62
- config_string = " with config: #{config}" unless config.empty?
62
+ unless config.empty?
63
+ formatted_config =
64
+ config.map { |key, value| "#{key}: #{value.inspect}" }.join(", ")
65
+ config_string = " with config: #{formatted_config}"
66
+ end
63
67
  Appsignal.internal_logger.debug("Initializing Sidekiq probe#{config_string}")
64
68
  require "sidekiq/api"
65
69
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Appsignal
4
- VERSION = "4.2.1"
4
+ VERSION = "4.2.2"
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.1
4
+ version: 4.2.2
5
5
  platform: ruby
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-04 00:00:00.000000000 Z
13
+ date: 2024-12-16 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: logger
@@ -313,7 +313,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
313
313
  - !ruby/object:Gem::Version
314
314
  version: '0'
315
315
  requirements: []
316
- rubygems_version: 3.5.22
316
+ rubygems_version: 3.3.7
317
317
  signing_key:
318
318
  specification_version: 4
319
319
  summary: Logs performance and exception data from your app to appsignal.com