appsignal 4.0.0.beta.1 → 4.0.0.beta.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: 6c62aeea855bb28e59a5580d8babf88ff51a63f73aa0a3ff17721e6ed4aeb3da
4
- data.tar.gz: 37e732954a981ad21f73d6baabea1857f21566e9534044a6c164b53b3277c123
3
+ metadata.gz: 106096bf50f3e6f1e98e570a806b2086bd5f9ad1d2a8740642d605efb4059e04
4
+ data.tar.gz: e9b763431f5c412a6aa3354f9b9e9c4ebd3ee6a1e36f7f9addd9b4c796811af1
5
5
  SHA512:
6
- metadata.gz: 1202595935a48c8ed7d5b0e5b2462cad9e0e6b998be9c7c9f5a1742c5ce670b5bfe73ada71edf3f5c7e648bc9e97cd5e926254e46c322c58dac12a19f6669cf1
7
- data.tar.gz: d006348ba01d732dfe2abd6bb09fa9d2b0128577011eb54df402ed43a4f04df300472e374d4f851d921be24e98800bbe6e0c6c636e0b30146e5d2c0e17f982c8
6
+ metadata.gz: 7d16d3e178791d3caaaf0acd7484c358ec09557a407c6ffa386c41ce5b27ba3d7e1d67f603f9db6993d13aa185d51a87cc2c18e4c46d868db7131852f713f770
7
+ data.tar.gz: d6b4d552c1eb6016e8a58ed06fee58719f49a0b775c588b6052da9ac6c97b2a3c1a71f80a1c2e9e0d0e7aa3734f0b3d27ddb9b2352ae9f81f3c2efbb6c9047df
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # AppSignal for Ruby gem Changelog
2
2
 
