appsignal 3.6.5 → 3.7.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 +4 -4
 - data/.semaphore/semaphore.yml +417 -0
 - data/CHANGELOG.md +57 -0
 - data/build_matrix.yml +8 -0
 - data/ext/agent.rb +27 -27
 - data/ext/base.rb +3 -0
 - data/lib/appsignal/config.rb +20 -7
 - data/lib/appsignal/event_formatter.rb +0 -2
 - data/lib/appsignal/heartbeat.rb +71 -0
 - data/lib/appsignal/helpers/instrumentation.rb +5 -5
 - data/lib/appsignal/helpers/metrics.rb +2 -2
 - data/lib/appsignal/hooks/gvl.rb +1 -1
 - data/lib/appsignal/hooks/mri.rb +1 -1
 - data/lib/appsignal/hooks/sidekiq.rb +1 -1
 - data/lib/appsignal/hooks.rb +1 -1
 - data/lib/appsignal/integrations/railtie.rb +1 -1
 - data/lib/appsignal/probes.rb +268 -0
 - data/lib/appsignal/utils/stdout_and_logger_message.rb +17 -0
 - data/lib/appsignal/utils.rb +1 -1
 - data/lib/appsignal/version.rb +1 -1
 - data/lib/appsignal.rb +24 -4
 - data/spec/lib/appsignal/config_spec.rb +37 -10
 - data/spec/lib/appsignal/heartbeat_spec.rb +89 -0
 - data/spec/lib/appsignal/hooks/gvl_spec.rb +1 -1
 - data/spec/lib/appsignal/hooks/mri_spec.rb +1 -1
 - data/spec/lib/appsignal/hooks/puma_spec.rb +1 -1
 - data/spec/lib/appsignal/{minutely_spec.rb → probes_spec.rb} +206 -57
 - data/spec/lib/appsignal_spec.rb +31 -5
 - data/spec/lib/puma/appsignal_spec.rb +8 -2
 - data/spec/spec_helper.rb +2 -2
 - metadata +7 -6
 - data/lib/appsignal/minutely.rb +0 -206
 - data/lib/appsignal/utils/deprecation_message.rb +0 -16
 
| 
         @@ -1,11 +1,40 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            describe Appsignal:: 
     | 
| 
      
 1 
     | 
    
         
            +
            describe Appsignal::Probes do
         
     | 
| 
       2 
