appsignal 3.9.0-java → 3.9.1-java

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: 87ae30cedc24d783bcd6f28bb01bb19384e0f7a280fe2c8b89585a5161aaaf77
4
- data.tar.gz: 36c1760ff247804c579bb0b7bf3db2aee1d4ed53ede1a1920d5a8a1fa762f032
3
+ metadata.gz: 41bb798be594cced035267d2df31d1055dedf7fa67ec22b3807c27833f828ed4
4
+ data.tar.gz: 69deaf2c8fe7b5abf5959a176645e640d72e9b75fb346eeba8ca9a53449374ed
5
5
  SHA512:
6
- metadata.gz: ed40403d826734ba4725b087b4d52d75be79d9bfd7172d12ceba70da3393de9bf55ca02964a81104082e9058eb44d1c3795623a21b244b13905a0310f2961d16
7
- data.tar.gz: 66832484c634de15a474774f49e8c38838faf4b71889c68c4ad7ef897d1ad64c119b926152a228117409103b657f8523599597394b989bbf87553d1c072bf5a1
6
+ metadata.gz: 71e4034081ed264899515c1de46b3e1d48d24dfc43e8b0861ddadb92bfbf803124491046f8ff6fbeeaa7b4a38e55e4638e822b39744ba6a7b5de986182d3f6b4
7
+ data.tar.gz: 3aa39a4f0f3ed36782ffbc3501eedfb6d811248abcf4e304be4d41f64ec24a4f938c8fe130bfb7de85751780d063783a72a1a389717a636fadc71e042305687f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # AppSignal for Ruby gem Changelog
2
2
 
