appsignal 3.9.3-java → 3.11.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +22 -19
- data/.rubocop.yml +1 -1
- data/CHANGELOG.md +180 -0
- data/Gemfile +1 -0
- data/README.md +0 -1
- data/Rakefile +1 -1
- data/benchmark.rake +99 -42
- data/build_matrix.yml +10 -12
- data/gemfiles/webmachine1.gemfile +5 -4
- data/lib/appsignal/cli/demo.rb +0 -1
- data/lib/appsignal/config.rb +57 -97
- data/lib/appsignal/demo.rb +15 -20
- data/lib/appsignal/environment.rb +6 -1
- data/lib/appsignal/event_formatter/rom/sql_formatter.rb +1 -0
- data/lib/appsignal/event_formatter.rb +3 -2
- data/lib/appsignal/helpers/instrumentation.rb +490 -16
- data/lib/appsignal/hooks/action_cable.rb +21 -16
- data/lib/appsignal/hooks/active_job.rb +15 -14
- data/lib/appsignal/hooks/delayed_job.rb +1 -1
- data/lib/appsignal/hooks/shoryuken.rb +3 -63
- data/lib/appsignal/integrations/action_cable.rb +5 -7
- data/lib/appsignal/integrations/active_support_notifications.rb +1 -0
- data/lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb +36 -35
- data/lib/appsignal/integrations/data_mapper.rb +1 -0
- data/lib/appsignal/integrations/delayed_job_plugin.rb +27 -33
- data/lib/appsignal/integrations/dry_monitor.rb +1 -0
- data/lib/appsignal/integrations/excon.rb +1 -0
- data/lib/appsignal/integrations/http.rb +1 -0
- data/lib/appsignal/integrations/net_http.rb +1 -0
- data/lib/appsignal/integrations/object.rb +6 -0
- data/lib/appsignal/integrations/padrino.rb +21 -25
- data/lib/appsignal/integrations/que.rb +13 -20
- data/lib/appsignal/integrations/railtie.rb +1 -1
- data/lib/appsignal/integrations/rake.rb +45 -15
- data/lib/appsignal/integrations/redis.rb +1 -0
- data/lib/appsignal/integrations/redis_client.rb +1 -0
- data/lib/appsignal/integrations/resque.rb +2 -5
- data/lib/appsignal/integrations/shoryuken.rb +75 -0
- data/lib/appsignal/integrations/sidekiq.rb +7 -25
- data/lib/appsignal/integrations/unicorn.rb +1 -0
- data/lib/appsignal/integrations/webmachine.rb +12 -9
- data/lib/appsignal/logger.rb +7 -3
- data/lib/appsignal/probes/helpers.rb +1 -0
- data/lib/appsignal/probes/mri.rb +1 -0
- data/lib/appsignal/probes/sidekiq.rb +1 -0
- data/lib/appsignal/probes.rb +3 -0
- data/lib/appsignal/rack/abstract_middleware.rb +67 -24
- data/lib/appsignal/rack/body_wrapper.rb +143 -0
- data/lib/appsignal/rack/event_handler.rb +39 -8
- data/lib/appsignal/rack/generic_instrumentation.rb +6 -4
- data/lib/appsignal/rack/grape_middleware.rb +3 -2
- data/lib/appsignal/rack/hanami_middleware.rb +1 -1
- data/lib/appsignal/rack/instrumentation_middleware.rb +62 -0
- data/lib/appsignal/rack/rails_instrumentation.rb +1 -3
- data/lib/appsignal/rack/sinatra_instrumentation.rb +1 -3
- data/lib/appsignal/rack/streaming_listener.rb +14 -59
- data/lib/appsignal/rack.rb +60 -0
- data/lib/appsignal/span.rb +1 -0
- data/lib/appsignal/transaction.rb +353 -104
- data/lib/appsignal/utils/data.rb +0 -1
- data/lib/appsignal/utils/hash_sanitizer.rb +0 -1
- data/lib/appsignal/utils/integration_logger.rb +0 -13
- data/lib/appsignal/utils/integration_memory_logger.rb +0 -13
- data/lib/appsignal/utils/json.rb +0 -1
- data/lib/appsignal/utils/query_params_sanitizer.rb +0 -1
- data/lib/appsignal/utils/stdout_and_logger_message.rb +0 -1
- data/lib/appsignal/utils.rb +6 -0
- data/lib/appsignal/version.rb +1 -1
- data/lib/appsignal.rb +9 -6
- data/spec/lib/appsignal/capistrano2_spec.rb +1 -1
- data/spec/lib/appsignal/config_spec.rb +139 -43
- data/spec/lib/appsignal/hooks/action_cable_spec.rb +43 -74
- data/spec/lib/appsignal/hooks/activejob_spec.rb +9 -0
- data/spec/lib/appsignal/hooks/delayed_job_spec.rb +2 -443
- data/spec/lib/appsignal/hooks/rake_spec.rb +100 -17
- data/spec/lib/appsignal/hooks/shoryuken_spec.rb +0 -171
- data/spec/lib/appsignal/integrations/delayed_job_plugin_spec.rb +459 -0
- data/spec/lib/appsignal/integrations/padrino_spec.rb +181 -131
- data/spec/lib/appsignal/integrations/que_spec.rb +3 -4
- data/spec/lib/appsignal/integrations/shoryuken_spec.rb +167 -0
- data/spec/lib/appsignal/integrations/sidekiq_spec.rb +4 -4
- data/spec/lib/appsignal/integrations/sinatra_spec.rb +10 -2
- data/spec/lib/appsignal/integrations/webmachine_spec.rb +77 -17
- data/spec/lib/appsignal/rack/abstract_middleware_spec.rb +144 -11
- data/spec/lib/appsignal/rack/body_wrapper_spec.rb +263 -0
- data/spec/lib/appsignal/rack/event_handler_spec.rb +81 -10
- data/spec/lib/appsignal/rack/generic_instrumentation_spec.rb +70 -17
- data/spec/lib/appsignal/rack/grape_middleware_spec.rb +1 -1
- data/spec/lib/appsignal/rack/instrumentation_middleware_spec.rb +38 -0
- data/spec/lib/appsignal/rack/rails_instrumentation_spec.rb +4 -2
- data/spec/lib/appsignal/rack/streaming_listener_spec.rb +43 -120
- data/spec/lib/appsignal/rack_spec.rb +63 -0
- data/spec/lib/appsignal/transaction_spec.rb +1675 -953
- data/spec/lib/appsignal/utils/integration_logger_spec.rb +12 -16
- data/spec/lib/appsignal/utils/integration_memory_logger_spec.rb +0 -10
- data/spec/lib/appsignal_spec.rb +517 -13
- data/spec/support/helpers/transaction_helpers.rb +44 -20
- data/spec/support/matchers/transaction.rb +15 -1
- data/spec/support/mocks/dummy_app.rb +1 -1
- data/spec/support/testing.rb +1 -1
- metadata +12 -4
- data/support/check_versions +0 -22
data/lib/appsignal/utils/data.rb
CHANGED
@@ -2,20 +2,7 @@
|
|
2
2
|
|
3
3
|
module Appsignal
|
4
4
|
module Utils
|
5
|
-
# Subclass of logger with method to only log a warning once
|
6
|
-
# prevents the local log from filling up with repeated messages.
|
7
5
|
class IntegrationLogger < ::Logger
|
8
|
-
def seen_keys
|
9
|
-
@seen_keys ||= Set.new
|
10
|
-
end
|
11
|
-
|
12
|
-
def warn_once_then_debug(key, message)
|
13
|
-
if seen_keys.add?(key).nil?
|
14
|
-
debug message
|
15
|
-
else
|
16
|
-
warn message
|
17
|
-
end
|
18
|
-
end
|
19
6
|
end
|
20
7
|
end
|
21
8
|
end
|
@@ -4,7 +4,6 @@ require "logger"
|
|
4
4
|
|
5
5
|
module Appsignal
|
6
6
|
module Utils
|
7
|
-
# @api private
|
8
7
|
class IntegrationMemoryLogger
|
9
8
|
LEVELS = {
|
10
9
|
Logger::DEBUG => :DEBUG,
|
@@ -35,18 +34,6 @@ module Appsignal
|
|
35
34
|
add(:WARN, message)
|
36
35
|
end
|
37
36
|
|
38
|
-
def seen_keys
|
39
|
-
@seen_keys ||= Set.new
|
40
|
-
end
|
41
|
-
|
42
|
-
def warn_once_then_debug(key, message)
|
43
|
-
if seen_keys.add?(key).nil?
|
44
|
-
debug message
|
45
|
-
else
|
46
|
-
warn message
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
37
|
def error(message)
|
51
38
|
add(:ERROR, message)
|
52
39
|
end
|
data/lib/appsignal/utils/json.rb
CHANGED
data/lib/appsignal/utils.rb
CHANGED
data/lib/appsignal/version.rb
CHANGED
data/lib/appsignal.rb
CHANGED
@@ -47,7 +47,7 @@ module Appsignal
|
|
47
47
|
# @see Extension
|
48
48
|
# @see extension_loaded?
|
49
49
|
attr_accessor :extension_loaded
|
50
|
-
# @!attribute [rw]
|
50
|
+
# @!attribute [rw] internal_logger
|
51
51
|
# Accessor for the internal AppSignal logger.
|
52
52
|
#
|
53
53
|
# Not to be confused with our logging feature.
|
@@ -59,10 +59,8 @@ module Appsignal
|
|
59
59
|
# {.start}) the contents of the "in memory logger" is written to the new
|
60
60
|
# logger.
|
61
61
|
#
|
62
|
-
# @note some classes may have options to set custom loggers. Their
|
63
|
-
# defaults are pointed to this attribute.
|
64
62
|
# @api private
|
65
|
-
# @return [
|
63
|
+
# @return [Utils::IntegrationLogger or Utils::IntegrationMemoryLogger]
|
66
64
|
# @see start
|
67
65
|
attr_writer :internal_logger
|
68
66
|
|
@@ -165,10 +163,12 @@ module Appsignal
|
|
165
163
|
Appsignal::Extension.start
|
166
164
|
end
|
167
165
|
|
166
|
+
# @api private
|
168
167
|
def get_server_state(key)
|
169
168
|
Appsignal::Extension.get_server_state(key)
|
170
169
|
end
|
171
170
|
|
171
|
+
# @api private
|
172
172
|
def in_memory_logger
|
173
173
|
@in_memory_logger ||=
|
174
174
|
Appsignal::Utils::IntegrationMemoryLogger.new.tap do |l|
|
@@ -176,6 +176,7 @@ module Appsignal
|
|
176
176
|
end
|
177
177
|
end
|
178
178
|
|
179
|
+
# @api private
|
179
180
|
def internal_logger
|
180
181
|
@internal_logger ||= in_memory_logger
|
181
182
|
end
|
@@ -195,7 +196,7 @@ module Appsignal
|
|
195
196
|
def start_logger
|
196
197
|
callers = caller
|
197
198
|
Appsignal::Utils::StdoutAndLoggerMessage.warning \
|
198
|
-
"
|
199
|
+
"Calling 'Appsignal.start_logger' is deprecated. " \
|
199
200
|
"The logger will be started when calling 'Appsignal.start'. " \
|
200
201
|
"Remove the 'Appsignal.start_logger' call in the following file to " \
|
201
202
|
"remove this message.\n#{callers.first}"
|
@@ -324,8 +325,10 @@ require "appsignal/hooks"
|
|
324
325
|
require "appsignal/probes"
|
325
326
|
require "appsignal/marker"
|
326
327
|
require "appsignal/garbage_collection"
|
328
|
+
require "appsignal/rack"
|
329
|
+
require "appsignal/rack/body_wrapper"
|
327
330
|
require "appsignal/rack/abstract_middleware"
|
328
|
-
require "appsignal/rack/
|
331
|
+
require "appsignal/rack/instrumentation_middleware"
|
329
332
|
require "appsignal/rack/event_handler"
|
330
333
|
require "appsignal/integrations/railtie" if defined?(::Rails)
|
331
334
|
require "appsignal/transaction"
|
@@ -1,19 +1,4 @@
|
|
1
1
|
describe Appsignal::Config do
|
2
|
-
describe "config keys" do
|
3
|
-
it "all config keys have an environment variable version registered" do
|
4
|
-
config = Appsignal::Config
|
5
|
-
mapped_env_keys = config::ENV_TO_KEY_MAPPING.keys.sort
|
6
|
-
configured_env_keys = (
|
7
|
-
config::ENV_STRING_KEYS +
|
8
|
-
config::ENV_BOOLEAN_KEYS +
|
9
|
-
config::ENV_ARRAY_KEYS +
|
10
|
-
config::ENV_FLOAT_KEYS
|
11
|
-
).sort
|
12
|
-
|
13
|
-
expect(mapped_env_keys).to eql(configured_env_keys)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
2
|
describe "#initialize" do
|
18
3
|
describe "environment" do
|
19
4
|
context "when environment is nil" do
|
@@ -165,6 +150,7 @@ describe Appsignal::Config do
|
|
165
150
|
:enable_statsd => true,
|
166
151
|
:enable_nginx_metrics => false,
|
167
152
|
:enable_rails_error_reporter => true,
|
153
|
+
:enable_rake_performance_instrumentation => false,
|
168
154
|
:endpoint => "https://push.appsignal.com",
|
169
155
|
:files_world_accessible => true,
|
170
156
|
:filter_metadata => [],
|
@@ -415,49 +401,159 @@ describe Appsignal::Config do
|
|
415
401
|
let(:working_directory_path) { File.join(tmp_dir, "test_working_directory_path") }
|
416
402
|
let(:env_config) do
|
417
403
|
{
|
418
|
-
:running_in_container => true,
|
419
|
-
:push_api_key => "aaa-bbb-ccc",
|
420
404
|
:active => true,
|
405
|
+
:activejob_report_errors => "all",
|
421
406
|
:bind_address => "0.0.0.0",
|
407
|
+
:ca_file_path => "/some/path",
|
422
408
|
:cpu_count => 1.5,
|
423
|
-
:name => "App name",
|
424
409
|
:debug => true,
|
425
410
|
:dns_servers => ["8.8.8.8", "8.8.4.4"],
|
426
|
-
:
|
427
|
-
:
|
411
|
+
:enable_allocation_tracking => false,
|
412
|
+
:enable_gvl_global_timer => false,
|
413
|
+
:enable_gvl_waiting_threads => false,
|
414
|
+
:enable_host_metrics => false,
|
415
|
+
:enable_minutely_probes => false,
|
416
|
+
:enable_nginx_metrics => false,
|
417
|
+
:enable_rails_error_reporter => false,
|
418
|
+
:enable_rake_performance_instrumentation => false,
|
419
|
+
:enable_statsd => false,
|
420
|
+
:endpoint => "https://test.appsignal.com",
|
421
|
+
:files_world_accessible => false,
|
422
|
+
:filter_metadata => ["key1", "key2"],
|
423
|
+
:filter_parameters => ["param1", "param2"],
|
424
|
+
:filter_session_data => ["session1", "session2"],
|
425
|
+
:host_role => "my host role",
|
426
|
+
:hostname => "my hostname",
|
427
|
+
:http_proxy => "some proxy",
|
428
|
+
:ignore_actions => ["action1", "action2"],
|
429
|
+
:ignore_errors => ["ExampleStandardError", "AnotherError"],
|
428
430
|
:ignore_logs => ["^start$", "^Completed 2.* in .*ms (.*)"],
|
429
|
-
:ignore_namespaces =>
|
431
|
+
:ignore_namespaces => ["admin", "private_namespace"],
|
432
|
+
:instrument_http_rb => false,
|
430
433
|
:instrument_net_http => false,
|
431
434
|
:instrument_redis => false,
|
432
435
|
:instrument_sequel => false,
|
433
|
-
:
|
434
|
-
:
|
436
|
+
:log => "file",
|
437
|
+
:log_level => "debug",
|
438
|
+
:log_path => "/tmp/something",
|
439
|
+
:logging_endpoint => "https://appsignal-endpoint.net/test",
|
440
|
+
:name => "App name",
|
441
|
+
:push_api_key => "aaa-bbb-ccc",
|
442
|
+
:request_headers => ["accept", "accept-charset"],
|
435
443
|
:revision => "v2.5.1",
|
444
|
+
:running_in_container => true,
|
436
445
|
:send_environment_metadata => false,
|
446
|
+
:send_params => false,
|
447
|
+
:send_session_data => false,
|
448
|
+
:sidekiq_report_errors => "all",
|
449
|
+
:skip_session_data => false,
|
450
|
+
:statsd_port => "7890",
|
451
|
+
:transaction_debug_mode => false,
|
452
|
+
:working_dir_path => "/some/path",
|
437
453
|
:working_directory_path => working_directory_path
|
438
454
|
}
|
439
455
|
end
|
456
|
+
let(:env_vars) do
|
457
|
+
{
|
458
|
+
# Strings
|
459
|
+
"APPSIGNAL_ACTIVEJOB_REPORT_ERRORS" => "all",
|
460
|
+
"APPSIGNAL_APP_NAME" => "App name",
|
461
|
+
"APPSIGNAL_BIND_ADDRESS" => "0.0.0.0",
|
462
|
+
"APPSIGNAL_CA_FILE_PATH" => "/some/path",
|
463
|
+
"APPSIGNAL_HOSTNAME" => "my hostname",
|
464
|
+
"APPSIGNAL_HOST_ROLE" => "my host role",
|
465
|
+
"APPSIGNAL_HTTP_PROXY" => "some proxy",
|
466
|
+
"APPSIGNAL_LOG" => "file",
|
467
|
+
"APPSIGNAL_LOGGING_ENDPOINT" => "https://appsignal-endpoint.net/test",
|
468
|
+
"APPSIGNAL_LOG_LEVEL" => "debug",
|
469
|
+
"APPSIGNAL_LOG_PATH" => "/tmp/something",
|
470
|
+
"APPSIGNAL_PUSH_API_ENDPOINT" => "https://test.appsignal.com",
|
471
|
+
"APPSIGNAL_PUSH_API_KEY" => "aaa-bbb-ccc",
|
472
|
+
"APPSIGNAL_SIDEKIQ_REPORT_ERRORS" => "all",
|
473
|
+
"APPSIGNAL_STATSD_PORT" => "7890",
|
474
|
+
"APPSIGNAL_WORKING_DIRECTORY_PATH" => working_directory_path,
|
475
|
+
"APPSIGNAL_WORKING_DIR_PATH" => "/some/path",
|
476
|
+
"APP_REVISION" => "v2.5.1",
|
477
|
+
|
478
|
+
# Booleans
|
479
|
+
"APPSIGNAL_ACTIVE" => "true",
|
480
|
+
"APPSIGNAL_DEBUG" => "true",
|
481
|
+
"APPSIGNAL_ENABLE_ALLOCATION_TRACKING" => "false",
|
482
|
+
"APPSIGNAL_ENABLE_GVL_GLOBAL_TIMER" => "false",
|
483
|
+
"APPSIGNAL_ENABLE_GVL_WAITING_THREADS" => "false",
|
484
|
+
"APPSIGNAL_ENABLE_HOST_METRICS" => "false",
|
485
|
+
"APPSIGNAL_ENABLE_MINUTELY_PROBES" => "false",
|
486
|
+
"APPSIGNAL_ENABLE_NGINX_METRICS" => "false",
|
487
|
+
"APPSIGNAL_ENABLE_RAILS_ERROR_REPORTER" => "false",
|
488
|
+
"APPSIGNAL_ENABLE_RAKE_PERFORMANCE_INSTRUMENTATION" => "false",
|
489
|
+
"APPSIGNAL_ENABLE_STATSD" => "false",
|
490
|
+
"APPSIGNAL_FILES_WORLD_ACCESSIBLE" => "false",
|
491
|
+
"APPSIGNAL_INSTRUMENT_HTTP_RB" => "false",
|
492
|
+
"APPSIGNAL_INSTRUMENT_NET_HTTP" => "false",
|
493
|
+
"APPSIGNAL_INSTRUMENT_REDIS" => "false",
|
494
|
+
"APPSIGNAL_INSTRUMENT_SEQUEL" => "false",
|
495
|
+
"APPSIGNAL_RUNNING_IN_CONTAINER" => "true",
|
496
|
+
"APPSIGNAL_SEND_ENVIRONMENT_METADATA" => "false",
|
497
|
+
"APPSIGNAL_SEND_PARAMS" => "false",
|
498
|
+
"APPSIGNAL_SEND_SESSION_DATA" => "false",
|
499
|
+
"APPSIGNAL_SKIP_SESSION_DATA" => "false",
|
500
|
+
"APPSIGNAL_TRANSACTION_DEBUG_MODE" => "false",
|
501
|
+
|
502
|
+
# Arrays
|
503
|
+
"APPSIGNAL_DNS_SERVERS" => "8.8.8.8,8.8.4.4",
|
504
|
+
"APPSIGNAL_FILTER_METADATA" => "key1,key2",
|
505
|
+
"APPSIGNAL_FILTER_PARAMETERS" => "param1,param2",
|
506
|
+
"APPSIGNAL_FILTER_SESSION_DATA" => "session1,session2",
|
507
|
+
"APPSIGNAL_IGNORE_ACTIONS" => "action1,action2",
|
508
|
+
"APPSIGNAL_IGNORE_ERRORS" => "ExampleStandardError,AnotherError",
|
509
|
+
"APPSIGNAL_IGNORE_LOGS" => "^start$,^Completed 2.* in .*ms (.*)",
|
510
|
+
"APPSIGNAL_IGNORE_NAMESPACES" => "admin,private_namespace",
|
511
|
+
"APPSIGNAL_REQUEST_HEADERS" => "accept,accept-charset",
|
512
|
+
|
513
|
+
# Floats
|
514
|
+
"APPSIGNAL_CPU_COUNT" => "1.5"
|
515
|
+
}
|
516
|
+
end
|
440
517
|
before do
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
518
|
+
env_vars.each do |key, value|
|
519
|
+
ENV[key] = value
|
520
|
+
end
|
521
|
+
end
|
522
|
+
|
523
|
+
it "reads all string env keys" do
|
524
|
+
config
|
525
|
+
|
526
|
+
Appsignal::Config::ENV_STRING_KEYS.each do |env_key, option|
|
527
|
+
ENV.fetch(env_key) { raise "Config env var '#{env_key}' is not set for this test" }
|
528
|
+
expect(config[option]).to eq(ENV.fetch(env_key, nil))
|
529
|
+
end
|
530
|
+
end
|
531
|
+
|
532
|
+
it "reads all boolean env keys" do
|
533
|
+
config
|
534
|
+
|
535
|
+
Appsignal::Config::ENV_BOOLEAN_KEYS.each do |env_key, option|
|
536
|
+
ENV.fetch(env_key) { raise "Config env var '#{env_key}' is not set for this test" }
|
537
|
+
expect(config[option]).to eq(ENV.fetch(env_key, nil) == "true")
|
538
|
+
end
|
539
|
+
end
|
540
|
+
|
541
|
+
it "reads all array env keys" do
|
542
|
+
config
|
543
|
+
|
544
|
+
Appsignal::Config::ENV_ARRAY_KEYS.each do |env_key, option|
|
545
|
+
ENV.fetch(env_key) { raise "Config env var '#{env_key}' is not set for this test" }
|
546
|
+
expect(config[option]).to eq(ENV.fetch(env_key, nil).split(","))
|
547
|
+
end
|
548
|
+
end
|
549
|
+
|
550
|
+
it "reads all float env keys" do
|
551
|
+
config
|
552
|
+
|
553
|
+
Appsignal::Config::ENV_FLOAT_KEYS.each do |env_key, option|
|
554
|
+
ENV.fetch(env_key) { raise "Config env var '#{env_key}' is not set for this test" }
|
555
|
+
expect(config[option]).to eq(ENV.fetch(env_key, nil).to_f)
|
556
|
+
end
|
461
557
|
end
|
462
558
|
|
463
559
|
it "overrides config with environment values" do
|