2 
     | 
    
         
             
              include WaitForHelper
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
     | 
    
         
            -
              before { Appsignal:: 
     | 
| 
      
 4 
     | 
    
         
            +
              before { Appsignal::Probes.probes.clear }
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
              context "Minutely constant" do
         
     | 
| 
      
 7 
     | 
    
         
            +
                let(:err_stream) { std_stream }
         
     | 
| 
      
 8 
     | 
    
         
            +
                let(:stderr) { err_stream.read }
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                it "returns the Probes constant calling the Minutely constant" do
         
     | 
| 
      
 11 
     | 
    
         
            +
                  silence { expect(Appsignal::Minutely).to be(Appsignal::Probes) }
         
     | 
| 
      
 12 
     | 
    
         
            +
                end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                it "prints a deprecation warning to STDERR" do
         
     | 
| 
      
 15 
     | 
    
         
            +
                  capture_std_streams(std_stream, err_stream) do
         
     | 
| 
      
 16 
     | 
    
         
            +
                    expect(Appsignal::Minutely).to be(Appsignal::Probes)
         
     | 
| 
      
 17 
     | 
    
         
            +
                  end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                  expect(stderr)
         
     | 
| 
      
 20 
     | 
    
         
            +
                    .to include("appsignal WARNING: The constant Appsignal::Minutely has been deprecated.")
         
     | 
| 
      
 21 
     | 
    
         
            +
                end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                it "logs a warning to STDERR" do
         
     | 
| 
      
 24 
     | 
    
         
            +
                  logs =
         
     | 
| 
      
 25 
     | 
    
         
            +
                    capture_logs do
         
     | 
| 
      
 26 
     | 
    
         
            +
                      silence do
         
     | 
| 
      
 27 
     | 
    
         
            +
                        expect(Appsignal::Minutely).to be(Appsignal::Probes)
         
     | 
| 
      
 28 
     | 
    
         
            +
                      end
         
     | 
| 
      
 29 
     | 
    
         
            +
                    end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                  expect(logs).to include("The constant Appsignal::Minutely has been deprecated.")
         
     | 
| 
      
 32 
     | 
    
         
            +
                end
         
     | 
| 
      
 33 
     | 
    
         
            +
              end
         
     | 
| 
       5 
34 
     | 
    
         | 
| 
       6 
35 
     | 
    
         
             
              it "returns a ProbeCollection" do
         
     | 
| 
       7 
     | 
    
         
            -
                expect(Appsignal:: 
     | 
| 
       8 
     | 
    
         
            -
                  .to be_instance_of(Appsignal:: 
     | 
| 
      
 36 
     | 
    
         
            +
                expect(Appsignal::Probes.probes)
         
     | 
| 
      
 37 
     | 
    
         
            +
                  .to be_instance_of(Appsignal::Probes::ProbeCollection)
         
     | 
| 
       9 
38 
     | 
    
         
             
              end
         
     | 
| 
       10 
39 
     | 
    
         | 
| 
       11 
40 
     | 
    
         
             
              describe ".start" do
         
     | 
| 
         @@ -43,16 +72,31 @@ describe Appsignal::Minutely do 
     | 
|
| 
       43 
72 
     | 
    
         
             
                let(:log) { log_contents(log_stream) }
         
     | 
| 
       44 
73 
     | 
    
         
             
                before do
         
     | 
| 
       45 
74 
     | 
    
         
             
                  Appsignal.internal_logger = test_logger(log_stream)
         
     | 
| 
       46 
     | 
    
         
            -
                   
     | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
       48 
     | 
    
         
            -
             
     | 
| 
      
 75 
     | 
    
         
            +
                  speed_up_tests!
         
     | 
| 
      
 76 
     | 
    
         
            +
                end
         
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
      
 78 
     | 
    
         
            +
                describe ".started?" do
         
     | 
| 
      
 79 
     | 
    
         
            +
                  it "returns true when the probes thread has been started" do
         
     | 
| 
      
 80 
     | 
    
         
            +
                    expect(Appsignal::Probes.started?).to be_falsy
         
     | 
| 
      
 81 
     | 
    
         
            +
                    Appsignal::Probes.register :my_probe, (lambda {})
         
     | 
| 
      
 82 
     | 
    
         
            +
                    Appsignal::Probes.start
         
     | 
| 
      
 83 
     | 
    
         
            +
                    expect(Appsignal::Probes.started?).to be_truthy
         
     | 
| 
      
 84 
     | 
    
         
            +
                  end
         
     | 
| 
      
 85 
     | 
    
         
            +
             
     | 
| 
      
 86 
     | 
    
         
            +
                  it "returns false when the probes thread has been stopped" do
         
     | 
| 
      
 87 
     | 
    
         
            +
                    Appsignal::Probes.register :my_probe, lambda {}
         
     | 
| 
      
 88 
     | 
    
         
            +
                    Appsignal::Probes.start
         
     | 
| 
      
 89 
     | 
    
         
            +
                    expect(Appsignal::Probes.started?).to be_truthy
         
     | 
| 
      
 90 
     | 
    
         
            +
                    Appsignal::Probes.stop
         
     | 
| 
      
 91 
     | 
    
         
            +
                    expect(Appsignal::Probes.started?).to be_falsy
         
     | 
| 
      
 92 
     | 
    
         
            +
                  end
         
     | 
| 
       49 
93 
     | 
    
         
             
                end
         
     | 
| 
       50 
94 
     | 
    
         | 
| 
       51 
95 
     | 
    
         
             
                context "with an instance of a class" do
         
     | 
| 
       52 
96 
     | 
    
         
             
                  it "calls the probe every <wait_time>" do
         
     | 
| 
       53 
97 
     | 
    
         
             
                    probe = MockProbe.new
         
     | 
| 
       54 
     | 
    
         
            -
                    Appsignal:: 
     | 
| 
       55 
     | 
    
         
            -
                    Appsignal:: 
     | 
| 
      
 98 
     | 
    
         
            +
                    Appsignal::Probes.register :my_probe, probe
         
     | 
| 
      
 99 
     | 
    
         
            +
                    Appsignal::Probes.start
         
     | 
| 
       56 
100 
     | 
    
         | 
| 
       57 
101 
     | 
    
         
             
                    wait_for("enough probe calls") { probe.calls >= 2 }
         
     | 
| 
       58 
102 
     | 
    
         
             
                    expect(log).to contains_log(:debug, "Gathering minutely metrics with 1 probe")
         
     | 
| 
         @@ -63,11 +107,11 @@ describe Appsignal::Minutely do 
     | 
|
| 
       63 
107 
     | 
    
         
             
                    it "does not initialize the probe" do
         
     | 
| 
       64 
108 
     | 
    
         
             
                      # Working probe which we can use to wait for X ticks
         
     | 
| 
       65 
109 
     | 
    
         
             
                      working_probe = ProbeWithoutDependency.new
         
     | 
| 
       66 
     | 
    
         
            -
                      Appsignal:: 
     | 
| 
      
 110 
     | 
    
         
            +
                      Appsignal::Probes.register :probe_without_dep, working_probe
         
     | 
| 
       67 
111 
     | 
    
         | 
| 
       68 
112 
     | 
    
         
             
                      probe = ProbeWithMissingDependency.new
         
     | 
| 
       69 
     | 
    
         
            -
                      Appsignal:: 
     | 
| 
       70 
     | 
    
         
            -
                      Appsignal:: 
     | 
| 
      
 113 
     | 
    
         
            +
                      Appsignal::Probes.register :probe_with_missing_dep, probe
         
     | 
| 
      
 114 
     | 
    
         
            +
                      Appsignal::Probes.start
         
     | 
| 
       71 
115 
     | 
    
         | 
| 
       72 
116 
     | 
    
         
             
                      wait_for("enough probe calls") { working_probe.calls >= 2 }
         
     | 
| 
       73 
117 
     | 
    
         
             
                      # Only counts initialized probes
         
     | 
| 
         @@ -83,8 +127,8 @@ describe Appsignal::Minutely do 
     | 
|
| 
       83 
127 
     | 
    
         
             
                    probe = MockProbe
         
     | 
| 
       84 
128 
     | 
    
         
             
                    probe_instance = MockProbe.new
         
     | 
| 
       85 
129 
     | 
    
         
             
                    expect(probe).to receive(:new).and_return(probe_instance)
         
     | 
| 
       86 
     | 
    
         
            -
                    Appsignal:: 
     | 
| 
       87 
     | 
    
         
            -
                    Appsignal:: 
     | 
| 
      
 130 
     | 
    
         
            +
                    Appsignal::Probes.register :my_probe, probe
         
     | 
| 
      
 131 
     | 
    
         
            +
                    Appsignal::Probes.start
         
     | 
| 
       88 
132 
     | 
    
         | 
| 
       89 
133 
     | 
    
         
             
                    wait_for("enough probe calls") { probe_instance.calls >= 2 }
         
     | 
| 
       90 
134 
     | 
    
         
             
                    expect(log).to contains_log(:debug, "Gathering minutely metrics with 1 probe")
         
     | 
| 
         @@ -97,11 +141,11 @@ describe Appsignal::Minutely do 
     | 
|
| 
       97 
141 
     | 
    
         
             
                      working_probe = ProbeWithoutDependency
         
     | 
| 
       98 
142 
     | 
    
         
             
                      working_probe_instance = working_probe.new
         
     | 
| 
       99 
143 
     | 
    
         
             
                      expect(working_probe).to receive(:new).and_return(working_probe_instance)
         
     | 
| 
       100 
     | 
    
         
            -
                      Appsignal:: 
     | 
| 
      
 144 
     | 
    
         
            +
                      Appsignal::Probes.register :probe_without_dep, working_probe
         
     | 
| 
       101 
145 
     | 
    
         | 
| 
       102 
146 
     | 
    
         
             
                      probe = ProbeWithMissingDependency
         
     | 
| 
       103 
     | 
    
         
            -
                      Appsignal:: 
     | 
| 
       104 
     | 
    
         
            -
                      Appsignal:: 
     | 
| 
      
 147 
     | 
    
         
            +
                      Appsignal::Probes.register :probe_with_missing_dep, probe
         
     | 
| 
      
 148 
     | 
    
         
            +
                      Appsignal::Probes.start
         
     | 
| 
       105 
149 
     | 
    
         | 
| 
       106 
150 
     | 
    
         
             
                      wait_for("enough probe calls") { working_probe_instance.calls >= 2 }
         
     | 
| 
       107 
151 
     | 
    
         
             
                      # Only counts initialized probes
         
     | 
| 
         @@ -117,11 +161,11 @@ describe Appsignal::Minutely do 
     | 
|
| 
       117 
161 
     | 
    
         
             
                      working_probe = ProbeWithoutDependency
         
     | 
| 
       118 
162 
     | 
    
         
             
                      working_probe_instance = working_probe.new
         
     | 
| 
       119 
163 
     | 
    
         
             
                      expect(working_probe).to receive(:new).and_return(working_probe_instance)
         
     | 
| 
       120 
     | 
    
         
            -
                      Appsignal:: 
     | 
| 
      
 164 
     | 
    
         
            +
                      Appsignal::Probes.register :probe_without_dep, working_probe
         
     | 
| 
       121 
165 
     | 
    
         | 
| 
       122 
166 
     | 
    
         
             
                      probe = BrokenProbeOnInitialize
         
     | 
| 
       123 
     | 
    
         
            -
                      Appsignal:: 
     | 
| 
       124 
     | 
    
         
            -
                      Appsignal:: 
     | 
| 
      
 167 
     | 
    
         
            +
                      Appsignal::Probes.register :broken_probe_on_initialize, probe
         
     | 
| 
      
 168 
     | 
    
         
            +
                      Appsignal::Probes.start
         
     | 
| 
       125 
169 
     | 
    
         | 
| 
       126 
170 
     | 
    
         
             
                      wait_for("enough probe calls") { working_probe_instance.calls >= 2 }
         
     | 
| 
       127 
171 
     | 
    
         
             
                      # Only counts initialized probes
         
     | 
| 
         @@ -142,8 +186,8 @@ describe Appsignal::Minutely do 
     | 
|
| 
       142 
186 
     | 
    
         
             
                  it "calls the lambda every <wait time>" do
         
     | 
| 
       143 
187 
     | 
    
         
             
                    calls = 0
         
     | 
| 
       144 
188 
     | 
    
         
             
                    probe = lambda { calls += 1 }
         
     | 
| 
       145 
     | 
    
         
            -
                    Appsignal:: 
     | 
| 
       146 
     | 
    
         
            -
                    Appsignal:: 
     | 
| 
      
 189 
     | 
    
         
            +
                    Appsignal::Probes.register :my_probe, probe
         
     | 
| 
      
 190 
     | 
    
         
            +
                    Appsignal::Probes.start
         
     | 
| 
       147 
191 
     | 
    
         | 
| 
       148 
192 
     | 
    
         
             
                    wait_for("enough probe calls") { calls >= 2 }
         
     | 
| 
       149 
193 
     | 
    
         
             
                    expect(log).to contains_log(:debug, "Gathering minutely metrics with 1 probe")
         
     | 
| 
         @@ -155,9 +199,9 @@ describe Appsignal::Minutely do 
     | 
|
| 
       155 
199 
     | 
    
         
             
                  it "logs the error and continues calling the probes every <wait_time>" do
         
     | 
| 
       156 
200 
     | 
    
         
             
                    probe = MockProbe.new
         
     | 
| 
       157 
201 
     | 
    
         
             
                    broken_probe = BrokenProbe.new
         
     | 
| 
       158 
     | 
    
         
            -
                    Appsignal:: 
     | 
| 
       159 
     | 
    
         
            -
                    Appsignal:: 
     | 
| 
       160 
     | 
    
         
            -
                    Appsignal:: 
     | 
| 
      
 202 
     | 
    
         
            +
                    Appsignal::Probes.register :my_probe, probe
         
     | 
| 
      
 203 
     | 
    
         
            +
                    Appsignal::Probes.register :broken_probe, broken_probe
         
     | 
| 
      
 204 
     | 
    
         
            +
                    Appsignal::Probes.start
         
     | 
| 
       161 
205 
     | 
    
         | 
| 
       162 
206 
     | 
    
         
             
                    wait_for("enough probe calls") { probe.calls >= 2 }
         
     | 
| 
       163 
207 
     | 
    
         
             
                    wait_for("enough broken_probe calls") { broken_probe.calls >= 2 }
         
     | 
| 
         @@ -174,53 +218,101 @@ describe Appsignal::Minutely do 
     | 
|
| 
       174 
218 
     | 
    
         
             
                it "ensures only one minutely probes thread is active at a time" do
         
     | 
| 
       175 
219 
     | 
    
         
             
                  alive_thread_counter = proc { Thread.list.reject { |t| t.status == "dead" }.length }
         
     | 
| 
       176 
220 
     | 
    
         
             
                  probe = MockProbe.new
         
     | 
| 
       177 
     | 
    
         
            -
                  Appsignal:: 
     | 
| 
      
 221 
     | 
    
         
            +
                  Appsignal::Probes.register :my_probe, probe
         
     | 
| 
       178 
222 
     | 
    
         
             
                  expect do
         
     | 
| 
       179 
     | 
    
         
            -
                    Appsignal:: 
     | 
| 
      
 223 
     | 
    
         
            +
                    Appsignal::Probes.start
         
     | 
| 
       180 
224 
     | 
    
         
             
                  end.to change { alive_thread_counter.call }.by(1)
         
     | 
| 
       181 
225 
     | 
    
         | 
| 
       182 
226 
     | 
    
         
             
                  wait_for("enough probe calls") { probe.calls >= 2 }
         
     | 
| 
       183 
     | 
    
         
            -
                  expect(Appsignal:: 
     | 
| 
       184 
     | 
    
         
            -
                  expect(Appsignal:: 
     | 
| 
      
 227 
     | 
    
         
            +
                  expect(Appsignal::Probes).to have_received(:initial_wait_time).once
         
     | 
| 
      
 228 
     | 
    
         
            +
                  expect(Appsignal::Probes).to have_received(:wait_time).at_least(:once)
         
     | 
| 
       185 
229 
     | 
    
         
             
                  expect(log).to contains_log(:debug, "Gathering minutely metrics with 1 probe")
         
     | 
| 
       186 
230 
     | 
    
         
             
                  expect(log).to contains_log(:debug, "Gathering minutely metrics with 'my_probe' probe")
         
     | 
| 
       187 
231 
     | 
    
         | 
| 
       188 
232 
     | 
    
         
             
                  # Starting twice in this spec, so expecting it more than once
         
     | 
| 
       189 
     | 
    
         
            -
                  expect(Appsignal:: 
     | 
| 
      
 233 
     | 
    
         
            +
                  expect(Appsignal::Probes).to have_received(:initial_wait_time).once
         
     | 
| 
       190 
234 
     | 
    
         
             
                  expect do
         
     | 
| 
       191 
235 
     | 
    
         
             
                    # Fetch old thread
         
     | 
| 
       192 
     | 
    
         
            -
                    thread = Appsignal:: 
     | 
| 
       193 
     | 
    
         
            -
                    Appsignal:: 
     | 
| 
      
 236 
     | 
    
         
            +
                    thread = Appsignal::Probes.instance_variable_get(:@thread)
         
     | 
| 
      
 237 
     | 
    
         
            +
                    Appsignal::Probes.start
         
     | 
| 
       194 
238 
     | 
    
         
             
                    thread&.join # Wait for old thread to exit
         
     | 
| 
       195 
239 
     | 
    
         
             
                  end.to_not(change { alive_thread_counter.call })
         
     | 
| 
       196 
240 
     | 
    
         
             
                end
         
     | 
| 
      
 241 
     | 
    
         
            +
             
     | 
| 
      
 242 
     | 
    
         
            +
                context "with thread already started" do
         
     | 
| 
      
 243 
     | 
    
         
            +
                  before do
         
     | 
| 
      
 244 
     | 
    
         
            +
                    allow(Appsignal::Probes).to receive(:initial_wait_time).and_return(0.00001)
         
     | 
| 
      
 245 
     | 
    
         
            +
                  end
         
     | 
| 
      
 246 
     | 
    
         
            +
             
     | 
| 
      
 247 
     | 
    
         
            +
                  it "auto starts probes added after the thread is started" do
         
     | 
| 
      
 248 
     | 
    
         
            +
                    Appsignal::Probes.start
         
     | 
| 
      
 249 
     | 
    
         
            +
                    wait_for("Probes thread to start") { Appsignal::Probes.started? }
         
     | 
| 
      
 250 
     | 
    
         
            +
             
     | 
| 
      
 251 
     | 
    
         
            +
                    calls = 0
         
     | 
| 
      
 252 
     | 
    
         
            +
                    probe = lambda { calls += 1 }
         
     | 
| 
      
 253 
     | 
    
         
            +
                    Appsignal::Probes.register :late_probe, probe
         
     | 
| 
      
 254 
     | 
    
         
            +
             
     | 
| 
      
 255 
     | 
    
         
            +
                    wait_for("enough probe calls") { calls >= 2 }
         
     | 
| 
      
 256 
     | 
    
         
            +
                    expect(log).to contains_log(:debug, "Gathering minutely metrics with 1 probe")
         
     | 
| 
      
 257 
     | 
    
         
            +
                    expect(log).to contains_log(:debug, "Gathering minutely metrics with 'late_probe' probe")
         
     | 
| 
      
 258 
     | 
    
         
            +
                  end
         
     | 
| 
      
 259 
     | 
    
         
            +
                end
         
     | 
| 
      
 260 
     | 
    
         
            +
              end
         
     | 
| 
      
 261 
     | 
    
         
            +
             
     | 
| 
      
 262 
     | 
    
         
            +
              describe ".unregister" do
         
     | 
| 
      
 263 
     | 
    
         
            +
                let(:log_stream) { StringIO.new }
         
     | 
| 
      
 264 
     | 
    
         
            +
                let(:log) { log_contents(log_stream) }
         
     | 
| 
      
 265 
     | 
    
         
            +
                before do
         
     | 
| 
      
 266 
     | 
    
         
            +
                  Appsignal.internal_logger = test_logger(log_stream)
         
     | 
| 
      
 267 
     | 
    
         
            +
                  speed_up_tests!
         
     | 
| 
      
 268 
     | 
    
         
            +
                end
         
     | 
| 
      
 269 
     | 
    
         
            +
             
     | 
| 
      
 270 
     | 
    
         
            +
                it "does not call the initialized probe after unregistering" do
         
     | 
| 
      
 271 
     | 
    
         
            +
                  probe1_calls = 0
         
     | 
| 
      
 272 
     | 
    
         
            +
                  probe2_calls = 0
         
     | 
| 
      
 273 
     | 
    
         
            +
                  probe1 = lambda { probe1_calls += 1 }
         
     | 
| 
      
 274 
     | 
    
         
            +
                  probe2 = lambda { probe2_calls += 1 }
         
     | 
| 
      
 275 
     | 
    
         
            +
                  Appsignal::Probes.register :probe1, probe1
         
     | 
| 
      
 276 
     | 
    
         
            +
                  Appsignal::Probes.register :probe2, probe2
         
     | 
| 
      
 277 
     | 
    
         
            +
                  Appsignal::Probes.start
         
     | 
| 
      
 278 
     | 
    
         
            +
                  wait_for("enough probe1 calls") { probe1_calls >= 2 }
         
     | 
| 
      
 279 
     | 
    
         
            +
                  wait_for("enough probe2 calls") { probe2_calls >= 2 }
         
     | 
| 
      
 280 
     | 
    
         
            +
             
     | 
| 
      
 281 
     | 
    
         
            +
                  Appsignal::Probes.unregister :probe2
         
     | 
| 
      
 282 
     | 
    
         
            +
                  probe1_calls = 0
         
     | 
| 
      
 283 
     | 
    
         
            +
                  probe2_calls = 0
         
     | 
| 
      
 284 
     | 
    
         
            +
                  # Check the probe 1 calls to make sure the probes have been called before
         
     | 
| 
      
 285 
     | 
    
         
            +
                  # testing if the unregistered probe has not been called
         
     | 
| 
      
 286 
     | 
    
         
            +
                  wait_for("enough probe1 calls") { probe1_calls >= 2 }
         
     | 
| 
      
 287 
     | 
    
         
            +
                  expect(probe2_calls).to eq(0)
         
     | 
| 
      
 288 
     | 
    
         
            +
                end
         
     | 
| 
       197 
289 
     | 
    
         
             
              end
         
     | 
| 
       198 
290 
     | 
    
         | 
| 
       199 
291 
     | 
    
         
             
              describe ".stop" do
         
     | 
| 
       200 
292 
     | 
    
         
             
                before do
         
     | 
| 
       201 
     | 
    
         
            -
                  allow(Appsignal:: 
     | 
| 
      
 293 
     | 
    
         
            +
                  allow(Appsignal::Probes).to receive(:initial_wait_time).and_return(0.001)
         
     | 
| 
       202 
294 
     | 
    
         
             
                end
         
     | 
| 
       203 
295 
     | 
    
         | 
| 
       204 
296 
     | 
    
         
             
                it "stops the minutely thread" do
         
     | 
| 
       205 
     | 
    
         
            -
                  Appsignal:: 
     | 
| 
       206 
     | 
    
         
            -
                  thread = Appsignal:: 
     | 
| 
      
 297 
     | 
    
         
            +
                  Appsignal::Probes.start
         
     | 
| 
      
 298 
     | 
    
         
            +
                  thread = Appsignal::Probes.instance_variable_get(:@thread)
         
     | 
| 
       207 
299 
     | 
    
         
             
                  expect(%w[sleep run]).to include(thread.status)
         
     | 
| 
       208 
     | 
    
         
            -
                  Appsignal:: 
     | 
| 
      
 300 
     | 
    
         
            +
                  Appsignal::Probes.stop
         
     | 
| 
       209 
301 
     | 
    
         
             
                  thread.join
         
     | 
| 
       210 
302 
     | 
    
         
             
                  expect(thread.status).to eql(false)
         
     | 
| 
       211 
303 
     | 
    
         
             
                end
         
     | 
| 
       212 
304 
     | 
    
         | 
| 
       213 
305 
     | 
    
         
             
                it "clears the probe instances array" do
         
     | 
| 
       214 
     | 
    
         
            -
                  Appsignal:: 
     | 
| 
       215 
     | 
    
         
            -
                  Appsignal:: 
     | 
| 
       216 
     | 
    
         
            -
                  thread = Appsignal:: 
     | 
| 
      
 306 
     | 
    
         
            +
                  Appsignal::Probes.register :my_probe, lambda {}
         
     | 
| 
      
 307 
     | 
    
         
            +
                  Appsignal::Probes.start
         
     | 
| 
      
 308 
     | 
    
         
            +
                  thread = Appsignal::Probes.instance_variable_get(:@thread)
         
     | 
| 
       217 
309 
     | 
    
         
             
                  wait_for("probes initialized") do
         
     | 
| 
       218 
     | 
    
         
            -
                    !Appsignal:: 
     | 
| 
      
 310 
     | 
    
         
            +
                    !Appsignal::Probes.send(:probe_instances).empty?
         
     | 
| 
       219 
311 
     | 
    
         
             
                  end
         
     | 
| 
       220 
     | 
    
         
            -
                  expect(Appsignal:: 
     | 
| 
       221 
     | 
    
         
            -
                  Appsignal:: 
     | 
| 
      
 312 
     | 
    
         
            +
                  expect(Appsignal::Probes.send(:probe_instances)).to_not be_empty
         
     | 
| 
      
 313 
     | 
    
         
            +
                  Appsignal::Probes.stop
         
     | 
| 
       222 
314 
     | 
    
         
             
                  thread.join
         
     | 
| 
       223 
     | 
    
         
            -
                  expect(Appsignal:: 
     | 
| 
      
 315 
     | 
    
         
            +
                  expect(Appsignal::Probes.send(:probe_instances)).to be_empty
         
     | 
| 
       224 
316 
     | 
    
         
             
                end
         
     | 
| 
       225 
317 
     | 
    
         
             
              end
         
     | 
| 
       226 
318 
     | 
    
         | 
| 
         @@ -228,7 +320,7 @@ describe Appsignal::Minutely do 
     | 
|
| 
       228 
320 
     | 
    
         
             
                it "gets the time to the next minute" do
         
     | 
| 
       229 
321 
     | 
    
         
             
                  time = Time.new(2019, 4, 9, 12, 0, 20)
         
     | 
| 
       230 
322 
     | 
    
         
             
                  Timecop.freeze time do
         
     | 
| 
       231 
     | 
    
         
            -
                    expect(Appsignal:: 
     | 
| 
      
 323 
     | 
    
         
            +
                    expect(Appsignal::Probes.wait_time).to eq 40
         
     | 
| 
       232 
324 
     | 
    
         
             
                  end
         
     | 
| 
       233 
325 
     | 
    
         
             
                end
         
     | 
| 
       234 
326 
     | 
    
         
             
              end
         
     | 
| 
         @@ -238,7 +330,7 @@ describe Appsignal::Minutely do 
     | 
|
| 
       238 
330 
     | 
    
         
             
                  it "waits for the number of seconds + 60" do
         
     | 
| 
       239 
331 
     | 
    
         
             
                    time = Time.new(2019, 4, 9, 12, 0, 31)
         
     | 
| 
       240 
332 
     | 
    
         
             
                    Timecop.freeze time do
         
     | 
| 
       241 
     | 
    
         
            -
                      expect(Appsignal:: 
     | 
| 
      
 333 
     | 
    
         
            +
                      expect(Appsignal::Probes.send(:initial_wait_time)).to eql(29 + 60)
         
     | 
| 
       242 
334 
     | 
    
         
             
                    end
         
     | 
| 
       243 
335 
     | 
    
         
             
                  end
         
     | 
| 
       244 
336 
     | 
    
         
             
                end
         
     | 
| 
         @@ -247,29 +339,29 @@ describe Appsignal::Minutely do 
     | 
|
| 
       247 
339 
     | 
    
         
             
                  it "waits the remaining seconds in the minute" do
         
     | 
| 
       248 
340 
     | 
    
         
             
                    time = Time.new(2019, 4, 9, 12, 0, 29)
         
     | 
| 
       249 
341 
     | 
    
         
             
                    Timecop.freeze time do
         
     | 
| 
       250 
     | 
    
         
            -
                      expect(Appsignal:: 
     | 
| 
      
 342 
     | 
    
         
            +
                      expect(Appsignal::Probes.send(:initial_wait_time)).to eql(31)
         
     | 
| 
       251 
343 
     | 
    
         
             
                    end
         
     | 
| 
       252 
344 
     | 
    
         
             
                  end
         
     | 
| 
       253 
345 
     | 
    
         
             
                end
         
     | 
| 
       254 
346 
     | 
    
         
             
              end
         
     | 
| 
       255 
347 
     | 
    
         | 
| 
       256 
     | 
    
         
            -
              describe Appsignal:: 
     | 
| 
      
 348 
     | 
    
         
            +
              describe Appsignal::Probes::ProbeCollection do
         
     | 
| 
       257 
349 
     | 
    
         
             
                let(:collection) { described_class.new }
         
     | 
| 
       258 
350 
     | 
    
         | 
| 
       259 
351 
     | 
    
         
             
                describe "#count" do
         
     | 
| 
       260 
352 
     | 
    
         
             
                  it "returns how many probes are registered" do
         
     | 
| 
       261 
353 
     | 
    
         
             
                    expect(collection.count).to eql(0)
         
     | 
| 
       262 
     | 
    
         
            -
                    collection. 
     | 
| 
      
 354 
     | 
    
         
            +
                    collection.internal_register :my_probe_1, lambda {}
         
     | 
| 
       263 
355 
     | 
    
         
             
                    expect(collection.count).to eql(1)
         
     | 
| 
       264 
     | 
    
         
            -
                    collection. 
     | 
| 
      
 356 
     | 
    
         
            +
                    collection.internal_register :my_probe_2, lambda {}
         
     | 
| 
       265 
357 
     | 
    
         
             
                    expect(collection.count).to eql(2)
         
     | 
| 
       266 
358 
     | 
    
         
             
                  end
         
     | 
| 
       267 
359 
     | 
    
         
             
                end
         
     | 
| 
       268 
360 
     | 
    
         | 
| 
       269 
361 
     | 
    
         
             
                describe "#clear" do
         
     | 
| 
       270 
362 
     | 
    
         
             
                  it "clears the list of probes" do
         
     | 
| 
       271 
     | 
    
         
            -
                    collection. 
     | 
| 
       272 
     | 
    
         
            -
                    collection. 
     | 
| 
      
 363 
     | 
    
         
            +
                    collection.internal_register :my_probe_1, lambda {}
         
     | 
| 
      
 364 
     | 
    
         
            +
                    collection.internal_register :my_probe_2, lambda {}
         
     | 
| 
       273 
365 
     | 
    
         
             
                    expect(collection.count).to eql(2)
         
     | 
| 
       274 
366 
     | 
    
         
             
                    collection.clear
         
     | 
| 
       275 
367 
     | 
    
         
             
                    expect(collection.count).to eql(0)
         
     | 
| 
         @@ -279,27 +371,65 @@ describe Appsignal::Minutely do 
     | 
|
| 
       279 
371 
     | 
    
         
             
                describe "#[]" do
         
     | 
| 
       280 
372 
     | 
    
         
             
                  it "returns the probe for that name" do
         
     | 
| 
       281 
373 
     | 
    
         
             
                    probe = lambda {}
         
     | 
| 
       282 
     | 
    
         
            -
                    collection. 
     | 
| 
      
 374 
     | 
    
         
            +
                    collection.internal_register :my_probe, probe
         
     | 
| 
       283 
375 
     | 
    
         
             
                    expect(collection[:my_probe]).to eql(probe)
         
     | 
| 
       284 
376 
     | 
    
         
             
                  end
         
     | 
| 
       285 
377 
     | 
    
         
             
                end
         
     | 
| 
       286 
378 
     | 
    
         | 
| 
       287 
379 
     | 
    
         
             
                describe "#register" do
         
     | 
| 
      
 380 
     | 
    
         
            +
                  it "adds the probe by key" do
         
     | 
| 
      
 381 
     | 
    
         
            +
                    expect(Appsignal::Probes).to receive(:probes).and_return(collection)
         
     | 
| 
      
 382 
     | 
    
         
            +
             
     | 
| 
      
 383 
     | 
    
         
            +
                    probe = lambda {}
         
     | 
| 
      
 384 
     | 
    
         
            +
                    silence { collection.register :my_probe, probe }
         
     | 
| 
      
 385 
     | 
    
         
            +
                    expect(collection[:my_probe]).to eql(probe)
         
     | 
| 
      
 386 
     | 
    
         
            +
                  end
         
     | 
| 
      
 387 
     | 
    
         
            +
             
     | 
| 
      
 388 
     | 
    
         
            +
                  context "logger" do
         
     | 
| 
      
 389 
     | 
    
         
            +
                    let(:log_stream) { std_stream }
         
     | 
| 
      
 390 
     | 
    
         
            +
                    let(:log) { log_contents(log_stream) }
         
     | 
| 
      
 391 
     | 
    
         
            +
             
     | 
| 
      
 392 
     | 
    
         
            +
                    around { |example| use_logger_with(log_stream) { example.run } }
         
     | 
| 
      
 393 
     | 
    
         
            +
                    it "logs a deprecation message" do
         
     | 
| 
      
 394 
     | 
    
         
            +
                      silence { collection.register :my_probe, lambda {} }
         
     | 
| 
      
 395 
     | 
    
         
            +
                      expect(log).to contains_log :warn,
         
     | 
| 
      
 396 
     | 
    
         
            +
                        "The method 'Appsignal::Probes.probes.register' is deprecated. " \
         
     | 
| 
      
 397 
     | 
    
         
            +
                          "Use 'Appsignal::Probes.register' instead."
         
     | 
| 
      
 398 
     | 
    
         
            +
                    end
         
     | 
| 
      
 399 
     | 
    
         
            +
                  end
         
     | 
| 
      
 400 
     | 
    
         
            +
             
     | 
| 
      
 401 
     | 
    
         
            +
                  context "stderr" do
         
     | 
| 
      
 402 
     | 
    
         
            +
                    let(:err_stream) { std_stream }
         
     | 
| 
      
 403 
     | 
    
         
            +
                    let(:stderr) { err_stream.read }
         
     | 
| 
      
 404 
     | 
    
         
            +
             
     | 
| 
      
 405 
     | 
    
         
            +
                    it "prints a deprecation warning" do
         
     | 
| 
      
 406 
     | 
    
         
            +
                      capture_std_streams(std_stream, err_stream) do
         
     | 
| 
      
 407 
     | 
    
         
            +
                        collection.register :my_probe, lambda {}
         
     | 
| 
      
 408 
     | 
    
         
            +
                      end
         
     | 
| 
      
 409 
     | 
    
         
            +
                      deprecation_message =
         
     | 
| 
      
 410 
     | 
    
         
            +
                        "The method 'Appsignal::Probes.probes.register' is deprecated. " \
         
     | 
| 
      
 411 
     | 
    
         
            +
                          "Use 'Appsignal::Probes.register' instead."
         
     | 
| 
      
 412 
     | 
    
         
            +
                      expect(stderr).to include("appsignal WARNING: #{deprecation_message}")
         
     | 
| 
      
 413 
     | 
    
         
            +
                    end
         
     | 
| 
      
 414 
     | 
    
         
            +
                  end
         
     | 
| 
      
 415 
     | 
    
         
            +
                end
         
     | 
| 
      
 416 
     | 
    
         
            +
             
     | 
| 
      
 417 
     | 
    
         
            +
                describe "#internal_register" do
         
     | 
| 
       288 
418 
     | 
    
         
             
                  let(:log_stream) { std_stream }
         
     | 
| 
       289 
419 
     | 
    
         
             
                  let(:log) { log_contents(log_stream) }
         
     | 
| 
       290 
420 
     | 
    
         
             
                  before { Appsignal.internal_logger = test_logger(log_stream) }
         
     | 
| 
       291 
421 
     | 
    
         | 
| 
       292 
     | 
    
         
            -
                  it "adds the by key 
     | 
| 
      
 422 
     | 
    
         
            +
                  it "adds the probe by key" do
         
     | 
| 
       293 
423 
     | 
    
         
             
                    probe = lambda {}
         
     | 
| 
       294 
     | 
    
         
            -
                    collection. 
     | 
| 
      
 424 
     | 
    
         
            +
                    collection.internal_register :my_probe, probe
         
     | 
| 
       295 
425 
     | 
    
         
             
                    expect(collection[:my_probe]).to eql(probe)
         
     | 
| 
       296 
426 
     | 
    
         
             
                  end
         
     | 
| 
       297 
427 
     | 
    
         | 
| 
       298 
428 
     | 
    
         
             
                  context "when a probe is already registered with the same key" do
         
     | 
| 
       299 
429 
     | 
    
         
             
                    it "logs a debug message" do
         
     | 
| 
       300 
430 
     | 
    
         
             
                      probe = lambda {}
         
     | 
| 
       301 
     | 
    
         
            -
                      collection. 
     | 
| 
       302 
     | 
    
         
            -
                      collection. 
     | 
| 
      
 431 
     | 
    
         
            +
                      collection.internal_register :my_probe, probe
         
     | 
| 
      
 432 
     | 
    
         
            +
                      collection.internal_register :my_probe, probe
         
     | 
| 
       303 
433 
     | 
    
         
             
                      expect(log).to contains_log :debug, "A probe with the name " \
         
     | 
| 
       304 
434 
     | 
    
         
             
                        "`my_probe` is already registered. Overwriting the entry " \
         
     | 
| 
       305 
435 
     | 
    
         
             
                        "with the new probe."
         
     | 
| 
         @@ -308,10 +438,23 @@ describe Appsignal::Minutely do 
     | 
|
| 
       308 
438 
     | 
    
         
             
                  end
         
     | 
| 
       309 
439 
     | 
    
         
             
                end
         
     | 
| 
       310 
440 
     | 
    
         | 
| 
      
 441 
     | 
    
         
            +
                describe "#unregister" do
         
     | 
| 
      
 442 
     | 
    
         
            +
                  it "removes the probe from the collection" do
         
     | 
| 
      
 443 
     | 
    
         
            +
                    expect(Appsignal::Probes).to receive(:probes).and_return(collection)
         
     | 
| 
      
 444 
     | 
    
         
            +
             
     | 
| 
      
 445 
     | 
    
         
            +
                    probe = lambda {}
         
     | 
| 
      
 446 
     | 
    
         
            +
                    silence { collection.register :my_probe, probe }
         
     | 
| 
      
 447 
     | 
    
         
            +
                    expect(collection[:my_probe]).to eql(probe)
         
     | 
| 
      
 448 
     | 
    
         
            +
             
     | 
| 
      
 449 
     | 
    
         
            +
                    silence { collection.unregister :my_probe }
         
     | 
| 
      
 450 
     | 
    
         
            +
                    expect(collection[:my_probe]).to be_nil
         
     | 
| 
      
 451 
     | 
    
         
            +
                  end
         
     | 
| 
      
 452 
     | 
    
         
            +
                end
         
     | 
| 
      
 453 
     | 
    
         
            +
             
     | 
| 
       311 
454 
     | 
    
         
             
                describe "#each" do
         
     | 
| 
       312 
455 
     | 
    
         
             
                  it "loops over the registered probes" do
         
     | 
| 
       313 
456 
     | 
    
         
             
                    probe = lambda {}
         
     | 
| 
       314 
     | 
    
         
            -
                    collection. 
     | 
| 
      
 457 
     | 
    
         
            +
                    collection.internal_register :my_probe, probe
         
     | 
| 
       315 
458 
     | 
    
         
             
                    list = []
         
     | 
| 
       316 
459 
     | 
    
         
             
                    collection.each do |name, p|
         
     | 
| 
       317 
460 
     | 
    
         
             
                      list << [name, p]
         
     | 
| 
         @@ -320,4 +463,10 @@ describe Appsignal::Minutely do 
     | 
|
| 
       320 
463 
     | 
    
         
             
                  end
         
     | 
| 
       321 
464 
     | 
    
         
             
                end
         
     | 
| 
       322 
465 
     | 
    
         
             
              end
         
     | 
| 
      
 466 
     | 
    
         
            +
             
     | 
| 
      
 467 
     | 
    
         
            +
              # Speed up test time by decreasing wait times in the probes mechanism
         
     | 
| 
      
 468 
     | 
    
         
            +
              def speed_up_tests!
         
     | 
| 
      
 469 
     | 
    
         
            +
                allow(Appsignal::Probes).to receive(:initial_wait_time).and_return(0.001)
         
     | 
| 
      
 470 
     | 
    
         
            +
                allow(Appsignal::Probes).to receive(:wait_time).and_return(0.001)
         
     | 
| 
      
 471 
     | 
    
         
            +
              end
         
     | 
| 
       323 
472 
     | 
    
         
             
            end
         
     | 
    
        data/spec/lib/appsignal_spec.rb
    CHANGED
    
    | 
         @@ -87,7 +87,7 @@ describe Appsignal do 
     | 
|
| 
       87 
87 
     | 
    
         
             
                    end
         
     | 
| 
       88 
88 
     | 
    
         | 
| 
       89 
89 
     | 
    
         
             
                    it "should start minutely" do
         
     | 
| 
       90 
     | 
    
         
            -
                      expect(Appsignal:: 
     | 
| 
      
 90 
     | 
    
         
            +
                      expect(Appsignal::Probes).to receive(:start)
         
     | 
| 
       91 
91 
     | 
    
         
             
                      Appsignal.start
         
     | 
| 
       92 
92 
     | 
    
         
             
                    end
         
     | 
| 
       93 
93 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -98,7 +98,7 @@ describe Appsignal do 
     | 
|
| 
       98 
98 
     | 
    
         
             
                    end
         
     | 
| 
       99 
99 
     | 
    
         | 
| 
       100 
100 
     | 
    
         
             
                    it "should not start minutely" do
         
     | 
| 
       101 
     | 
    
         
            -
                      expect(Appsignal:: 
     | 
| 
      
 101 
     | 
    
         
            +
                      expect(Appsignal::Probes).to_not receive(:start)
         
     | 
| 
       102 
102 
     | 
    
         
             
                      Appsignal.start
         
     | 
| 
       103 
103 
     | 
    
         
             
                    end
         
     | 
| 
       104 
104 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -151,13 +151,20 @@ describe Appsignal do 
     | 
|
| 
       151 
151 
     | 
    
         
             
              end
         
     | 
| 
       152 
152 
     | 
    
         | 
| 
       153 
153 
     | 
    
         
             
              describe ".stop" do
         
     | 
| 
       154 
     | 
    
         
            -
                it " 
     | 
| 
      
 154 
     | 
    
         
            +
                it "calls stop on the extension" do
         
     | 
| 
       155 
155 
     | 
    
         
             
                  expect(Appsignal.internal_logger).to receive(:debug).with("Stopping appsignal")
         
     | 
| 
       156 
156 
     | 
    
         
             
                  expect(Appsignal::Extension).to receive(:stop)
         
     | 
| 
       157 
157 
     | 
    
         
             
                  Appsignal.stop
         
     | 
| 
       158 
158 
     | 
    
         
             
                  expect(Appsignal.active?).to be_falsy
         
     | 
| 
       159 
159 
     | 
    
         
             
                end
         
     | 
| 
       160 
160 
     | 
    
         | 
| 
      
 161 
     | 
    
         
            +
                it "stops the minutely probes" do
         
     | 
| 
      
 162 
     | 
    
         
            +
                  Appsignal::Probes.start
         
     | 
| 
      
 163 
     | 
    
         
            +
                  expect(Appsignal::Probes.started?).to be_truthy
         
     | 
| 
      
 164 
     | 
    
         
            +
                  Appsignal.stop
         
     | 
| 
      
 165 
     | 
    
         
            +
                  expect(Appsignal::Probes.started?).to be_falsy
         
     | 
| 
      
 166 
     | 
    
         
            +
                end
         
     | 
| 
      
 167 
     | 
    
         
            +
             
     | 
| 
       161 
168 
     | 
    
         
             
                context "with context specified" do
         
     | 
| 
       162 
169 
     | 
    
         
             
                  it "should log the context" do
         
     | 
| 
       163 
170 
     | 
    
         
             
                    expect(Appsignal.internal_logger).to receive(:debug).with("Stopping appsignal (something)")
         
     | 
| 
         @@ -1121,7 +1128,14 @@ describe Appsignal do 
     | 
|
| 
       1121 
1128 
     | 
    
         
             
                let(:log_path) { File.join(tmp_dir, "log") }
         
     | 
| 
       1122 
1129 
     | 
    
         
             
                let(:log_file) { File.join(log_path, "appsignal.log") }
         
     | 
| 
       1123 
1130 
     | 
    
         | 
| 
       1124 
     | 
    
         
            -
                before  
     | 
| 
      
 1131 
     | 
    
         
            +
                before do
         
     | 
| 
      
 1132 
     | 
    
         
            +
                  FileUtils.mkdir_p(log_path)
         
     | 
| 
      
 1133 
     | 
    
         
            +
                  # Clear state from previous test
         
     | 
| 
      
 1134 
     | 
    
         
            +
                  Appsignal.internal_logger = nil
         
     | 
| 
      
 1135 
     | 
    
         
            +
                  if Appsignal.instance_variable_defined?(:@in_memory_log)
         
     | 
| 
      
 1136 
     | 
    
         
            +
                    Appsignal.remove_instance_variable(:@in_memory_log)
         
     | 
| 
      
 1137 
     | 
    
         
            +
                  end
         
     | 
| 
      
 1138 
     | 
    
         
            +
                end
         
     | 
| 
       1125 
1139 
     | 
    
         
             
                after { FileUtils.rm_rf(log_path) }
         
     | 
| 
       1126 
1140 
     | 
    
         | 
| 
       1127 
1141 
     | 
    
         
             
                def initialize_config
         
     | 
| 
         @@ -1130,6 +1144,7 @@ describe Appsignal do 
     | 
|
| 
       1130 
1144 
     | 
    
         
             
                    :log_path => log_path
         
     | 
| 
       1131 
1145 
     | 
    
         
             
                  )
         
     | 
| 
       1132 
1146 
     | 
    
         
             
                  Appsignal.internal_logger.error("Log in memory")
         
     | 
| 
      
 1147 
     | 
    
         
            +
                  expect(Appsignal.in_memory_log.string).to_not be_empty
         
     | 
| 
       1133 
1148 
     | 
    
         
             
                end
         
     | 
| 
       1134 
1149 
     | 
    
         | 
| 
       1135 
1150 
     | 
    
         
             
                context "when the log path is writable" do
         
     | 
| 
         @@ -1154,6 +1169,10 @@ describe Appsignal do 
     | 
|
| 
       1154 
1169 
     | 
    
         
             
                    it "amends in memory log to log file" do
         
     | 
| 
       1155 
1170 
     | 
    
         
             
                      expect(log_file_contents).to include "[ERROR] appsignal: Log in memory"
         
     | 
| 
       1156 
1171 
     | 
    
         
             
                    end
         
     | 
| 
      
 1172 
     | 
    
         
            +
             
     | 
| 
      
 1173 
     | 
    
         
            +
                    it "clears the in memory log after writing to the new logger" do
         
     | 
| 
      
 1174 
     | 
    
         
            +
                      expect(Appsignal.in_memory_log.string).to be_empty
         
     | 
| 
      
 1175 
     | 
    
         
            +
                    end
         
     | 
| 
       1157 
1176 
     | 
    
         
             
                  end
         
     | 
| 
       1158 
1177 
     | 
    
         | 
| 
       1159 
1178 
     | 
    
         
             
                  context "when the log file is not writable" do
         
     | 
| 
         @@ -1178,8 +1197,11 @@ describe Appsignal do 
     | 
|
| 
       1178 
1197 
     | 
    
         
             
                      expect(output).to include "[ERROR] appsignal: Log in memory"
         
     | 
| 
       1179 
1198 
     | 
    
         
             
                    end
         
     | 
| 
       1180 
1199 
     | 
    
         | 
| 
      
 1200 
     | 
    
         
            +
                    it "clears the in memory log after writing to the new logger" do
         
     | 
| 
      
 1201 
     | 
    
         
            +
                      expect(Appsignal.in_memory_log.string).to be_empty
         
     | 
| 
      
 1202 
     | 
    
         
            +
                    end
         
     | 
| 
      
 1203 
     | 
    
         
            +
             
     | 
| 
       1181 
1204 
     | 
    
         
             
                    it "outputs a warning" do
         
     | 
| 
       1182 
     | 
    
         
            -
                      puts output
         
     | 
| 
       1183 
1205 
     | 
    
         
             
                      expect(output).to include \
         
     | 
| 
       1184 
1206 
     | 
    
         
             
                        "[WARN] appsignal: Unable to start internal logger with log path '#{log_file}'.",
         
     | 
| 
       1185 
1207 
     | 
    
         
             
                        "[WARN] appsignal: Permission denied"
         
     | 
| 
         @@ -1237,6 +1259,10 @@ describe Appsignal do 
     | 
|
| 
       1237 
1259 
     | 
    
         
             
                  it "amends in memory log to stdout" do
         
     | 
| 
       1238 
1260 
     | 
    
         
             
                    expect(output).to include "[ERROR] appsignal: Log in memory"
         
     | 
| 
       1239 
1261 
     | 
    
         
             
                  end
         
     | 
| 
      
 1262 
     | 
    
         
            +
             
     | 
| 
      
 1263 
     | 
    
         
            +
                  it "clears the in memory log after writing to the new logger" do
         
     | 
| 
      
 1264 
     | 
    
         
            +
                    expect(Appsignal.in_memory_log.string).to be_empty
         
     | 
| 
      
 1265 
     | 
    
         
            +
                  end
         
     | 
| 
       1240 
1266 
     | 
    
         
             
                end
         
     | 
| 
       1241 
1267 
     | 
    
         | 
| 
       1242 
1268 
     | 
    
         
             
                describe "#logger#level" do
         
     | 
| 
         @@ -32,10 +32,14 @@ RSpec.describe "Puma plugin" do 
     | 
|
| 
       32 
32 
     | 
    
         
             
              # StatsD server used for these tests.
         
     | 
| 
       33 
33 
     | 
    
         
             
              # Open a UDPSocket and listen for messages sent by the AppSignal Puma plugin.
         
     | 
| 
       34 
34 
     | 
    
         
             
              class StatsdServer
         
     | 
| 
      
 35 
     | 
    
         
            +
                def initialize(statsd_port)
         
     | 
| 
      
 36 
     | 
    
         
            +
                  @statsd_port = statsd_port
         
     | 
| 
      
 37 
     | 
    
         
            +
                end
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
       35 
39 
     | 
    
         
             
                def start
         
     | 
| 
       36 
40 
     | 
    
         
             
                  stop
         
     | 
| 
       37 
41 
     | 
    
         
             
                  @socket = UDPSocket.new
         
     | 
| 
       38 
     | 
    
         
            -
                  @socket.bind("127.0.0.1",  
     | 
| 
      
 42 
     | 
    
         
            +
                  @socket.bind("127.0.0.1", @statsd_port)
         
     | 
| 
       39 
43 
     | 
    
         | 
| 
       40 
44 
     | 
    
         
             
                  loop do
         
     | 
| 
       41 
45 
     | 
    
         
             
                    # Listen for messages and track them on the messages Array.
         
     | 
| 
         @@ -115,13 +119,15 @@ RSpec.describe "Puma plugin" do 
     | 
|
| 
       115 
119 
     | 
    
         | 
| 
       116 
120 
     | 
    
         
             
              def run_plugin(stats_data, plugin, &block)
         
     | 
| 
       117 
121 
     | 
    
         
             
                Puma._set_stats = stats_data
         
     | 
| 
       118 
     | 
    
         
            -
                 
     | 
| 
      
 122 
     | 
    
         
            +
                ENV["APPSIGNAL_STATSD_PORT"] = "8126"
         
     | 
| 
      
 123 
     | 
    
         
            +
                @statsd = StatsdServer.new(ENV.fetch("APPSIGNAL_STATSD_PORT"))
         
     | 
| 
       119 
124 
     | 
    
         
             
                @server_thread = Thread.new { @statsd.start }
         
     | 
| 
       120 
125 
     | 
    
         
             
                @server_thread.abort_on_exception = true
         
     | 
| 
       121 
126 
     | 
    
         
             
                @client_thread = Thread.new { start_plugin(plugin) }
         
     | 
| 
       122 
127 
     | 
    
         
             
                @client_thread.abort_on_exception = true
         
     | 
| 
       123 
128 
     | 
    
         
             
                wait_for(:puma_client_wait, &block)
         
     | 
| 
       124 
129 
     | 
    
         
             
              ensure
         
     | 
| 
      
 130 
     | 
    
         
            +
                ENV["APPSIGNAL_STATSD_PORT"] = nil
         
     | 
| 
       125 
131 
     | 
    
         
             
                Puma._set_stats = nil
         
     | 
| 
       126 
132 
     | 
    
         
             
                # Stop all threads in test and stop listening on the UDPSocket
         
     | 
| 
       127 
133 
     | 
    
         
             
                @client_thread.kill if defined?(@client_thread) && @client_thread
         
     | 
    
        data/spec/spec_helper.rb
    CHANGED
    
    | 
         @@ -171,11 +171,11 @@ RSpec.configure do |config| 
     | 
|
| 
       171 
171 
     | 
    
         
             
              def stop_minutely_probes
         
     | 
| 
       172 
172 
     | 
    
         
             
                thread =
         
     | 
| 
       173 
173 
     | 
    
         
             
                  begin
         
     | 
| 
       174 
     | 
    
         
            -
                    Appsignal:: 
     | 
| 
      
 174 
     | 
    
         
            +
                    Appsignal::Probes.class_variable_get(:@@thread) # Fetch old thread
         
     | 
| 
       175 
175 
     | 
    
         
             
                  rescue NameError
         
     | 
| 
       176 
176 
     | 
    
         
             
                    nil
         
     | 
| 
       177 
177 
     | 
    
         
             
                  end
         
     | 
| 
       178 
     | 
    
         
            -
                Appsignal:: 
     | 
| 
      
 178 
     | 
    
         
            +
                Appsignal::Probes.stop
         
     | 
| 
       179 
179 
     | 
    
         
             
                thread&.join # Wait for old thread to exit
         
     | 
| 
       180 
180 
     | 
    
         
             
              end
         
     | 
| 
       181 
181 
     | 
    
         
             
            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: 3. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 3.7.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-04- 
     | 
| 
      
 13 
     | 
    
         
            +
            date: 2024-04-29 00:00:00.000000000 Z
         
     | 
| 
       14 
14 
     | 
    
         
             
            dependencies:
         
     | 
| 
       15 
15 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       16 
16 
     | 
    
         
             
              name: rack
         
     | 
| 
         @@ -206,6 +206,7 @@ files: 
     | 
|
| 
       206 
206 
     | 
    
         
             
            - lib/appsignal/extension.rb
         
     | 
| 
       207 
207 
     | 
    
         
             
            - lib/appsignal/extension/jruby.rb
         
     | 
| 
       208 
208 
     | 
    
         
             
            - lib/appsignal/garbage_collection.rb
         
     | 
| 
      
 209 
     | 
    
         
            +
            - lib/appsignal/heartbeat.rb
         
     | 
| 
       209 
210 
     | 
    
         
             
            - lib/appsignal/helpers/instrumentation.rb
         
     | 
| 
       210 
211 
     | 
    
         
             
            - lib/appsignal/helpers/metrics.rb
         
     | 
| 
       211 
212 
     | 
    
         
             
            - lib/appsignal/hooks.rb
         
     | 
| 
         @@ -262,7 +263,6 @@ files: 
     | 
|
| 
       262 
263 
     | 
    
         
             
            - lib/appsignal/integrations/webmachine.rb
         
     | 
| 
       263 
264 
     | 
    
         
             
            - lib/appsignal/logger.rb
         
     | 
| 
       264 
265 
     | 
    
         
             
            - lib/appsignal/marker.rb
         
     | 
| 
       265 
     | 
    
         
            -
            - lib/appsignal/minutely.rb
         
     | 
| 
       266 
266 
     | 
    
         
             
            - lib/appsignal/probes.rb
         
     | 
| 
       267 
267 
     | 
    
         
             
            - lib/appsignal/probes/gvl.rb
         
     | 
| 
       268 
268 
     | 
    
         
             
            - lib/appsignal/probes/helpers.rb
         
     | 
| 
         @@ -278,12 +278,12 @@ files: 
     | 
|
| 
       278 
278 
     | 
    
         
             
            - lib/appsignal/transmitter.rb
         
     | 
| 
       279 
279 
     | 
    
         
             
            - lib/appsignal/utils.rb
         
     | 
| 
       280 
280 
     | 
    
         
             
            - lib/appsignal/utils/data.rb
         
     | 
| 
       281 
     | 
    
         
            -
            - lib/appsignal/utils/deprecation_message.rb
         
     | 
| 
       282 
281 
     | 
    
         
             
            - lib/appsignal/utils/hash_sanitizer.rb
         
     | 
| 
       283 
282 
     | 
    
         
             
            - lib/appsignal/utils/integration_logger.rb
         
     | 
| 
       284 
283 
     | 
    
         
             
            - lib/appsignal/utils/json.rb
         
     | 
| 
       285 
284 
     | 
    
         
             
            - lib/appsignal/utils/query_params_sanitizer.rb
         
     | 
| 
       286 
285 
     | 
    
         
             
            - lib/appsignal/utils/rails_helper.rb
         
     | 
| 
      
 286 
     | 
    
         
            +
            - lib/appsignal/utils/stdout_and_logger_message.rb
         
     | 
| 
       287 
287 
     | 
    
         
             
            - lib/appsignal/version.rb
         
     | 
| 
       288 
288 
     | 
    
         
             
            - lib/puma/plugin/appsignal.rb
         
     | 
| 
       289 
289 
     | 
    
         
             
            - lib/sequel/extensions/appsignal_integration.rb
         
     | 
| 
         @@ -318,6 +318,7 @@ files: 
     | 
|
| 
       318 
318 
     | 
    
         
             
            - spec/lib/appsignal/extension_install_failure_spec.rb
         
     | 
| 
       319 
319 
     | 
    
         
             
            - spec/lib/appsignal/extension_spec.rb
         
     | 
| 
       320 
320 
     | 
    
         
             
            - spec/lib/appsignal/garbage_collection_spec.rb
         
     | 
| 
      
 321 
     | 
    
         
            +
            - spec/lib/appsignal/heartbeat_spec.rb
         
     | 
| 
       321 
322 
     | 
    
         
             
            - spec/lib/appsignal/hooks/action_cable_spec.rb
         
     | 
| 
       322 
323 
     | 
    
         
             
            - spec/lib/appsignal/hooks/action_mailer_spec.rb
         
     | 
| 
       323 
324 
     | 
    
         
             
            - spec/lib/appsignal/hooks/active_support_notifications/finish_with_state_shared_examples.rb
         
     | 
| 
         @@ -362,10 +363,10 @@ files: 
     | 
|
| 
       362 
363 
     | 
    
         
             
            - spec/lib/appsignal/integrations/webmachine_spec.rb
         
     | 
| 
       363 
364 
     | 
    
         
             
            - spec/lib/appsignal/logger_spec.rb
         
     | 
| 
       364 
365 
     | 
    
         
             
            - spec/lib/appsignal/marker_spec.rb
         
     | 
| 
       365 
     | 
    
         
            -
            - spec/lib/appsignal/minutely_spec.rb
         
     | 
| 
       366 
366 
     | 
    
         
             
            - spec/lib/appsignal/probes/gvl_spec.rb
         
     | 
| 
       367 
367 
     | 
    
         
             
            - spec/lib/appsignal/probes/mri_spec.rb
         
     | 
| 
       368 
368 
     | 
    
         
             
            - spec/lib/appsignal/probes/sidekiq_spec.rb
         
     | 
| 
      
 369 
     | 
    
         
            +
            - spec/lib/appsignal/probes_spec.rb
         
     | 
| 
       369 
370 
     | 
    
         
             
            - spec/lib/appsignal/rack/generic_instrumentation_spec.rb
         
     | 
| 
       370 
371 
     | 
    
         
             
            - spec/lib/appsignal/rack/rails_instrumentation_spec.rb
         
     | 
| 
       371 
372 
     | 
    
         
             
            - spec/lib/appsignal/rack/sinatra_instrumentation_spec.rb
         
     | 
| 
         @@ -451,7 +452,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       451 
452 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       452 
453 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       453 
454 
     | 
    
         
             
            requirements: []
         
     | 
| 
       454 
     | 
    
         
            -
            rubygems_version: 3. 
     | 
| 
      
 455 
     | 
    
         
            +
            rubygems_version: 3.5.9
         
     | 
| 
       455 
456 
     | 
    
         
             
            signing_key:
         
     | 
| 
       456 
457 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       457 
458 
     | 
    
         
             
            summary: Logs performance and exception data from your app to appsignal.com
         
     |