appsignal 3.4.2-java → 3.4.4-java

Sign up to get free protection for your applications and to get access to all the features.
@@ -643,6 +643,7 @@ describe Appsignal::Config do
643
643
  expect(ENV.fetch("_APPSIGNAL_FILES_WORLD_ACCESSIBLE", nil)).to eq "true"
644
644
  expect(ENV.fetch("_APPSIGNAL_TRANSACTION_DEBUG_MODE", nil)).to eq "true"
645
645
  expect(ENV.fetch("_APPSIGNAL_SEND_ENVIRONMENT_METADATA", nil)).to eq "false"
646
+ expect(ENV.fetch("_APPSIGNAL_STATSD_PORT", nil)).to eq ""
646
647
  expect(ENV.fetch("_APPSIGNAL_FILTER_PARAMETERS", nil)).to eq "password,confirm_password"
647
648
  expect(ENV.fetch("_APPSIGNAL_FILTER_SESSION_DATA", nil)).to eq "key1,key2"
648
649
  expect(ENV.fetch("_APP_REVISION", nil)).to eq "v2.5.1"
@@ -682,6 +683,17 @@ describe Appsignal::Config do
682
683
  expect(ENV.fetch("_APPSIGNAL_WORKING_DIRECTORY_PATH", nil)).to eq "/tmp/appsignal2"
683
684
  end
684
685
  end
686
+
687
+ context "with :statsd_port" do
688
+ before do
689
+ config[:statsd_port] = "1000"
690
+ config.write_to_environment
691
+ end
692
+
693
+ it "sets the statsd_port env var" do
694
+ expect(ENV.fetch("_APPSIGNAL_STATSD_PORT", nil)).to eq "1000"
695
+ end
696
+ end
685
697
  end
686
698
 
687
699
  describe "#log_file_path" do
@@ -28,9 +28,10 @@ describe Appsignal::Logger do
28
28
  logger.add(::Logger::INFO, "Log message", "other_group")
29
29
  end
30
30
 
31
- it "should return with a nil message" do
32
- expect(Appsignal::Extension).not_to receive(:log)
33
- logger.add(::Logger::INFO, nil)
31
+ it "should log when using `group` for the log message" do
32
+ expect(Appsignal::Extension).to receive(:log)
33
+ .with("group", 3, 0, "Log message", instance_of(Appsignal::Extension::Data))
34
+ logger.add(::Logger::INFO, nil, "Log message")
34
35
  end
35
36
 
36
37
  context "with info log level" do
@@ -106,26 +106,31 @@ RSpec.describe "Puma plugin" do
106
106
  end
107
107
  end
108
108
  end
109
- Puma._set_stats = stats_data
110
109
  load File.expand_path("../lib/puma/plugin/appsignal.rb", APPSIGNAL_SPEC_DIR)
111
-
112
- @statsd = StatsdServer.new
113
- @server_thread = Thread.new { @statsd.start }
114
- @server_thread.abort_on_exception = true
115
110
  end
116
111
  after do
117
- @statsd = nil
118
-
119
112
  Object.send(:remove_const, :Puma)
120
113
  Object.send(:remove_const, :AppsignalPumaPlugin)
121
114
  end
122
115
 
123
- def run_plugin(plugin, &block)
116
+ def run_plugin(stats_data, plugin, &block)
117
+ Puma._set_stats = stats_data
118
+ @statsd = StatsdServer.new
119
+ @server_thread = Thread.new { @statsd.start }
120
+ @server_thread.abort_on_exception = true
124
121
  @client_thread = Thread.new { start_plugin(plugin) }
125
122
  @client_thread.abort_on_exception = true
126
123
  wait_for(:puma_client_wait, &block)
127
124
  ensure
128
- stop_all
125
+ Puma._set_stats = nil
126
+ # Stop all threads in test and stop listening on the UDPSocket
127
+ @client_thread.kill if defined?(@client_thread) && @client_thread
128
+ @server_thread.kill if defined?(@server_thread) && @server_thread
129
+ @client_thread = nil
130
+ @server_thread = nil
131
+
132
+ @statsd.stop if defined?(@statsd) && @statsd
133
+ @statsd = nil
129
134
  end
130
135
 
131
136
  def appsignal_plugin
@@ -141,15 +146,6 @@ RSpec.describe "Puma plugin" do
141
146
  plugin.in_background_block.call
142
147
  end
143
148
 
144
- # Stop all threads in test and stop listening on the UDPSocket
145
- def stop_all
146
- @client_thread.kill if defined?(@client_thread) && @client_thread
147
- @server_thread.kill if defined?(@server_thread) && @server_thread
148
- @statsd.stop if defined?(@statsd) && @statsd
149
- @client_thread = nil
150
- @server_thread = nil
151
- end
152
-
153
149
  def logs