3
+ ## 3.9.1
4
+
5
+ _Published on 2024-06-24._
6
+
7
+ ### Fixed
8
+
9
+ - [0a253aa1](https://github.com/appsignal/appsignal-ruby/commit/0a253aa16c00cd6172e35a4edaff34f76ac9cbe5) patch - Fix parameter reporting for Rack and Sinatra apps, especially POST payloads.
10
+
3
11
  ## 3.9.0
4
12
 
5
13
  _Published on 2024-06-21._
@@ -91,8 +91,6 @@ module Appsignal
91
91
  # Override this method to set metadata before the app is called.
92
92
  # Call `super` to also include the default set metadata.
93
93
  def add_transaction_metadata_before(transaction, request)
94
- params = params_for(request)
95
- transaction.params = params if params
96
94
  end
97
95
 
98
96
  # Add metadata to the transaction based on the request environment.
@@ -104,6 +102,7 @@ module Appsignal
104
102
  transaction.set_action_if_nil(default_action)
105
103
  transaction.set_metadata("path", request.path)
106
104
  transaction.set_metadata("method", request.request_method)
105
+ transaction.set_params_if_nil(params_for(request))
107
106
  transaction.set_http_or_background_queue_start
108
107
  end
109
108
 
@@ -76,18 +76,6 @@ module Appsignal
76
76
  attr_reader :ext, :transaction_id, :action, :namespace, :request, :paused, :tags, :options,
77
77
  :discarded, :breadcrumbs
78
78
 
79
- # @!attribute params
80
- # Attribute for parameters of the transaction.
81
- #
82
- # When no parameters are set with {#params=} the parameters it will look
83
- # for parameters on the {#request} environment.
84
- #
85
- # The parameters set using {#params=} are leading over those extracted
86
- # from a request's environment.
87
- #
88
- # @return [Hash]
89
- attr_writer :params
90
-
91
79
  def initialize(transaction_id, namespace, request, options = {})
92
80
  @transaction_id = transaction_id
93
81
  @action = nil
@@ -156,6 +144,40 @@ module Appsignal
156
144
  request_params
157
145
  end
158
146
 
147
+ # Set parameters on the transaction.
148
+ #
149
+ # When no parameters are set this way, the transaction will look for
150
+ # parameters on the {#request} environment.
151
+ #
152
+ # The parameters set using {#set_params} are leading over those extracted
153
+ # from a request's environment.
154
+ #
155
+ # @param given_params [Hash] The parameters to set on the transaction.
156
+ # @return [void]
157
+ def set_params(given_params)
158
+ @params = given_params if given_params
159
+ end
160
+
161
+ # @deprecated Use {#set_params} or {#set_params_if_nil} instead.
162
+ def params=(given_params)
163
+ Appsignal::Utils::StdoutAndLoggerMessage.warning(
164
+ "Transaction#params= is deprecated." \
165
+ "Use Transaction#set_params or #set_params_if_nil instead."
166
+ )
167
+ set_params(given_params)
168
+ end
169
+
170
+ # Set parameters on the transaction if not already set
171
+ #
172
+ # When no parameters are set this way, the transaction will look for
173
+ # parameters on the {#request} environment.
174
+ #
175
+ # @param given_params [Hash] The parameters to set on the transaction if none are already set.
176
+ # @return [void]
177
+ def set_params_if_nil(given_params)
178
+ set_params(given_params) unless @params
179
+ end
180
+
159
181
  # Set tags on the transaction.
160
182
  #
161
183
  # @param given_tags [Hash] Collection of tags.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Appsignal
4
- VERSION = "3.9.0"
4
+ VERSION = "3.9.1"
5
5
  end
@@ -348,9 +348,92 @@ describe Appsignal::Transaction do
348
348
  end
349
349
 
350
350
  describe "#params=" do
351
+ around { |example| keep_transactions { example.run } }
352
+
351
353
  it "sets params on the transaction" do
352
- transaction.params = { :foo => "bar" }
353
- expect(transaction.params).to eq(:foo => "bar")
354
+ params = { "foo" => "bar" }
355
+ transaction.params = params
356
+
357
+ transaction.complete # Sample the data
358
+ expect(transaction.params).to eq(params)
359
+ expect(transaction.to_h.dig("sample_data", "params")).to eq(params)
360
+ end
361
+
362
+ it "logs a deprecation warning" do
363
+ transaction.params = { "foo" => "bar" }
364
+
365
+ expect(log_contents(log)).to contains_log(
366
+ :warn,
367
+ "Transaction#params= is deprecated." \
368
+ "Use Transaction#set_params or #set_params_if_nil instead."
369
+ )
370
+ end
371
+ end
372
+
373
+ describe "#set_params" do
374
+ around { |example| keep_transactions { example.run } }
375
+
376
+ context "when the params are set" do
377
+ it "updates the params on the transaction" do
378
+ params = { "key" => "value" }
379
+ transaction.set_params(params)
380
+
381
+ transaction.complete # Sample the data
382
+ expect(transaction.params).to eq(params)
383
+ expect(transaction.to_h.dig("sample_data", "params")).to eq(params)
384
+ end
385
+ end
386
+
387
+ context "when the given params is nil" do
388
+ it "does not update the params on the transaction" do
389
+ params = { "key" => "value" }
390
+ transaction.set_params(params)
391
+ transaction.set_params(nil)
392
+
393
+ transaction.complete # Sample the data
394
+ expect(transaction.params).to eq(params)
395
+ expect(transaction.to_h.dig("sample_data", "params")).to eq(params)
396
+ end
397
+ end
398
+ end
399
+
400
+ describe "#set_params_if_nil" do
401
+ around { |example| keep_transactions { example.run } }
402
+
403
+ context "when the params are not set" do
404
+ it "sets the params on the transaction" do
405
+ params = { "key" => "value" }
406
+ transaction.set_params_if_nil(params)
407
+
408
+ transaction.complete # Sample the data
409
+ expect(transaction.params).to eq(params)
410
+ expect(transaction.to_h.dig("sample_data", "params")).to eq(params)
411
+ end
412
+
413
+ context "when the given params is nil" do
414
+ it "does not update the params on the transaction" do
415
+ params = { "key" => "value" }
416
+ transaction.set_params(params)
417
+ transaction.set_params_if_nil(nil)
418
+
419
+ transaction.complete # Sample the data
420
+ expect(transaction.params).to eq(params)
421
+ expect(transaction.to_h.dig("sample_data", "params")).to eq(params)
422
+ end
423
+ end
424
+ end
425
+
426
+ context "when the params are set" do
427
+ it "does not update the params on the transaction" do
428
+ preset_params = { "other" => "params" }
429
+ params = { "key" => "value" }
430
+ transaction.set_params(preset_params)
431
+ transaction.set_params_if_nil(params)
432
+
433
+ transaction.complete # Sample the data
434
+ expect(transaction.params).to eq(preset_params)
435
+ expect(transaction.to_h.dig("sample_data", "params")).to eq(preset_params)
436
+ end
354
437
  end
355
438
  end
356
439
 
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: 3.9.0
4
+ version: 3.9.1
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-06-21 00:00:00.000000000 Z
13
+ date: 2024-06-24 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rack