3
+ ## 4.0.0.beta.2
4
+
5
+ _Published on 2024-08-19._
6
+
7
+ ### Added
8
+
9
+ - Add a helper for parameters sample data to be unset. This is a private method until we stabilize it. (patch [e9336363](https://github.com/appsignal/appsignal-ruby/commit/e9336363fa869c88ab925f57e86ead45e8e18c29))
10
+
3
11
  ## 4.0.0.beta.1
4
12
 
5
13
  _Published on 2024-08-19._
@@ -552,6 +552,20 @@ module Appsignal
552
552
  end
553
553
  alias :set_params :add_params
554
554
 
555
+ # Mark the parameters sample data to be set as an empty value.
556
+ #
557
+ # @api private
558
+ # @since 4.0.0
559
+ # @return [void]
560
+ # @see Helpers::Instrumentation#set_empty_params!
561
+ def set_empty_params!
562
+ return unless active?
563
+ return unless Appsignal::Transaction.current?
564
+
565
+ transaction = Appsignal::Transaction.current
566
+ transaction.set_empty_params!
567
+ end
568
+
555
569
  # Add session data to the current transaction.
556
570
  #
557
571
  # Session data is automatically added by most of our integrations. It
@@ -7,9 +7,11 @@ module Appsignal
7
7
  @key = key
8
8
  @accepted_type = accepted_type
9
9
  @blocks = []
10
+ @empty = false
10
11
  end
11
12
 
12
13
  def add(data = nil, &block)
14
+ @empty = false
13
15
  if block_given?
14
16
  @blocks << block
15
17
  elsif accepted_type?(data)
@@ -19,6 +21,12 @@ module Appsignal
19
21
  end
20
22
  end
21
23
 
24
+ # @api private
25
+ def set_empty_value!
26
+ @empty = true
27
+ @blocks.clear
28
+ end
29
+
22
30
  def value
23
31
  value = nil
24
32
  @blocks.map! do |block_or_value|
@@ -44,6 +52,11 @@ module Appsignal
44
52
  @blocks.any?
45
53
  end
46
54
 
55
+ # @api private
56
+ def empty?
57
+ @empty
58
+ end
59
+
47
60
  protected
48
61
 
49
62
  attr_reader :blocks
@@ -246,6 +246,14 @@ module Appsignal
246
246
  end
247
247
  alias :set_params :add_params
248
248
 
249
+ # @api private
250
+ # @since 4.0.0
251
+ # @return [void]
252
+ # @see Helpers::Instrumentation#set_empty_params!
253
+ def set_empty_params!
254
+ @params.set_empty_value!
255
+ end
256
+
249
257
  # Add parameters to the transaction if not already set.
250
258
  #
251
259
  # @api private
@@ -257,7 +265,7 @@ module Appsignal
257
265
  #
258
266
  # @see #add_params
259
267
  def add_params_if_nil(given_params = nil, &block)
260
- add_params(given_params, &block) unless @params.value?
268
+ add_params(given_params, &block) if !@params.value? && !@params.empty?
261
269
  end
262
270
  alias :set_params_if_nil :add_params_if_nil
263
271
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Appsignal
4
- VERSION = "4.0.0.beta.1"
4
+ VERSION = "4.0.0.beta.2"
5
5
  end
@@ -142,6 +142,45 @@ describe Appsignal::SampleData do
142
142
  end
143
143
  end
144
144
 
145
+ describe "#set_empty_value!" do
146
+ it "clears the set values" do
147
+ data.add(["abc"])
148
+ data.add(["def"])
149
+ data.set_empty_value!
150
+
151
+ expect(data.value).to be_nil
152
+ end
153
+
154
+ it "allows values to be added afterwards" do
155
+ data.add(["abc"])
156
+ data.set_empty_value!
157
+
158
+ expect(data.value).to be_nil
159
+
160
+ data.add(["def"])
161
+ expect(data.value).to eq(["def"])
162
+ end
163
+ end
164
+
165
+ describe "#cleared?" do
166
+ it "returns false if not cleared" do
167
+ expect(data.empty?).to be(false)
168
+ end
169
+
170
+ it "returns true if cleared" do
171
+ data.set_empty_value!
172
+
173
+ expect(data.empty?).to be(true)
174
+ end
175
+
176
+ it "returns false if cleared and then new values were added" do
177
+ data.set_empty_value!
178
+ data.add(["abc"])
179
+
180
+ expect(data.empty?).to be(false)
181
+ end
182
+ end
183
+
145
184
  describe "#duplicate" do
146
185
  it "duplicates the internal Hash state without modifying the original" do
147
186
  data = described_class.new(:my_key, Hash)
@@ -732,6 +732,17 @@ describe Appsignal::Transaction do
732
732
  expect(transaction).to include_params(preset_params)
733
733
  end
734
734
  end
735
+
736
+ context "when the params were set as an empty value" do
737
+ it "does not set params on the transaction" do
738
+ transaction.add_params("key1" => "value")
739
+ transaction.set_empty_params!
740
+ transaction.add_params_if_nil("key2" => "value")
741
+
742
+ transaction._sample
743
+ expect(transaction).to_not include_params
744
+ end
745
+ end
735
746
  end
736
747
 
737
748
  describe "#add_session_data" do
@@ -935,6 +935,23 @@ describe Appsignal do
935
935
  end
936
936
  end
937
937
 
938
+ describe ".set_empty_params!" do
939
+ before { start_agent }
940
+
941
+ context "with transaction" do
942
+ let(:transaction) { http_request_transaction }
943
+ before { set_current_transaction(transaction) }
944
+
945
+ it "marks parameters to be sent as an empty value" do
946
+ Appsignal.add_params("key1" => "value")
947
+ Appsignal.set_empty_params!
948
+
949
+ transaction._sample
950
+ expect(transaction).to_not include_params
951
+ end
952
+ end
953
+ end
954
+
938
955
  describe ".add_session_data" do
939
956
  before { start_agent }
940
957
 
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.0.0.beta.1
4
+ version: 4.0.0.beta.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Beekman