154
150
  launcher.log_writer.logs
155
151
  end
@@ -209,7 +205,7 @@ RSpec.describe "Puma plugin" do
209
205
  end
210
206
 
211
207
  it "collects puma stats as guage metrics with the (summed) worker metrics" do
212
- run_plugin(appsignal_plugin) do
208
+ run_plugin(stats_data, appsignal_plugin) do
213
209
  expect(logs).to_not include([:error, kind_of(String)])
214
210
  expect_gauge(:workers, 2, "type" => "count")
215
211
  expect_gauge(:workers, 2, "type" => "booted")
@@ -233,7 +229,7 @@ RSpec.describe "Puma plugin" do
233
229
  end
234
230
 
235
231
  it "calls `puma_gauge` with the (summed) worker metrics" do
236
- run_plugin(appsignal_plugin) do
232
+ run_plugin(stats_data, appsignal_plugin) do
237
233
  expect(logs).to_not include([:error, kind_of(String)])
238
234
  expect_gauge(:connection_backlog, 0)
239
235
  expect_gauge(:pool_capacity, 5)
@@ -249,7 +245,7 @@ RSpec.describe "Puma plugin" do
249
245
  after { ENV.delete("APPSIGNAL_HOSTNAME") }
250
246
 
251
247
  it "reports the APPSIGNAL_HOSTNAME as the hostname tag value" do
252
- run_plugin(appsignal_plugin) do
248
+ run_plugin(stats_data, appsignal_plugin) do
253
249
  expect(logs).to_not include([:error, kind_of(String)])
254
250
  expect_gauge(:connection_backlog, 1)
255
251
  end
@@ -262,7 +258,7 @@ RSpec.describe "Puma plugin" do
262
258
  end
263
259
 
264
260
  it "fetches metrics from Puma.stats instead" do
265
- run_plugin(appsignal_plugin) do
261
+ run_plugin(stats_data, appsignal_plugin) do
266
262
  expect(logs).to_not include([:error, kind_of(String)])
267
263
  expect(logs).to_not include([kind_of(Symbol), "AppSignal: No Puma stats to report."])
268
264
  expect_gauge(:connection_backlog, 1)
@@ -277,7 +273,7 @@ RSpec.describe "Puma plugin" do
277
273
  end
278
274
 
279
275
  it "does not fetch metrics" do
280
- run_plugin(appsignal_plugin) do
276
+ run_plugin(stats_data, appsignal_plugin) do
281
277
  expect(logs).to_not include([:error, kind_of(String)])
282
278
  expect(logs).to include([:debug, "AppSignal: No Puma stats to report."])
283
279
  expect(messages).to be_empty
@@ -287,8 +283,7 @@ RSpec.describe "Puma plugin" do
287
283
 
288
284
  context "without running StatsD server" do
289
285
  it "does nothing" do
290
- stop_all
291
- run_plugin(appsignal_plugin) do
286
+ run_plugin(stats_data, appsignal_plugin) do
292
287
  expect(logs).to_not include([:error, kind_of(String)])
293
288
  expect(messages).to be_empty
294
289
  end
@@ -328,7 +323,7 @@ RSpec.describe "Puma plugin" do
328
323
  let(:stats_data) { { :max_threads => 5 } }
329
324
 
330
325
  it "logs messages to the events class" do
331
- run_plugin(appsignal_plugin) do
326
+ run_plugin(stats_data, appsignal_plugin) do
332
327
  expect(launcher.events.logs).to_not be_empty
333
328
  end
334
329
  end
@@ -1,6 +1,18 @@
1
1
  RSpec::Matchers.define :contains_log do |level, message|
2
+ expected_log_line = "[#{level.upcase}] #{message}"
3
+
2
4
  match do |actual|
3
- actual.include?("[#{level.upcase}] #{message}")
5
+ actual.include?(expected_log_line)
6
+ end
7
+
8
+ failure_message do |actual|
9
+ <<~MESSAGE
10
+ Did not contain log line:
11
+ #{expected_log_line}
12
+
13
+ Received logs:
14
+ #{actual}
15
+ MESSAGE
4
16
  end
5
17
 
6
18
  diffable
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.2
4
+ version: 3.4.4
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: 2023-05-02 00:00:00.000000000 Z
13
+ date: 2023-06-02 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rack
@@ -453,7 +453,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
453
453
  - !ruby/object:Gem::Version
454
454
  version: '0'
455
455
  requirements: []
456
- rubygems_version: 3.4.6
456
+ rubygems_version: 3.4.11
457
457
  signing_key:
458
458
  specification_version: 4
459
459
  summary: Logs performance and exception data from your app to appsignal.com