appsignal 5.0.3-java → 5.0.4-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: f511b69fdbdeb226062bbaf05e00fe52eb3bd20854c3eeb202edba0b815b1db5
4
- data.tar.gz: e1261b245afbc044c149b030ba2b4f4656c7d56f56e37223006ed21a68d1a8be
3
+ metadata.gz: 8cbb7e4a2eea9564a48fa144018d1d6b2a3a0071145dbb83667e1f35dd79ced2
4
+ data.tar.gz: 94ca97dc758b43867456f9ca351085ba0f43945d55c94ef777d83af89a77c2d2
5
5
  SHA512:
6
- metadata.gz: a18f025051286fc68ff81d27cdc6d4d2fd91b71f79e3d439a9d957e39c98350c9dd46fc7626738c8dfddd13908f13884f9be13155475dedfc8e2844e10f44021
7
- data.tar.gz: eb8047d550aaa8afd456483ef40db0d188ba492215e582b6f7ddc5c73b6d7e1d957c39bf0183e2b2d5fa1dbd5531a5064d66ac874a1112193feddf9d90f1cd94
6
+ metadata.gz: a78c3d8478e1be4f5ba71a555042be872889ceec267b7fa623068059cdf928434141f19ae4635ffd7b0fe8d14ffc075266d1b95db36655dbaebde41bd381c8cb
7
+ data.tar.gz: c848362c51a845da9b0f5be46180d857b14a58152765664d24abdf89244fb4c7efe9569a18dda2a3549e04cbb21465468eef5d6fd12164c8c5e73954f777921f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # AppSignal for Ruby gem Changelog
2
2
 
3
+ ## 5.0.4
4
+
5
+ _Published on 2026-10-09._
6
+
7
+ ### Fixed
8
+
9
+ - Fix an issue where transactions would be reused across requests when an error happened before the transaction could be closed, which would lead to errors being returned by the app itself. (patch [65ff0be0](https://github.com/appsignal/appsignal-ruby/commit/65ff0be0c3d4dea2eb9ed5bdb81004e899e6edf4))
10
+
3
11
  ## 5.0.3
4
12
 
5
13
  _Published on 2026-10-08._
@@ -37,6 +37,15 @@ module Appsignal
37
37
  )
38
38
  end
39
39
 
40
+ # @api private
41
+ def self.complete_transaction(transaction)
42
+ safe_execution("Appsignal::Rack::EventHandler#complete_transaction") do
43
+ transaction.complete
44
+ end
45
+ ensure
46
+ Appsignal::Transaction.clear_current_transaction!
47
+ end
48
+
40
49
  # @api private
41
50
  attr_reader :id
42
51
  attr_writer :using_appsignal_event_middleware
@@ -68,29 +77,7 @@ module Appsignal
68
77
  :opentelemetry_context => Appsignal::OpenTelemetry.extract_rack_context(request.env),
69
78
  :opentelemetry_scope => ["appsignal-ruby/rack", Appsignal::VERSION]
70
79
  )
71
- # Describes the transaction's span as an incoming HTTP request.
72
- # Together with the SERVER span kind the transaction already carries,
73
- # this is what the trace timeline reads to recognize a web request.
74
- #
75
- # Set before the event below starts, because attributes go on
76
- # whichever span is open and these belong on the transaction's own
77
- # span. That event stays open until the response finishes, so there is
78
- # no later point in the request at which these could be set.
79
- transaction.add_opentelemetry_attributes(
80
- Appsignal::OpenTelemetry::HttpServerRequest.attributes_for(
81
- :method => Appsignal::Rack::Utils.request_method_from(request),
82
- :path => Appsignal::Rack::Utils.request_value_from(request, :path),
83
- :scheme => Appsignal::Rack::Utils.request_value_from(request, :scheme),
84
- :query => Appsignal::Rack::Utils.request_value_from(request, :query_string),
85
- :host => Appsignal::Rack::Utils.request_value_from(request, :hostname),
86
- :port => Appsignal::Rack::Utils.request_value_from(request, :port),
87
- :protocol =>
88
- Appsignal::Rack::Utils.request_env_value_from(request, "SERVER_PROTOCOL")
89
- )
90
- )
91
- transaction.start_event(
92
- :opentelemetry_scope => ["appsignal-ruby/rack", Appsignal::VERSION]
93
- )
80
+ # Register cleanup before request instrumentation can raise.
94
81
  request.env[APPSIGNAL_TRANSACTION] = transaction
95
82
 
96
83
  request.env[RACK_AFTER_REPLY] ||= []
@@ -113,9 +100,32 @@ module Appsignal
113
100
  # just a fallback if that doesn't get called.
