appsignal 2.10.2-java → 2.10.3-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d916c32303b06205ace0030078f35290579311ed6ce39878393b5b357e257e16
4
- data.tar.gz: '09d596e29a82bf7c034b484e207889540338f0d00979619b847a8483c7790fa2'
3
+ metadata.gz: 4a2e76a161980415faed21d9d147781e3581c31deef2c236fbf8f99fe2d0a374
4
+ data.tar.gz: ecaa124c56de18417510e0f9798c02888a68ccabc8187e6412739f4669a664e2
5
5
  SHA512:
6
- metadata.gz: 1a9b3456093a22296840fd4c3e3493c188410114c090088ee21bdf1a7dd7cf74b15f2732dad1e9f0d94d0bef1c0e8fc7e53ee79508402d6b5237d1bc99466bf6
7
- data.tar.gz: cb35aa1310941a00a78baef9ab1318543fa84c178afbd734fde178d79efa496592b813c8a0d89536106ce8ab9b19d3b2c46f44a7eb8b3bfae802a286964a1a1f
6
+ metadata.gz: f58df1c3f65c8694cecf519fde5429545f6a3849f9d93b73fa6ad3bd6b06128f59ee31c42a9886a9d4b0053f2adf4082cdbe456efd8d5f49d694d0c6736bc212
7
+ data.tar.gz: 0f723ad1d12acef218607e83e7f06639c85969e3dda91c700f285d540a875f89d098e0cdac7a7ea2860d1d736815b106a86977967b497eec56dc361d31b6173a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.10.3
4
+ - Only warn about reused transactions once. Repeated occurrences are logged as
5
+ debug messages. PR #585
6
+
3
7
  ## 2.10.2
4
8
  - Fix wait_for test suite helper. PR #581
5
9
  - Fix exception handling of config file issues. PR #582
data/lib/appsignal.rb CHANGED
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "json"
4
- require "logger"
5
4
  require "securerandom"
6
5
 
6
+ require "appsignal/logger"
7
7
  require "appsignal/helpers/instrumentation"
8
8
  require "appsignal/helpers/metrics"
9
9
 
@@ -195,7 +195,7 @@ module Appsignal
195
195
  end
196
196
 
197
197
  def logger
198
- @logger ||= Logger.new(in_memory_log).tap do |l|
198
+ @logger ||= Appsignal::Logger.new(in_memory_log).tap do |l|
199
199
  l.level = Logger::INFO
200
200
  l.formatter = log_formatter("appsignal")
201
201
  end
@@ -294,12 +294,12 @@ module Appsignal
294
294
  private
295
295
 
296
296
  def start_stdout_logger
297
- @logger = Logger.new($stdout)
297
+ @logger = Appsignal::Logger.new($stdout)
298
298
  logger.formatter = log_formatter("appsignal")
299
299
  end
300
300
 
301
301
  def start_file_logger(path)
302
- @logger = Logger.new(path)
302
+ @logger = Appsignal::Logger.new(path)
303
303
  logger.formatter = log_formatter
304
304
  rescue SystemCallError => error
305
305
  start_stdout_logger
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "logger"
4
+ require "set"
5
+
6
+ # Subclass of logger with method to only log a warning once
7
+ # prevents the log from filling up with repeated messages.
8
+ module Appsignal
9
+ class Logger < ::Logger
10
+ def seen_keys
11
+ @seen_keys ||= Set.new
12
+ end
13
+
14
+ def warn_once_then_debug(key, message)
15
+ if !seen_keys.add?(key).nil?
16
+ warn message
17
+ else
18
+ debug message
19
+ end
20
+ end
21
+ end
22
+ end
@@ -25,7 +25,7 @@ module Appsignal
25
25
  Thread.current[:appsignal_transaction] = Appsignal::Transaction.new(id, namespace, request, options)
26
26
  else
27
27
  # Otherwise, log the issue about trying to start another transaction
28
- Appsignal.logger.warn "Trying to start new transaction with id " \
28
+ Appsignal.logger.warn_once_then_debug :transaction_id, "Trying to start new transaction with id " \
29
29
  "'#{id}', but a transaction with id '#{current.transaction_id}' " \
30
30
  "is already running. Using transaction '#{current.transaction_id}'."
31
31
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Appsignal
4
- VERSION = "2.10.2".freeze
4
+ VERSION = "2.10.3".freeze
5
5
  end
