appsignal 4.5.13 → 4.5.14

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: f462fd8fc28aa3a2a6028261d58ab86697d2b8070ddc1046a6cd28dca037eedf
4
- data.tar.gz: abfeb2be7e98cad19da981bcc54206fad3a6a07308ed5d4ac0b03043c471b716
3
+ metadata.gz: f2628ac9928190da11c2c906087fa6ab1b0ae533e4ee050e90c84dde6c6837c4
4
+ data.tar.gz: 4197a339909bce0ee679d5969cd842d1ab28a53d36f5f7eee49f85f6aacb7e63
5
5
  SHA512:
6
- metadata.gz: 1a55c84c2f35efc21b0e64bbefbd4d6af3141643567629bab715a5133560a23e64f71a9f9f198da006c63cfd4d99ef6ab7f0e95f5ca0ad55f4ff52d74739d54a
7
- data.tar.gz: 26e857ed78d111e6c504715de0a967992a9c2b16cf22defe5bb388516db882104fe296b93375e77457f60b87c938290f1e010c90f4f2b1a8a881a67964e358cb
6
+ metadata.gz: b525fa5d6742d936d1eba5b0fe040743814f0105473651dcd0032c17d295fd3e8d740f6db47384fa5868bc61dbb74ccb2d4855b215f0b23045d45c12ade03763
7
+ data.tar.gz: 4f05b2d6664dfef43dd94a840268b4e78fe239c1bec43ab3ef531ef35f8e14e6e9a32930ea6f06633e68f623a0998c87f331b5ed4b17d1cd869d7a7eed787743
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # AppSignal for Ruby gem Changelog
2
2
 
