appsignal 3.9.0 → 3.9.1

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: 9957483552477f7eceba77181c904899b22ff6657db6782558b2fce96b9571e1
4
- data.tar.gz: 36c1760ff247804c579bb0b7bf3db2aee1d4ed53ede1a1920d5a8a1fa762f032
3
+ metadata.gz: 4ba7ce82da19f71d170cf4e49c9766668dfe0e9f2ee8538e174c176b27f8029d
4
+ data.tar.gz: 69deaf2c8fe7b5abf5959a176645e640d72e9b75fb346eeba8ca9a53449374ed
5
5
  SHA512:
6
- metadata.gz: '068c51758a2d48731ea31a4854cf31ab002c62fd290796832dea372f68078cbe2da29b237eb006aab7b6936b6a85b437a1f28f01d6182fad03425933b73a0241'
7
- data.tar.gz: 66832484c634de15a474774f49e8c38838faf4b71889c68c4ad7ef897d1ad64c119b926152a228117409103b657f8523599597394b989bbf87553d1c072bf5a1
6
+ metadata.gz: 94a9cf035fc75911dbcef3ba2d39ef207387dd1f4908f268a366ef4d71a8e1eb48657d6b7ccf6ed038d530be43cc6771e696e0f89335e7603b54b09104b49113
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: 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-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