@@ -0,0 +1,25 @@
1
+ describe Appsignal::Logger do
2
+ let(:log) { std_stream }
3
+ let(:logger) do
4
+ Appsignal::Logger.new(log).tap do |l|
5
+ l.formatter = logger_formatter
6
+ end
7
+ end
8
+
9
+ describe "#seen_keys" do
10
+ it "returns a Set" do
11
+ expect(logger.seen_keys).to be_a(Set)
12
+ end
13
+ end
14
+
15
+ describe "#warn_once_then_debug" do
16
+ it "only warns once, then uses debug" do
17
+ message = "This is a log line"
18
+ 3.times { logger.warn_once_then_debug(:key, message) }
19
+
20
+ logs = log_contents(log)
21
+ expect(logs.scan(/#{Regexp.escape(log_line(:WARN, message))}/).count).to eql(1)
22
+ expect(logs.scan(/#{Regexp.escape(log_line(:DEBUG, message))}/).count).to eql(2)
23
+ end
24
+ end
25
+ end
@@ -1021,6 +1021,7 @@ describe Appsignal do
1021
1021
  Appsignal.start_logger
1022
1022
  Appsignal.logger.error("Log to file")
1023
1023
  end
1024
+ expect(Appsignal.logger).to be_a(Appsignal::Logger)
1024
1025
  end
1025
1026
 
1026
1027
  it "logs to file" do
@@ -1043,6 +1044,7 @@ describe Appsignal do
1043
1044
  initialize_config
1044
1045
  Appsignal.start_logger
1045
1046
  Appsignal.logger.error("Log to not writable log file")
1047
+ expect(Appsignal.logger).to be_a(Appsignal::Logger)
1046
1048
  end
1047
1049
  end
1048
1050
 
@@ -1073,6 +1075,7 @@ describe Appsignal do
1073
1075
  Appsignal.start_logger
1074
1076
  Appsignal.logger.error("Log to not writable log path")
1075
1077
  end
1078
+ expect(Appsignal.logger).to be_a(Appsignal::Logger)
1076
1079
  end
1077
1080
  after do
1078
1081
  FileUtils.chmod 0o755, Appsignal::Config.system_tmp_dir
@@ -1101,6 +1104,7 @@ describe Appsignal do
1101
1104
  Appsignal.start_logger
1102
1105
  Appsignal.logger.error("Log to stdout")
1103
1106
  end
1107
+ expect(Appsignal.logger).to be_a(Appsignal::Logger)
1104
1108
  end
1105
1109
  around { |example| recognize_as_heroku { example.run } }
1106
1110
 
@@ -12,15 +12,22 @@ module LogHelpers
12
12
  end
13
13
 
14
14
  def test_logger(log)
15
- Logger.new(log).tap do |logger|
16
- logger.formatter =
17
- proc do |severity, _datetime, _progname, msg|
18
- # This format is used in the `contains_log` matcher.
19
- "[#{severity}] #{msg}\n"
20
- end
15
+ Appsignal::Logger.new(log).tap do |logger|
16
+ logger.formatter = logger_formatter
21
17
  end
22
18
  end
23
19
 
20
+ def logger_formatter
21
+ proc do |severity, _datetime, _progname, msg|
22
+ log_line(severity, msg)
23
+ end
24
+ end
25
+
26
+ def log_line(severity, message)
27
+ # This format is used in the `contains_log` matcher.
28
+ "[#{severity}] #{message}\n"
29
+ end
30
+
24
31
  def log_contents(log)
25
32
  log.rewind
26
33
  log.read
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: 2.10.2
4
+ version: 2.10.3
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: 2020-01-30 00:00:00.000000000 Z
13
+ date: 2020-02-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rack
@@ -251,6 +251,7 @@ files:
251
251
  - lib/appsignal/integrations/sinatra.rb
252
252
  - lib/appsignal/integrations/webmachine.rb
253
253
  - lib/appsignal/js_exception_transaction.rb
254
+ - lib/appsignal/logger.rb
254
255
  - lib/appsignal/marker.rb
255
256
  - lib/appsignal/minutely.rb
256
257
  - lib/appsignal/rack/generic_instrumentation.rb
@@ -328,6 +329,7 @@ files:
328
329
  - spec/lib/appsignal/integrations/sinatra_spec.rb
329
330
  - spec/lib/appsignal/integrations/webmachine_spec.rb
330
331
  - spec/lib/appsignal/js_exception_transaction_spec.rb
332
+ - spec/lib/appsignal/logger_spec.rb
331
333
  - spec/lib/appsignal/marker_spec.rb
332
334
  - spec/lib/appsignal/minutely_spec.rb
333
335
  - spec/lib/appsignal/rack/generic_instrumentation_spec.rb
@@ -406,7 +408,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
406
408
  - !ruby/object:Gem::Version
407
409
  version: '0'
408
410
  requirements: []
409
- rubygems_version: 3.0.6
411
+ rubygems_version: 3.1.2
410
412
  signing_key:
411
413
  specification_version: 4
412
414
  summary: Logs performance and exception data from your app to appsignal.com
@@ -466,6 +468,7 @@ test_files:
466
468
  - spec/lib/appsignal/integrations/sinatra_spec.rb
467
469
  - spec/lib/appsignal/integrations/webmachine_spec.rb
468
470
  - spec/lib/appsignal/js_exception_transaction_spec.rb
471
+ - spec/lib/appsignal/logger_spec.rb
469
472
  - spec/lib/appsignal/marker_spec.rb
470
473
  - spec/lib/appsignal/minutely_spec.rb
471
474
  - spec/lib/appsignal/rack/generic_instrumentation_spec.rb