114
101
  #
115
102
  # One such scenario is when a Puma "lowlevel_error" occurs.
116
- transaction.complete
117
- Appsignal::Transaction.clear_current_transaction!
103
+ Appsignal::Rack::EventHandler.complete_transaction(transaction)
118
104
  end
105
+
106
+ # Describes the transaction's span as an incoming HTTP request.
107
+ # Together with the SERVER span kind the transaction already carries,
108
+ # this is what the trace timeline reads to recognize a web request.
109
+ #
110
+ # Set before the event below starts, because attributes go on
111
+ # whichever span is open and these belong on the transaction's own
112
+ # span. That event stays open until the response finishes, so there is
113
+ # no later point in the request at which these could be set.
114
+ transaction.add_opentelemetry_attributes(
115
+ Appsignal::OpenTelemetry::HttpServerRequest.attributes_for(
116
+ :method => Appsignal::Rack::Utils.request_method_from(request),
117
+ :path => Appsignal::Rack::Utils.request_value_from(request, :path),
118
+ :scheme => Appsignal::Rack::Utils.request_value_from(request, :scheme),
119
+ :query => Appsignal::Rack::Utils.request_value_from(request, :query_string),
120
+ :host => Appsignal::Rack::Utils.request_value_from(request, :hostname),
121
+ :port => Appsignal::Rack::Utils.request_value_from(request, :port),
122
+ :protocol =>
123
+ Appsignal::Rack::Utils.request_env_value_from(request, "SERVER_PROTOCOL")
124
+ )
125
+ )
126
+ transaction.start_event(
127
+ :opentelemetry_scope => ["appsignal-ruby/rack", Appsignal::VERSION]
128
+ )
119
129
  end
120
130
  end
121
131
 
@@ -188,8 +198,7 @@ module Appsignal
188
198
 
189
199
  # Make sure the current transaction is always closed when the request
190
200
  # is finished
191
- transaction.complete
192
- Appsignal::Transaction.clear_current_transaction!
201
+ self.class.complete_transaction(transaction)
193
202
  end
194
203
 
195
204
  private
@@ -446,6 +446,7 @@ module Appsignal
446
446
  emit_queue_duration_metric if should_report?
447
447
  report_allocation_count
448
448
  end
449
+ ensure
449
450
  teardown
450
451
  end
451
452
 
@@ -316,26 +316,30 @@ module Appsignal
316
316
  return
317
317
  end
318
318
 
319
- # If the transaction is a duplicate, we don't want to finish it,
320
- # because we want its finish time to be the finish time of the
321
- # original transaction.
322
- # Duplicate transactions should always be sampled, as we only
323
- # create duplicates for errors, which are always sampled.
324
- should_sample = true
325
-
326
- unless duplicate?
327
- self.class.last_errors = @errors.to_a
328
- should_sample = @backend.finish
329
- end
330
-
331
- report_errors
319
+ begin
320
+ # If the transaction is a duplicate, we don't want to finish it,
321
+ # because we want its finish time to be the finish time of the
322
+ # original transaction.
323
+ # Duplicate transactions should always be sampled, as we only
324
+ # create duplicates for errors, which are always sampled.
325
+ should_sample = true
326
+
327
+ unless duplicate?
328
+ self.class.last_errors = @errors.to_a
329
+ should_sample = @backend.finish
330
+ end
332
331
 
333
- run_before_complete_hooks
332
+ report_errors
334
333
 
335
- sample_data if should_sample
334
+ run_before_complete_hooks
336
335
 
337
- @completed = true
338
- @backend.complete
336
+ sample_data if should_sample
337
+ ensure
338
+ # Release backend resources even when sample data cannot be collected
339
+ # or serialized. In collector mode this also detaches the span context.
340
+ @completed = true
341
+ @backend.complete
342
+ end
339
343
  end
340
344
 
341
345
  # @!visibility private
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Appsignal
4
4
  # @return [String]
5
- VERSION = "5.0.3"
5
+ VERSION = "5.0.4"
6
6
  end
data/sig/appsignal.rbi CHANGED
@@ -8,7 +8,7 @@
8
8
  module Appsignal
9
9
  extend Appsignal::Helpers::Metrics
10
10
  extend Appsignal::Helpers::Instrumentation
11
- VERSION = T.let("5.0.3", T.untyped)
11
+ VERSION = T.let("5.0.4", T.untyped)
12
12
 
13
13
  class << self
14
14
  # The loaded AppSignal configuration.
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: 5.0.3
4
+ version: 5.0.4
5
5
  platform: java
6
6
  authors:
7
7
  - Robert Beekman