3
+ ## 4.5.14
4
+
5
+ _Published on 2025-05-27._
6
+
7
+ ### Fixed
8
+
9
+ - Resolve problems with transactions not being properly closed when using libraries that change Fibers during the transactions. Previously, completed transactions would be attempted to be reused when creating a transaction, when the Fiber would be switched during a transaction. (patch [32733b25](https://github.com/appsignal/appsignal-ruby/commit/32733b25ced393cc7ed4bd6f15f3b6b293b133c5))
10
+ - Fix a config error log message when the config is not active and should not validate the config. (patch [0d114b43](https://github.com/appsignal/appsignal-ruby/commit/0d114b435f63fe11bebce26efe282f90e2eb57aa))
11
+
3
12
  ## 4.5.13
4
13
 
5
14
  _Published on 2025-05-12._
@@ -393,8 +393,12 @@ module Appsignal
393
393
  @valid
394
394
  end
395
395
 
396
+ def active_for_env?
397
+ config_hash[:active]
398
+ end
399
+
396
400
  def active?
397
- @valid && config_hash[:active]
401
+ valid? && active_for_env?
398
402
  end
399
403
 
400
404
  # @api private
@@ -444,13 +448,16 @@ module Appsignal
444
448
  merge(options)
445
449
  end
446
450
 
447
- # @return [void]
451
+ # Apply any overrides for invalid settings.
448
452
  # @api private
449
- def validate
450
- # Apply any overrides for invalid settings.
453
+ def apply_overrides
451
454
  @override_config = determine_overrides
452
455
  merge(override_config)
456
+ end
453
457
 
458
+ # @return [void]
459
+ # @api private
460
+ def validate
454
461
  # Strip path from endpoint so we're backwards compatible with
455
462
  # earlier versions of the gem.
456
463
  # TODO: Move to its own method, maybe in `#[]=`?
@@ -27,20 +27,25 @@ module Appsignal
27
27
  # @param namespace [String] Namespace of the to be created transaction.
28
28
  # @return [Transaction]
29
29
  def create(namespace)
30
- # Check if we already have a running transaction
30
+ # Reset the transaction if it was already completed but not cleared
31
+ if Thread.current[:appsignal_transaction]&.completed?
32
+ Thread.current[:appsignal_transaction] = nil
33
+ end
34
+
31
35
  if Thread.current[:appsignal_transaction].nil?
32
36
  # If not, start a new transaction
33
37
  set_current_transaction(Appsignal::Transaction.new(namespace))
34
38
  else
39
+ transaction = current
35
40
  # Otherwise, log the issue about trying to start another transaction
36
41
  Appsignal.internal_logger.warn(
37
42
  "Trying to start new transaction, but a transaction " \
38
- "with id '#{current.transaction_id}' is already running. " \
39
- "Using transaction '#{current.transaction_id}'."
43
+ "with id '#{transaction.transaction_id}' is already running. " \
44
+ "Using transaction '#{transaction.transaction_id}'."
40
45
  )
41
46
 
42
47
  # And return the current transaction instead
43
- current
48
+ transaction
44
49
  end
45
50
  end
46
51
 
@@ -154,6 +159,7 @@ module Appsignal
154
159
  @namespace = namespace
155
160
  @paused = false
156
161
  @discarded = false
162
+ @completed = false
157
163
  @tags = {}
158
164
  @breadcrumbs = []
159
165
  @store = Hash.new { |hash, key| hash[key] = {} }
@@ -185,6 +191,11 @@ module Appsignal
185
191
  false
186
192
  end
187
193
 
194
+ # @api private
195
+ def completed?
196
+ @completed
197
+ end
198
+
188
199
  # @api private
189
200
  def complete
190
201
  if discarded?
@@ -233,6 +244,7 @@ module Appsignal
233
244
 
234
245
  sample_data if should_sample
235
246
 
247
+ @completed = true
236
248
  @ext.complete
237
249
  end
238
250
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Appsignal
4
- VERSION = "4.5.13"
4
+ VERSION = "4.5.14"
5
5
  end
data/lib/appsignal.rb CHANGED
@@ -133,8 +133,8 @@ module Appsignal
133
133
  _load_config!
134
134
  _start_logger
135
135
 
136
- if config.valid?
137
- if config.active?
136
+ if config.active_for_env?
137
+ if config.valid?
138
138
  @started = true
139
139
  internal_logger.info "Starting AppSignal #{Appsignal::VERSION} " \
140
140
  "(#{$PROGRAM_NAME}, Ruby #{RUBY_VERSION}, #{RUBY_PLATFORM})"
@@ -153,10 +153,10 @@ module Appsignal
153
153
  collect_environment_metadata
154
154
  @config.freeze
155
155
  else
156
- internal_logger.info("Not starting, not active for #{config.env}")
156
+ internal_logger.info("Not starting, no valid config for this environment")
157
157
  end
158
158
  else
159
- internal_logger.error("Not starting, no valid config for this environment")
159
+ internal_logger.info("Not starting, not active for #{config.env}")
160
160
  end
161
161
  nil
162
162
  end
@@ -166,7 +166,7 @@ module Appsignal
166
166
  # @param env_param [String, NilClass] Used by diagnose CLI to pass through
167
167
  # the environment CLI option value.
168
168
  # @api private
169
- def _load_config!(env_param = nil, &block)
169
+ def _load_config!(env_param = nil, &block) # rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity
170
170
  # Ensure it's not an empty string if it's a value
171
171
  proper_env_param = env_param&.to_s&.strip
172
172
  # Unset it if it's an empty string
@@ -206,9 +206,17 @@ module Appsignal
206
206
  # This will load the config/appsignal.yml file automatically
207
207
  @config ||= Config.new(context.root_path, context.env)
208
208
  end
209
+
209
210
  # Allow a block to be given to customize the config and override any
210
211
  # loaded config before it's validated.
211
212
  block.call(config) if block_given?
213
+
214
+ # Apply any config overrides after the user config has been merged
215
+ config&.apply_overrides
216
+
217
+ # Skip validation if not configured as active for this environment
218
+ return unless config.active_for_env?
219
+
212
220
  # Validate the config, if present
213
221
  config&.validate
214
222
  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.5.13
4
+ version: 4.5.14
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: 2025-05-12 00:00:00.000000000 Z
13
+ date: 2025-05-27 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: logger