appsignal 4.0.5 → 4.0.7
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/CHANGELOG.md +20 -0
- data/Rakefile +9 -9
- data/appsignal.gemspec +22 -1
- data/build_matrix.yml +2 -1
- data/ext/agent.rb +27 -27
- data/lib/appsignal/check_in/scheduler.rb +3 -4
- data/lib/appsignal/check_in.rb +1 -1
- data/lib/appsignal/config.rb +1 -3
- data/lib/appsignal/integrations/que.rb +8 -2
- data/lib/appsignal/integrations/resque.rb +1 -6
- data/lib/appsignal/utils/hash_sanitizer.rb +4 -0
- data/lib/appsignal/version.rb +1 -1
- metadata +2 -191
- data/.github/ISSUE_TEMPLATE/bug_report.md +0 -31
- data/.github/ISSUE_TEMPLATE/chore.md +0 -14
- data/.github/workflows/ci.yml +0 -3150
- data/.github/workflows/create_release_from_tag.yml +0 -62
- data/.gitignore +0 -35
- data/.gitmodules +0 -3
- data/.rspec +0 -4
- data/.yardopts +0 -8
- data/benchmark.rake +0 -139
- data/gemfiles/capistrano2.gemfile +0 -6
- data/gemfiles/capistrano3.gemfile +0 -7
- data/gemfiles/dry-monitor.gemfile +0 -5
- data/gemfiles/grape.gemfile +0 -5
- data/gemfiles/hanami-2.0.gemfile +0 -7
- data/gemfiles/hanami-2.1.gemfile +0 -7
- data/gemfiles/http5.gemfile +0 -5
- data/gemfiles/no_dependencies.gemfile +0 -10
- data/gemfiles/padrino.gemfile +0 -7
- data/gemfiles/psych-3.gemfile +0 -5
- data/gemfiles/psych-4.gemfile +0 -5
- data/gemfiles/que.gemfile +0 -5
- data/gemfiles/rails-6.0.gemfile +0 -10
- data/gemfiles/rails-6.1.gemfile +0 -11
- data/gemfiles/rails-7.0.gemfile +0 -11
- data/gemfiles/rails-7.1.gemfile +0 -11
- data/gemfiles/rails-7.2.gemfile +0 -11
- data/gemfiles/redis-4.gemfile +0 -5
- data/gemfiles/redis-5.gemfile +0 -6
- data/gemfiles/resque-2.gemfile +0 -6
- data/gemfiles/sequel.gemfile +0 -10
- data/gemfiles/sinatra.gemfile +0 -5
- data/gemfiles/webmachine1.gemfile +0 -7
- data/gemfiles/webmachine2.gemfile +0 -6
- data/mono.yml +0 -16
- data/spec/.rubocop.yml +0 -7
- data/spec/lib/appsignal/auth_check_spec.rb +0 -84
- data/spec/lib/appsignal/capistrano2_spec.rb +0 -227
- data/spec/lib/appsignal/capistrano3_spec.rb +0 -284
- data/spec/lib/appsignal/check_in/cron_spec.rb +0 -202
- data/spec/lib/appsignal/check_in/scheduler_spec.rb +0 -443
- data/spec/lib/appsignal/cli/demo_spec.rb +0 -46
- data/spec/lib/appsignal/cli/diagnose/paths_spec.rb +0 -16
- data/spec/lib/appsignal/cli/diagnose/utils_spec.rb +0 -86
- data/spec/lib/appsignal/cli/diagnose_spec.rb +0 -1553
- data/spec/lib/appsignal/cli/helpers_spec.rb +0 -179
- data/spec/lib/appsignal/cli/install_spec.rb +0 -848
- data/spec/lib/appsignal/cli_spec.rb +0 -56
- data/spec/lib/appsignal/config_spec.rb +0 -1380
- data/spec/lib/appsignal/demo_spec.rb +0 -83
- data/spec/lib/appsignal/environment_spec.rb +0 -190
- data/spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb +0 -60
- data/spec/lib/appsignal/event_formatter/active_record/instantiation_formatter_spec.rb +0 -21
- data/spec/lib/appsignal/event_formatter/active_record/sql_formatter_spec.rb +0 -21
- data/spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb +0 -52
- data/spec/lib/appsignal/event_formatter/faraday/request_formatter_spec.rb +0 -21
- data/spec/lib/appsignal/event_formatter/mongo_ruby_driver/query_formatter_spec.rb +0 -84
- data/spec/lib/appsignal/event_formatter/rom/sql_formatter_spec.rb +0 -22
- data/spec/lib/appsignal/event_formatter/sequel/sql_formatter_spec.rb +0 -30
- data/spec/lib/appsignal/event_formatter/view_component/render_formatter_spec.rb +0 -41
- data/spec/lib/appsignal/event_formatter_spec.rb +0 -193
- data/spec/lib/appsignal/extension/jruby_spec.rb +0 -46
- data/spec/lib/appsignal/extension_install_failure_spec.rb +0 -20
- data/spec/lib/appsignal/extension_spec.rb +0 -178
- data/spec/lib/appsignal/garbage_collection_spec.rb +0 -98
- data/spec/lib/appsignal/hooks/action_cable_spec.rb +0 -345
- data/spec/lib/appsignal/hooks/action_mailer_spec.rb +0 -55
- data/spec/lib/appsignal/hooks/active_support_notifications/finish_with_state_shared_examples.rb +0 -23
- data/spec/lib/appsignal/hooks/active_support_notifications/instrument_shared_examples.rb +0 -99
- data/spec/lib/appsignal/hooks/active_support_notifications/start_finish_shared_examples.rb +0 -47
- data/spec/lib/appsignal/hooks/active_support_notifications_spec.rb +0 -47
- data/spec/lib/appsignal/hooks/activejob_spec.rb +0 -650
- data/spec/lib/appsignal/hooks/at_exit_spec.rb +0 -105
- data/spec/lib/appsignal/hooks/celluloid_spec.rb +0 -40
- data/spec/lib/appsignal/hooks/data_mapper_spec.rb +0 -40
- data/spec/lib/appsignal/hooks/delayed_job_spec.rb +0 -38
- data/spec/lib/appsignal/hooks/dry_monitor_spec.rb +0 -83
- data/spec/lib/appsignal/hooks/excon_spec.rb +0 -67
- data/spec/lib/appsignal/hooks/gvl_spec.rb +0 -145
- data/spec/lib/appsignal/hooks/http_spec.rb +0 -37
- data/spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb +0 -46
- data/spec/lib/appsignal/hooks/mri_spec.rb +0 -23
- data/spec/lib/appsignal/hooks/net_http_spec.rb +0 -18
- data/spec/lib/appsignal/hooks/passenger_spec.rb +0 -30
- data/spec/lib/appsignal/hooks/puma_spec.rb +0 -80
- data/spec/lib/appsignal/hooks/que_spec.rb +0 -19
- data/spec/lib/appsignal/hooks/rake_spec.rb +0 -144
- data/spec/lib/appsignal/hooks/redis_client_spec.rb +0 -218
- data/spec/lib/appsignal/hooks/redis_spec.rb +0 -124
- data/spec/lib/appsignal/hooks/resque_spec.rb +0 -27
- data/spec/lib/appsignal/hooks/sequel_spec.rb +0 -44
- data/spec/lib/appsignal/hooks/shoryuken_spec.rb +0 -29
- data/spec/lib/appsignal/hooks/sidekiq_spec.rb +0 -115
- data/spec/lib/appsignal/hooks/unicorn_spec.rb +0 -63
- data/spec/lib/appsignal/hooks/webmachine_spec.rb +0 -24
- data/spec/lib/appsignal/hooks_spec.rb +0 -124
- data/spec/lib/appsignal/integrations/data_mapper_spec.rb +0 -74
- data/spec/lib/appsignal/integrations/delayed_job_plugin_spec.rb +0 -454
- data/spec/lib/appsignal/integrations/http_spec.rb +0 -111
- data/spec/lib/appsignal/integrations/mongo_ruby_driver_spec.rb +0 -154
- data/spec/lib/appsignal/integrations/net_http_spec.rb +0 -33
- data/spec/lib/appsignal/integrations/object_spec.rb +0 -347
- data/spec/lib/appsignal/integrations/puma_spec.rb +0 -150
- data/spec/lib/appsignal/integrations/que_spec.rb +0 -152
- data/spec/lib/appsignal/integrations/railtie_spec.rb +0 -457
- data/spec/lib/appsignal/integrations/resque_spec.rb +0 -155
- data/spec/lib/appsignal/integrations/shoryuken_spec.rb +0 -165
- data/spec/lib/appsignal/integrations/sidekiq_spec.rb +0 -640
- data/spec/lib/appsignal/integrations/webmachine_spec.rb +0 -136
- data/spec/lib/appsignal/loaders/grape_spec.rb +0 -12
- data/spec/lib/appsignal/loaders/hanami_spec.rb +0 -92
- data/spec/lib/appsignal/loaders/padrino_spec.rb +0 -273
- data/spec/lib/appsignal/loaders/sinatra_spec.rb +0 -44
- data/spec/lib/appsignal/loaders_spec.rb +0 -144
- data/spec/lib/appsignal/logger_spec.rb +0 -205
- data/spec/lib/appsignal/marker_spec.rb +0 -51
- data/spec/lib/appsignal/probes/gvl_spec.rb +0 -164
- data/spec/lib/appsignal/probes/mri_spec.rb +0 -162
- data/spec/lib/appsignal/probes/sidekiq_spec.rb +0 -333
- data/spec/lib/appsignal/probes_spec.rb +0 -411
- data/spec/lib/appsignal/rack/abstract_middleware_spec.rb +0 -370
- data/spec/lib/appsignal/rack/body_wrapper_spec.rb +0 -319
- data/spec/lib/appsignal/rack/event_handler_spec.rb +0 -441
- data/spec/lib/appsignal/rack/grape_middleware_spec.rb +0 -201
- data/spec/lib/appsignal/rack/hanami_middleware_spec.rb +0 -36
- data/spec/lib/appsignal/rack/instrumentation_middleware_spec.rb +0 -38
- data/spec/lib/appsignal/rack/rails_instrumentation_spec.rb +0 -126
- data/spec/lib/appsignal/rack/sinatra_instrumentation_spec.rb +0 -217
- data/spec/lib/appsignal/rack_spec.rb +0 -243
- data/spec/lib/appsignal/sample_data_spec.rb +0 -238
- data/spec/lib/appsignal/span_spec.rb +0 -141
- data/spec/lib/appsignal/system_spec.rb +0 -126
- data/spec/lib/appsignal/transaction_spec.rb +0 -2111
- data/spec/lib/appsignal/transmitter_spec.rb +0 -198
- data/spec/lib/appsignal/utils/data_spec.rb +0 -166
- data/spec/lib/appsignal/utils/hash_sanitizer_spec.rb +0 -182
- data/spec/lib/appsignal/utils/integration_logger_spec.rb +0 -21
- data/spec/lib/appsignal/utils/integration_memory_logger_spec.rb +0 -153
- data/spec/lib/appsignal/utils/json_spec.rb +0 -44
- data/spec/lib/appsignal/utils/query_params_sanitizer_spec.rb +0 -192
- data/spec/lib/appsignal_spec.rb +0 -1919
- data/spec/lib/puma/appsignal_spec.rb +0 -334
- data/spec/spec_helper.rb +0 -173
- data/spec/support/fixtures/generated_config.yml +0 -24
- data/spec/support/fixtures/projects/broken/config/appsignal.yml +0 -1
- data/spec/support/fixtures/projects/valid/config/appsignal.yml +0 -57
- data/spec/support/fixtures/projects/valid/log/.gitkeep +0 -0
- data/spec/support/fixtures/projects/valid_with_rails_app/config/application.rb +0 -16
- data/spec/support/fixtures/projects/valid_with_rails_app/config/appsignal.yml +0 -56
- data/spec/support/fixtures/projects/valid_with_rails_app/config/environment.rb +0 -10
- data/spec/support/fixtures/projects/valid_with_rails_app/log/.gitkeep +0 -0
- data/spec/support/fixtures/uploaded_file.txt +0 -0
- data/spec/support/hanami/hanami_app.rb +0 -29
- data/spec/support/helpers/action_mailer_helpers.rb +0 -25
- data/spec/support/helpers/activejob_helpers.rb +0 -27
- data/spec/support/helpers/api_request_helper.rb +0 -20
- data/spec/support/helpers/cli_helpers.rb +0 -40
- data/spec/support/helpers/config_helpers.rb +0 -66
- data/spec/support/helpers/dependency_helper.rb +0 -150
- data/spec/support/helpers/directory_helper.rb +0 -27
- data/spec/support/helpers/env_helpers.rb +0 -41
- data/spec/support/helpers/environment_metdata_helper.rb +0 -16
- data/spec/support/helpers/example_exception.rb +0 -13
- data/spec/support/helpers/example_standard_error.rb +0 -13
- data/spec/support/helpers/loader_helper.rb +0 -21
- data/spec/support/helpers/log_helpers.rb +0 -36
- data/spec/support/helpers/rails_helper.rb +0 -28
- data/spec/support/helpers/std_streams_helper.rb +0 -94
- data/spec/support/helpers/system_helpers.rb +0 -8
- data/spec/support/helpers/take_at_most_helper.rb +0 -21
- data/spec/support/helpers/time_helpers.rb +0 -11
- data/spec/support/helpers/transaction_helpers.rb +0 -122
- data/spec/support/helpers/wait_for_helper.rb +0 -39
- data/spec/support/matchers/contains_log.rb +0 -26
- data/spec/support/matchers/have_colorized_text.rb +0 -28
- data/spec/support/matchers/transaction.rb +0 -200
- data/spec/support/mocks/appsignal_mock.rb +0 -18
- data/spec/support/mocks/dummy_app.rb +0 -20
- data/spec/support/mocks/fake_gc_profiler.rb +0 -19
- data/spec/support/mocks/fake_gvl_tools.rb +0 -28
- data/spec/support/mocks/hash_like.rb +0 -10
- data/spec/support/mocks/mock_probe.rb +0 -13
- data/spec/support/mocks/puma_mock.rb +0 -43
- data/spec/support/shared_examples/instrument.rb +0 -48
- data/spec/support/stubs/appsignal/loaders/loader_stub.rb +0 -7
- data/spec/support/stubs/delayed_job.rb +0 -0
- data/spec/support/stubs/sidekiq/api.rb +0 -4
- data/spec/support/testing.rb +0 -194
- data/support/bundler_wrapper +0 -12
- data/support/install_deps +0 -33
@@ -1,333 +0,0 @@
|
|
1
|
-
require "appsignal/probes/sidekiq"
|
2
|
-
|
3
|
-
describe Appsignal::Probes::SidekiqProbe do
|
4
|
-
describe "#call" do
|
5
|
-
let(:probe) { described_class.new }
|
6
|
-
let(:redis_hostname) { "localhost" }
|
7
|
-
let(:expected_default_tags) { { :hostname => "localhost" } }
|
8
|
-
before do
|
9
|
-
start_agent
|
10
|
-
|
11
|
-
class SidekiqStats
|
12
|
-
class << self
|
13
|
-
attr_reader :calls
|
14
|
-
|
15
|
-
def count_call
|
16
|
-
@calls ||= -1
|
17
|
-
@calls += 1
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def workers_size
|
22
|
-
# First method called, so count it towards a call
|
23
|
-
self.class.count_call
|
24
|
-
24
|
25
|
-
end
|
26
|
-
|
27
|
-
def processes_size
|
28
|
-
25
|
29
|
-
end
|
30
|
-
|
31
|
-
# Return two different values for two separate calls.
|
32
|
-
# This allows us to test the delta of the value send as a gauge.
|
33
|
-
def processed
|
34
|
-
[10, 15][self.class.calls]
|
35
|
-
end
|
36
|
-
|
37
|
-
# Return two different values for two separate calls.
|
38
|
-
# This allows us to test the delta of the value send as a gauge.
|
39
|
-
def failed
|
40
|
-
[10, 13][self.class.calls]
|
41
|
-
end
|
42
|
-
|
43
|
-
def retry_size
|
44
|
-
12
|
45
|
-
end
|
46
|
-
|
47
|
-
# Return two different values for two separate calls.
|
48
|
-
# This allows us to test the delta of the value send as a gauge.
|
49
|
-
def dead_size
|
50
|
-
[10, 12][self.class.calls]
|
51
|
-
end
|
52
|
-
|
53
|
-
def scheduled_size
|
54
|
-
14
|
55
|
-
end
|
56
|
-
|
57
|
-
def enqueued
|
58
|
-
15
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
class SidekiqQueue
|
63
|
-
Queue = Struct.new(:name, :size, :latency)
|
64
|
-
|
65
|
-
def self.all
|
66
|
-
[
|
67
|
-
Queue.new("default", 10, 12),
|
68
|
-
Queue.new("critical", 1, 2)
|
69
|
-
]
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
module Sidekiq7Mock
|
74
|
-
VERSION = "7.0.0".freeze
|
75
|
-
|
76
|
-
def self.redis_info_data=(info)
|
77
|
-
@redis_info_data = info
|
78
|
-
end
|
79
|
-
|
80
|
-
def self.redis_info_data
|
81
|
-
return @redis_info_data if defined?(@redis_info_data)
|
82
|
-
|
83
|
-
{
|
84
|
-
"connected_clients" => 2,
|
85
|
-
"used_memory" => 1024,
|
86
|
-
"used_memory_rss" => 512
|
87
|
-
}
|
88
|
-
end
|
89
|
-
|
90
|
-
def self.redis
|
91
|
-
yield Client.new
|
92
|
-
end
|
93
|
-
|
94
|
-
class Client
|
95
|
-
def config
|
96
|
-
Config.new
|
97
|
-
end
|
98
|
-
|
99
|
-
def info
|
100
|
-
Sidekiq7Mock.redis_info_data
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
class Config
|
105
|
-
def host
|
106
|
-
"localhost"
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
Stats = ::SidekiqStats
|
111
|
-
Queue = ::SidekiqQueue
|
112
|
-
end
|
113
|
-
|
114
|
-
module Sidekiq6Mock
|
115
|
-
VERSION = "6.9.9".freeze
|
116
|
-
|
117
|
-
def self.redis_info
|
118
|
-
{
|
119
|
-
"connected_clients" => 2,
|
120
|
-
"used_memory" => 1024,
|
121
|
-
"used_memory_rss" => 512
|
122
|
-
}
|
123
|
-
end
|
124
|
-
|
125
|
-
def self.redis
|
126
|
-
yield Client.new
|
127
|
-
end
|
128
|
-
|
129
|
-
class Client
|
130
|
-
def connection
|
131
|
-
{ :host => "localhost" }
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
Stats = ::SidekiqStats
|
136
|
-
Queue = ::SidekiqQueue
|
137
|
-
end
|
138
|
-
end
|
139
|
-
after do
|
140
|
-
Object.send(:remove_const, :SidekiqStats)
|
141
|
-
Object.send(:remove_const, :SidekiqQueue)
|
142
|
-
Object.send(:remove_const, :Sidekiq6Mock)
|
143
|
-
Object.send(:remove_const, :Sidekiq7Mock)
|
144
|
-
end
|
145
|
-
|
146
|
-
def with_sidekiq7!
|
147
|
-
stub_const("Sidekiq", Sidekiq7Mock)
|
148
|
-
end
|
149
|
-
# Version not relevant, but requires any version for tests
|
150
|
-
alias_method :with_sidekiq!, :with_sidekiq7!
|
151
|
-
|
152
|
-
def with_sidekiq6!
|
153
|
-
stub_const("Sidekiq", Sidekiq6Mock)
|
154
|
-
end
|
155
|
-
|
156
|
-
describe ".dependencies_present?" do
|
157
|
-
context "when Sidekiq 7" do
|
158
|
-
before { with_sidekiq7! }
|
159
|
-
|
160
|
-
it "starts the probe" do
|
161
|
-
expect(described_class.dependencies_present?).to be_truthy
|
162
|
-
end
|
163
|
-
end
|
164
|
-
|
165
|
-
context "when Sidekiq 6" do
|
166
|
-
before do
|
167
|
-
with_sidekiq6!
|
168
|
-
stub_const("Redis::VERSION", version)
|
169
|
-
end
|
170
|
-
|
171
|
-
context "when Redis version is < 3.3.5" do
|
172
|
-
let(:version) { "3.3.4" }
|
173
|
-
|
174
|
-
it "does not start probe" do
|
175
|
-
expect(described_class.dependencies_present?).to be_falsy
|
176
|
-
end
|
177
|
-
end
|
178
|
-
|
179
|
-
context "when Redis version is >= 3.3.5" do
|
180
|
-
let(:version) { "3.3.5" }
|
181
|
-
|
182
|
-
it "starts the probe" do
|
183
|
-
expect(described_class.dependencies_present?).to be_truthy
|
184
|
-
end
|
185
|
-
end
|
186
|
-
end
|
187
|
-
end
|
188
|
-
|
189
|
-
it "loads Sidekiq::API" do
|
190
|
-
with_sidekiq!
|
191
|
-
# Hide the Sidekiq constant if it was already loaded. It will be
|
192
|
-
# redefined by loading "sidekiq/api" in the probe.
|
193
|
-
hide_const "Sidekiq::Stats"
|
194
|
-
|
195
|
-
expect(defined?(Sidekiq::Stats)).to be_falsy
|
196
|
-
probe
|
197
|
-
expect(defined?(Sidekiq::Stats)).to be_truthy
|
198
|
-
end
|
199
|
-
|
200
|
-
it "logs config on initialize" do
|
201
|
-
with_sidekiq!
|
202
|
-
log = capture_logs { probe }
|
203
|
-
expect(log).to contains_log(:debug, "Initializing Sidekiq probe\n")
|
204
|
-
end
|
205
|
-
|
206
|
-
context "with Sidekiq 7" do
|
207
|
-
before { with_sidekiq7! }
|
208
|
-
|
209
|
-
it "logs used hostname on call once" do
|
210
|
-
log = capture_logs { probe.call }
|
211
|
-
expect(log).to contains_log(
|
212
|
-
:debug,
|
213
|
-
%(Sidekiq probe: Using Redis server hostname "localhost" as hostname)
|
214
|
-
)
|
215
|
-
log = capture_logs { probe.call }
|
216
|
-
# Match more logs with incompelete message
|
217
|
-
expect(log).to_not contains_log(:debug, %(Sidekiq probe: ))
|
218
|
-
end
|
219
|
-
|
220
|
-
it "collects custom metrics" do
|
221
|
-
expect_gauge("worker_count", 24).twice
|
222
|
-
expect_gauge("process_count", 25).twice
|
223
|
-
expect_gauge("connection_count", 2).twice
|
224
|
-
expect_gauge("memory_usage", 1024).twice
|
225
|
-
expect_gauge("memory_usage_rss", 512).twice
|
226
|
-
expect_gauge("job_count", 5, :status => :processed) # Gauge delta
|
227
|
-
expect_gauge("job_count", 3, :status => :failed) # Gauge delta
|
228
|
-
expect_gauge("job_count", 12, :status => :retry_queue).twice
|
229
|
-
expect_gauge("job_count", 2, :status => :died) # Gauge delta
|
230
|
-
expect_gauge("job_count", 14, :status => :scheduled).twice
|
231
|
-
expect_gauge("job_count", 15, :status => :enqueued).twice
|
232
|
-
expect_gauge("queue_length", 10, :queue => "default").twice
|
233
|
-
expect_gauge("queue_latency", 12_000, :queue => "default").twice
|
234
|
-
expect_gauge("queue_length", 1, :queue => "critical").twice
|
235
|
-
expect_gauge("queue_latency", 2_000, :queue => "critical").twice
|
236
|
-
# Call probe twice so we can calculate the delta for some gauge values
|
237
|
-
probe.call
|
238
|
-
probe.call
|
239
|
-
end
|
240
|
-
|
241
|
-
context "when redis info doesn't contain requested keys" do
|
242
|
-
before { Sidekiq7Mock.redis_info_data = {} }
|
243
|
-
|
244
|
-
it "doesn't create metrics for nil values" do
|
245
|
-
expect_gauge("connection_count").never
|
246
|
-
expect_gauge("memory_usage").never
|
247
|
-
expect_gauge("memory_usage_rss").never
|
248
|
-
# Call probe twice so we can calculate the delta for some gauge values
|
249
|
-
probe.call
|
250
|
-
probe.call
|
251
|
-
end
|
252
|
-
end
|
253
|
-
end
|
254
|
-
|
255
|
-
context "with Sidekiq 6" do
|
256
|
-
before { with_sidekiq6! }
|
257
|
-
|
258
|
-
it "logs used hostname on call once" do
|
259
|
-
log = capture_logs { probe.call }
|
260
|
-
expect(log).to contains_log(
|
261
|
-
:debug,
|
262
|
-
%(Sidekiq probe: Using Redis server hostname "localhost" as hostname)
|
263
|
-
)
|
264
|
-
log = capture_logs { probe.call }
|
265
|
-
# Match more logs with incompelete message
|
266
|
-
expect(log).to_not contains_log(:debug, %(Sidekiq probe: ))
|
267
|
-
end
|
268
|
-
|
269
|
-
it "collects custom metrics" do
|
270
|
-
expect_gauge("worker_count", 24).twice
|
271
|
-
expect_gauge("process_count", 25).twice
|
272
|
-
expect_gauge("connection_count", 2).twice
|
273
|
-
expect_gauge("memory_usage", 1024).twice
|
274
|
-
expect_gauge("memory_usage_rss", 512).twice
|
275
|
-
expect_gauge("job_count", 5, :status => :processed) # Gauge delta
|
276
|
-
expect_gauge("job_count", 3, :status => :failed) # Gauge delta
|
277
|
-
expect_gauge("job_count", 12, :status => :retry_queue).twice
|
278
|
-
expect_gauge("job_count", 2, :status => :died) # Gauge delta
|
279
|
-
expect_gauge("job_count", 14, :status => :scheduled).twice
|
280
|
-
expect_gauge("job_count", 15, :status => :enqueued).twice
|
281
|
-
expect_gauge("queue_length", 10, :queue => "default").twice
|
282
|
-
expect_gauge("queue_latency", 12_000, :queue => "default").twice
|
283
|
-
expect_gauge("queue_length", 1, :queue => "critical").twice
|
284
|
-
expect_gauge("queue_latency", 2_000, :queue => "critical").twice
|
285
|
-
# Call probe twice so we can calculate the delta for some gauge values
|
286
|
-
probe.call
|
287
|
-
probe.call
|
288
|
-
end
|
289
|
-
|
290
|
-
context "when Sidekiq `redis_info` is not defined" do
|
291
|
-
before do
|
292
|
-
allow(Sidekiq).to receive(:respond_to?).with(:redis_info).and_return(false)
|
293
|
-
end
|
294
|
-
|
295
|
-
it "does not collect redis metrics" do
|
296
|
-
expect_gauge("connection_count", 2).never
|
297
|
-
expect_gauge("memory_usage", 1024).never
|
298
|
-
expect_gauge("memory_usage_rss", 512).never
|
299
|
-
probe.call
|
300
|
-
end
|
301
|
-
end
|
302
|
-
end
|
303
|
-
|
304
|
-
context "when hostname is configured for probe" do
|
305
|
-
let(:redis_hostname) { "my_redis_server" }
|
306
|
-
let(:probe) { described_class.new(:hostname => redis_hostname) }
|
307
|
-
|
308
|
-
it "uses the redis hostname for the hostname tag" do
|
309
|
-
with_sidekiq!
|
310
|
-
|
311
|
-
allow(Appsignal).to receive(:set_gauge).and_call_original
|
312
|
-
log = capture_logs { probe }
|
313
|
-
expect(log).to contains_log(
|
314
|
-
:debug,
|
315
|
-
%(Initializing Sidekiq probe with config: {:hostname=>"#{redis_hostname}"})
|
316
|
-
)
|
317
|
-
log = capture_logs { probe.call }
|
318
|
-
expect(log).to contains_log(
|
319
|
-
:debug,
|
320
|
-
"Sidekiq probe: Using hostname config option #{redis_hostname.inspect} as hostname"
|
321
|
-
)
|
322
|
-
expect(Appsignal).to have_received(:set_gauge)
|
323
|
-
.with(anything, anything, :hostname => redis_hostname).at_least(:once)
|
324
|
-
end
|
325
|
-
end
|
326
|
-
|
327
|
-
def expect_gauge(key, value = anything, tags = {})
|
328
|
-
expect(Appsignal).to receive(:set_gauge)
|
329
|
-
.with("sidekiq_#{key}", value, expected_default_tags.merge(tags))
|
330
|
-
.and_call_original
|
331
|
-
end
|
332
|
-
end
|
333
|
-
end
|