metrician 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/gemfiles/Gemfile.4.2.sidekiq-4.lock +1 -1
- data/gemfiles/Gemfile.5.0.pg.lock +1 -1
- data/lib/metrician.rb +3 -4
- data/lib/metrician/middleware/request_timing.rb +6 -4
- data/lib/metrician/reporters/active_record.rb +5 -4
- data/lib/metrician/reporters/honeybadger.rb +4 -2
- data/lib/metrician/reporters/memcache.rb +3 -2
- data/lib/metrician/reporters/net_http.rb +3 -1
- data/lib/metrician/reporters/redis.rb +4 -2
- data/lib/metrician/version.rb +1 -1
- data/spec/metrician_spec.rb +37 -37
- metadata +2 -3
- data/METRICS.MD +0 -48
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50753f3c05fa7176d026cb28dad17d914eaba6dd
|
4
|
+
data.tar.gz: a2488841dfdf26f306eee4f874e59ab9e065506e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf88d35020ebcc9294f25c3933097f8627d6dec8c5d3658e035382df7ba96899dc84cc18040a9ce40755bd286923b5cb23522c28689ed17f68d854748cc760c7
|
7
|
+
data.tar.gz: 3b3a1bcf966aef58b7bec42d246ad461e022f42b13f1952c6a78949c68dd208463767c7ba03657fc075ef7bc87670e69aab76fd93b0d101e9281c8783743fd06
|
data/CHANGELOG.md
CHANGED
data/lib/metrician.rb
CHANGED
@@ -17,6 +17,7 @@ module Metrician
|
|
17
17
|
:logger,
|
18
18
|
"logger=".to_sym,
|
19
19
|
]
|
20
|
+
DEFAULT_PREFIX = "app.".freeze
|
20
21
|
|
21
22
|
def self.activate(agent)
|
22
23
|
self.agent = agent
|
@@ -51,17 +52,15 @@ module Metrician
|
|
51
52
|
klass.to_s.underscore.gsub(%r{/}, ".")
|
52
53
|
end
|
53
54
|
|
54
|
-
# TODO: consider removal/movement to Instrumental Agent
|
55
55
|
def self.prefix=(prefix)
|
56
|
+
@prefixed = nil
|
56
57
|
@prefix = prefix.to_s[-1] == "." ? prefix.to_s : "#{prefix}."
|
57
58
|
end
|
58
59
|
|
59
|
-
# TODO: consider removal/movement to Instrumental Agent
|
60
60
|
def self.prefix
|
61
|
-
@prefix
|
61
|
+
@prefix ||= DEFAULT_PREFIX
|
62
62
|
end
|
63
63
|
|
64
|
-
# TODO: consider removal/movement to Instrumental Agent
|
65
64
|
def self.prefixed?
|
66
65
|
@prefixed ||= !prefix.empty?
|
67
66
|
end
|
@@ -9,6 +9,8 @@ module Metrician
|
|
9
9
|
# middleware).
|
10
10
|
class RequestTiming
|
11
11
|
|
12
|
+
WEB_METRIC = "web".freeze
|
13
|
+
|
12
14
|
def initialize(app)
|
13
15
|
@app = app
|
14
16
|
end
|
@@ -73,16 +75,16 @@ module Metrician
|
|
73
75
|
end
|
74
76
|
|
75
77
|
def gauge(kind, value, route = nil)
|
76
|
-
Metrician.gauge("
|
78
|
+
Metrician.gauge("#{WEB_METRIC}.#{kind}", value)
|
77
79
|
if route && Middleware.route_tracking?
|
78
|
-
Metrician.gauge("
|
80
|
+
Metrician.gauge("#{WEB_METRIC}.#{kind}.#{route}", value)
|
79
81
|
end
|
80
82
|
end
|
81
83
|
|
82
84
|
def increment(kind, route = nil)
|
83
|
-
Metrician.increment("
|
85
|
+
Metrician.increment("#{WEB_METRIC}.#{kind}")
|
84
86
|
if route && Middleware.route_tracking?
|
85
|
-
Metrician.increment("
|
87
|
+
Metrician.increment("#{WEB_METRIC}.#{kind}.#{route}")
|
86
88
|
end
|
87
89
|
end
|
88
90
|
|
@@ -17,9 +17,10 @@ module Metrician
|
|
17
17
|
|
18
18
|
module QueryInterceptor
|
19
19
|
|
20
|
-
COMMAND_EXP
|
21
|
-
SQL_EXP
|
22
|
-
OTHER
|
20
|
+
COMMAND_EXP = /^(select|update|insert|delete|show|begin|commit|rollback|describe)/i
|
21
|
+
SQL_EXP = /#{COMMAND_EXP} (?:into |from |.+? from )?(?:[`"]([a-z_]+)[`"])?/i
|
22
|
+
OTHER = "other".freeze
|
23
|
+
QUERY_METRIC = "database.query"
|
23
24
|
|
24
25
|
def self.included(instrumented_class)
|
25
26
|
return if instrumented_class.method_defined?(:log_without_metrician)
|
@@ -36,7 +37,7 @@ module Metrician
|
|
36
37
|
sql = sql.dup.force_encoding(Encoding::BINARY)
|
37
38
|
config = Metrician.configuration[:database]
|
38
39
|
metrics = []
|
39
|
-
metrics <<
|
40
|
+
metrics << QUERY_METRIC if config[:query][:enabled]
|
40
41
|
if [:command, :table, :command_and_table].any?{ |key| config[key][:enabled] }
|
41
42
|
command, table = parse_sql(sql)
|
42
43
|
metrics << "database.#{command}" if config[:command][:enabled] && command
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module Metrician
|
2
2
|
class Honeybadger < Reporter
|
3
3
|
|
4
|
+
EXCEPTION_METRIC = "tracked_exception"
|
5
|
+
|
4
6
|
def self.enabled?
|
5
7
|
!!defined?(::Honeybadger) &&
|
6
8
|
Metrician.configuration[:exception][:enabled]
|
@@ -15,9 +17,9 @@ module Metrician
|
|
15
17
|
# context_manager.get_rack_env
|
16
18
|
notify_without_metrician(exception, options)
|
17
19
|
ensure
|
18
|
-
Metrician.increment(
|
20
|
+
Metrician.increment(EXCEPTION_METRIC) if Metrician.configuration[:exception][:raise][:enabled]
|
19
21
|
# TODO: underscore is rails only
|
20
|
-
Metrician.increment("
|
22
|
+
Metrician.increment("#{EXCEPTION_METRIC}.#{Metrician.dotify(exception.class.name.underscore)}") if exception && Metrician.configuration[:exception][:exception_specific][:enabled]
|
21
23
|
end
|
22
24
|
alias_method :notify_without_metrician, :notify
|
23
25
|
alias_method :notify, :notify_with_metrician
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module Metrician
|
2
2
|
class Memcache < Reporter
|
3
3
|
|
4
|
+
CACHE_METRIC = "cache.command".freeze
|
4
5
|
METHODS = %i[get delete cas prepend append replace decrement increment add set].freeze
|
5
6
|
|
6
7
|
def self.memcached_gem?
|
@@ -40,8 +41,8 @@ module Metrician
|
|
40
41
|
#{method_name}_without_metrician_trace(*args, &blk)
|
41
42
|
ensure
|
42
43
|
duration = (Time.now - start_time).to_f
|
43
|
-
Metrician.gauge(
|
44
|
-
Metrician.gauge("
|
44
|
+
Metrician.gauge(::Metrician::Memcache::CACHE_METRIC, duration) if Metrician.configuration[:cache][:command][:enabled]
|
45
|
+
Metrician.gauge("#{::Metrician::Memcache::CACHE_METRIC}.#{method_name}", duration) if Metrician.configuration[:cache][:command_specific][:enabled]
|
45
46
|
end
|
46
47
|
end
|
47
48
|
alias #{method_name}_without_metrician_trace #{method_name}
|
@@ -3,6 +3,8 @@ require "net/http"
|
|
3
3
|
module Metrician
|
4
4
|
class NetHttp < Reporter
|
5
5
|
|
6
|
+
REQUEST_METRIC = "outgoing_request"
|
7
|
+
|
6
8
|
def self.enabled?
|
7
9
|
!!defined?(Net::HTTP) &&
|
8
10
|
Metrician.configuration[:external_service][:enabled]
|
@@ -16,7 +18,7 @@ module Metrician
|
|
16
18
|
begin
|
17
19
|
request_without_metrician_trace(req, body, &block)
|
18
20
|
ensure
|
19
|
-
Metrician.gauge(
|
21
|
+
Metrician.gauge(REQUEST_METRIC, (Time.now - start_time).to_f) if Metrician.configuration[:external_service][:request][:enabled]
|
20
22
|
end
|
21
23
|
end
|
22
24
|
alias_method :request_without_metrician_trace, :request
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module Metrician
|
2
2
|
class Redis < Reporter
|
3
3
|
|
4
|
+
CACHE_METRIC = "cache.command".freeze
|
5
|
+
|
4
6
|
def self.enabled?
|
5
7
|
!!defined?(::Redis) &&
|
6
8
|
Metrician.configuration[:cache][:enabled]
|
@@ -15,10 +17,10 @@ module Metrician
|
|
15
17
|
call_without_metrician_trace(*args, &blk)
|
16
18
|
ensure
|
17
19
|
duration = (Time.now - start_time).to_f
|
18
|
-
Metrician.gauge(
|
20
|
+
Metrician.gauge(CACHE_METRIC, duration) if Metrician.configuration[:cache][:command][:enabled]
|
19
21
|
if Metrician.configuration[:cache][:command_specific][:enabled]
|
20
22
|
method_name = args[0].is_a?(Array) ? args[0][0] : args[0]
|
21
|
-
Metrician.gauge("
|
23
|
+
Metrician.gauge("#{CACHE_METRIC}.#{method_name}", duration)
|
22
24
|
end
|
23
25
|
end
|
24
26
|
end
|
data/lib/metrician/version.rb
CHANGED
data/spec/metrician_spec.rb
CHANGED
@@ -73,7 +73,7 @@ RSpec.describe Metrician do
|
|
73
73
|
describe "honeybadger" do
|
74
74
|
specify "exceptions are instrumented" do
|
75
75
|
@agent.stub(:increment)
|
76
|
-
@agent.should_receive(:increment).with("
|
76
|
+
@agent.should_receive(:increment).with("app.tracked_exception", 1)
|
77
77
|
Honeybadger.notify('Something went wrong.', {
|
78
78
|
error_class: 'MyClass',
|
79
79
|
context: {my_data: 'value'}
|
@@ -83,7 +83,7 @@ RSpec.describe Metrician do
|
|
83
83
|
specify "exceptions are instrumented (job specific, string)" do
|
84
84
|
Metrician.configuration[:exception][:exception_specific][:enabled] = true
|
85
85
|
@agent.stub(:increment)
|
86
|
-
@agent.should_receive(:increment).with("
|
86
|
+
@agent.should_receive(:increment).with("app.tracked_exception.string", 1)
|
87
87
|
Honeybadger.notify('Something went wrong.', {
|
88
88
|
error_class: 'MyClass',
|
89
89
|
context: {my_data: 'value'}
|
@@ -93,7 +93,7 @@ RSpec.describe Metrician do
|
|
93
93
|
specify "exceptions are instrumented (job specific, exception)" do
|
94
94
|
Metrician.configuration[:exception][:exception_specific][:enabled] = true
|
95
95
|
@agent.stub(:increment)
|
96
|
-
@agent.should_receive(:increment).with("
|
96
|
+
@agent.should_receive(:increment).with("app.tracked_exception.runtime_error", 1)
|
97
97
|
begin
|
98
98
|
fail 'badgers!'
|
99
99
|
rescue => exception
|
@@ -113,7 +113,7 @@ RSpec.describe Metrician do
|
|
113
113
|
|
114
114
|
specify "top level queries are instrumented" do
|
115
115
|
@agent.stub(:gauge)
|
116
|
-
@agent.should_receive(:gauge).with("database.query", anything)
|
116
|
+
@agent.should_receive(:gauge).with("app.database.query", anything)
|
117
117
|
|
118
118
|
User.where(name: "foobar").to_a
|
119
119
|
end
|
@@ -121,7 +121,7 @@ RSpec.describe Metrician do
|
|
121
121
|
specify "per command instrumentation" do
|
122
122
|
Metrician.configuration[:database][:command][:enabled] = true
|
123
123
|
@agent.stub(:gauge)
|
124
|
-
@agent.should_receive(:gauge).with("database.select", anything)
|
124
|
+
@agent.should_receive(:gauge).with("app.database.select", anything)
|
125
125
|
|
126
126
|
User.where(name: "foobar").to_a
|
127
127
|
end
|
@@ -129,7 +129,7 @@ RSpec.describe Metrician do
|
|
129
129
|
specify "per table instrumentation" do
|
130
130
|
Metrician.configuration[:database][:table][:enabled] = true
|
131
131
|
@agent.stub(:gauge)
|
132
|
-
@agent.should_receive(:gauge).with("database.users", anything)
|
132
|
+
@agent.should_receive(:gauge).with("app.database.users", anything)
|
133
133
|
|
134
134
|
User.where(name: "foobar").to_a
|
135
135
|
end
|
@@ -137,7 +137,7 @@ RSpec.describe Metrician do
|
|
137
137
|
specify "per command and table instrumentation" do
|
138
138
|
Metrician.configuration[:database][:command_and_table][:enabled] = true
|
139
139
|
@agent.stub(:gauge)
|
140
|
-
@agent.should_receive(:gauge).with("database.select.users", anything)
|
140
|
+
@agent.should_receive(:gauge).with("app.database.select.users", anything)
|
141
141
|
|
142
142
|
User.where(name: "foobar").to_a
|
143
143
|
end
|
@@ -153,7 +153,7 @@ RSpec.describe Metrician do
|
|
153
153
|
specify "DelayedJob is instrumented" do
|
154
154
|
@agent.stub(:gauge)
|
155
155
|
|
156
|
-
@agent.should_receive(:gauge).with("jobs.run", anything)
|
156
|
+
@agent.should_receive(:gauge).with("app.jobs.run", anything)
|
157
157
|
Delayed::Job.enqueue(TestDelayedJob.new(success: true))
|
158
158
|
Delayed::Worker.new(exit_on_complete: true).start
|
159
159
|
end
|
@@ -161,7 +161,7 @@ RSpec.describe Metrician do
|
|
161
161
|
specify "job errors are instrumented" do
|
162
162
|
@agent.stub(:increment)
|
163
163
|
|
164
|
-
@agent.should_receive(:increment).with("jobs.error", 1)
|
164
|
+
@agent.should_receive(:increment).with("app.jobs.error", 1)
|
165
165
|
Delayed::Job.enqueue(TestDelayedJob.new(error: true))
|
166
166
|
Delayed::Worker.new(exit_on_complete: true).start
|
167
167
|
end
|
@@ -170,7 +170,7 @@ RSpec.describe Metrician do
|
|
170
170
|
Metrician.configuration[:jobs][:job_specific][:enabled] = true
|
171
171
|
@agent.stub(:gauge)
|
172
172
|
|
173
|
-
@agent.should_receive(:gauge).with("jobs.run.job.TestDelayedJob", anything)
|
173
|
+
@agent.should_receive(:gauge).with("app.jobs.run.job.TestDelayedJob", anything)
|
174
174
|
Delayed::Job.enqueue(TestDelayedJob.new(success: true))
|
175
175
|
Delayed::Worker.new(exit_on_complete: true).start
|
176
176
|
end
|
@@ -189,14 +189,14 @@ RSpec.describe Metrician do
|
|
189
189
|
|
190
190
|
specify "Resque is instrumented" do
|
191
191
|
@agent.stub(:gauge)
|
192
|
-
@agent.should_receive(:gauge).with("jobs.run", anything)
|
192
|
+
@agent.should_receive(:gauge).with("app.jobs.run", anything)
|
193
193
|
|
194
194
|
Resque::Job.create(:default, TestResqueJob, { "success" => true })
|
195
195
|
end
|
196
196
|
|
197
197
|
specify "job errors are instrumented" do
|
198
198
|
@agent.stub(:increment)
|
199
|
-
@agent.should_receive(:increment).with("jobs.error", 1)
|
199
|
+
@agent.should_receive(:increment).with("app.jobs.error", 1)
|
200
200
|
|
201
201
|
lambda { Resque::Job.create(:default, TestResqueJob, { "error" => true }) }.should raise_error(StandardError)
|
202
202
|
end
|
@@ -221,7 +221,7 @@ RSpec.describe Metrician do
|
|
221
221
|
|
222
222
|
specify "Sidekiq is instrumented" do
|
223
223
|
@agent.stub(:gauge)
|
224
|
-
@agent.should_receive(:gauge).with("jobs.run", anything)
|
224
|
+
@agent.should_receive(:gauge).with("app.jobs.run", anything)
|
225
225
|
|
226
226
|
# avoid load order error of sidekiq here by just including the
|
227
227
|
# worker bits at latest possible time
|
@@ -230,7 +230,7 @@ RSpec.describe Metrician do
|
|
230
230
|
|
231
231
|
specify "job errors are instrumented" do
|
232
232
|
@agent.stub(:increment)
|
233
|
-
@agent.should_receive(:increment).with("jobs.error", 1)
|
233
|
+
@agent.should_receive(:increment).with("app.jobs.error", 1)
|
234
234
|
|
235
235
|
# avoid load order error of sidekiq here by just including the
|
236
236
|
# worker bits at latest possible time
|
@@ -241,7 +241,7 @@ RSpec.describe Metrician do
|
|
241
241
|
Metrician.configuration[:jobs][:job_specific][:enabled] = true
|
242
242
|
@agent.stub(:gauge)
|
243
243
|
|
244
|
-
@agent.should_receive(:gauge).with("jobs.run.job.TestSidekiqWorker", anything)
|
244
|
+
@agent.should_receive(:gauge).with("app.jobs.run.job.TestSidekiqWorker", anything)
|
245
245
|
# avoid load order error of sidekiq here by just including the
|
246
246
|
# worker bits at latest possible time
|
247
247
|
TestSidekiqWorker.perform_async({ "success" => true})
|
@@ -250,7 +250,7 @@ RSpec.describe Metrician do
|
|
250
250
|
specify "job errors are instrumented per job" do
|
251
251
|
Metrician.configuration[:jobs][:job_specific][:enabled] = true
|
252
252
|
@agent.stub(:increment)
|
253
|
-
@agent.should_receive(:increment).with("jobs.error.job.TestSidekiqWorker", 1)
|
253
|
+
@agent.should_receive(:increment).with("app.jobs.error.job.TestSidekiqWorker", 1)
|
254
254
|
|
255
255
|
# avoid load order error of sidekiq here by just including the
|
256
256
|
# worker bits at latest possible time
|
@@ -265,7 +265,7 @@ RSpec.describe Metrician do
|
|
265
265
|
Metrician.activate(agent)
|
266
266
|
client = Redis.new
|
267
267
|
agent.stub(:gauge)
|
268
|
-
agent.should_receive(:gauge).with("cache.command", anything)
|
268
|
+
agent.should_receive(:gauge).with("app.cache.command", anything)
|
269
269
|
client.get("foo-#{rand(100_000)}")
|
270
270
|
end
|
271
271
|
|
@@ -280,7 +280,7 @@ RSpec.describe Metrician do
|
|
280
280
|
Metrician.activate(agent)
|
281
281
|
agent.stub(:gauge)
|
282
282
|
|
283
|
-
agent.should_receive(:gauge).with("cache.command", anything)
|
283
|
+
agent.should_receive(:gauge).with("app.cache.command", anything)
|
284
284
|
begin
|
285
285
|
client.get("foo-#{rand(100_000)}")
|
286
286
|
rescue Memcached::NotFound
|
@@ -296,7 +296,7 @@ RSpec.describe Metrician do
|
|
296
296
|
Metrician.activate(agent)
|
297
297
|
agent.stub(:gauge)
|
298
298
|
|
299
|
-
agent.should_receive(:gauge).with("
|
299
|
+
agent.should_receive(:gauge).with("app.outgoing_request", anything)
|
300
300
|
Net::HTTP.get(URI.parse("http://example.com/"))
|
301
301
|
end
|
302
302
|
end
|
@@ -320,7 +320,7 @@ RSpec.describe Metrician do
|
|
320
320
|
specify "Rack timing is instrumented" do
|
321
321
|
agent.stub(:gauge)
|
322
322
|
|
323
|
-
agent.should_receive(:gauge).with("web.request", anything)
|
323
|
+
agent.should_receive(:gauge).with("app.web.request", anything)
|
324
324
|
get "/"
|
325
325
|
end
|
326
326
|
end
|
@@ -340,8 +340,8 @@ RSpec.describe Metrician do
|
|
340
340
|
agent.stub(:gauge)
|
341
341
|
agent.stub(:increment)
|
342
342
|
|
343
|
-
agent.should_receive(:gauge).with("web.request", anything)
|
344
|
-
agent.should_receive(:increment).with("web.error", 1)
|
343
|
+
agent.should_receive(:gauge).with("app.web.request", anything)
|
344
|
+
agent.should_receive(:increment).with("app.web.error", 1)
|
345
345
|
get "/"
|
346
346
|
end
|
347
347
|
|
@@ -351,8 +351,8 @@ RSpec.describe Metrician do
|
|
351
351
|
agent.stub(:gauge)
|
352
352
|
agent.stub(:increment)
|
353
353
|
|
354
|
-
agent.should_not_receive(:gauge).with("web.request", anything)
|
355
|
-
agent.should_receive(:increment).with("web.error", 1)
|
354
|
+
agent.should_not_receive(:gauge).with("app.web.request", anything)
|
355
|
+
agent.should_receive(:increment).with("app.web.error", 1)
|
356
356
|
get "/"
|
357
357
|
end
|
358
358
|
end
|
@@ -373,8 +373,8 @@ RSpec.describe Metrician do
|
|
373
373
|
agent.stub(:gauge)
|
374
374
|
agent.stub(:increment)
|
375
375
|
|
376
|
-
agent.should_receive(:gauge).with("web.request", anything)
|
377
|
-
agent.should_receive(:increment).with("web.error", 1)
|
376
|
+
agent.should_receive(:gauge).with("app.web.request", anything)
|
377
|
+
agent.should_receive(:increment).with("app.web.error", 1)
|
378
378
|
lambda { get "/" }.should raise_error(RuntimeError, "boom")
|
379
379
|
end
|
380
380
|
end
|
@@ -394,7 +394,7 @@ RSpec.describe Metrician do
|
|
394
394
|
Metrician.configuration[:request_timing][:queue_time][:enabled] = true
|
395
395
|
agent.stub(:gauge)
|
396
396
|
|
397
|
-
agent.should_receive(:gauge).with("web.queue_time", anything)
|
397
|
+
agent.should_receive(:gauge).with("app.web.queue_time", anything)
|
398
398
|
get "/", {}, { Metrician::Middleware::ENV_QUEUE_START_KEYS.first => 1.second.ago.to_f }
|
399
399
|
end
|
400
400
|
end
|
@@ -419,9 +419,9 @@ RSpec.describe Metrician do
|
|
419
419
|
specify "satisfied is recorded" do
|
420
420
|
agent.stub(:gauge)
|
421
421
|
|
422
|
-
agent.should_receive(:gauge).with("web.apdex.satisfied", anything)
|
423
|
-
agent.should_not_receive(:gauge).with("web.apdex.tolerated", anything)
|
424
|
-
agent.should_not_receive(:gauge).with("web.apdex.frustrated", anything)
|
422
|
+
agent.should_receive(:gauge).with("app.web.apdex.satisfied", anything)
|
423
|
+
agent.should_not_receive(:gauge).with("app.web.apdex.tolerated", anything)
|
424
|
+
agent.should_not_receive(:gauge).with("app.web.apdex.frustrated", anything)
|
425
425
|
get "/"
|
426
426
|
end
|
427
427
|
|
@@ -444,9 +444,9 @@ RSpec.describe Metrician do
|
|
444
444
|
specify "tolerated is recorded" do
|
445
445
|
agent.stub(:gauge)
|
446
446
|
|
447
|
-
agent.should_not_receive(:gauge).with("web.apdex.satisfied", anything)
|
448
|
-
agent.should_receive(:gauge).with("web.apdex.tolerated", anything)
|
449
|
-
agent.should_not_receive(:gauge).with("web.apdex.frustrated", anything)
|
447
|
+
agent.should_not_receive(:gauge).with("app.web.apdex.satisfied", anything)
|
448
|
+
agent.should_receive(:gauge).with("app.web.apdex.tolerated", anything)
|
449
|
+
agent.should_not_receive(:gauge).with("app.web.apdex.frustrated", anything)
|
450
450
|
get "/"
|
451
451
|
end
|
452
452
|
end
|
@@ -468,9 +468,9 @@ RSpec.describe Metrician do
|
|
468
468
|
specify "frustrated is recorded" do
|
469
469
|
agent.stub(:gauge)
|
470
470
|
|
471
|
-
agent.should_not_receive(:gauge).with("web.apdex.satisfied", anything)
|
472
|
-
agent.should_not_receive(:gauge).with("web.apdex.tolerated", anything)
|
473
|
-
agent.should_receive(:gauge).with("web.apdex.frustrated", anything)
|
471
|
+
agent.should_not_receive(:gauge).with("app.web.apdex.satisfied", anything)
|
472
|
+
agent.should_not_receive(:gauge).with("app.web.apdex.tolerated", anything)
|
473
|
+
agent.should_receive(:gauge).with("app.web.apdex.frustrated", anything)
|
474
474
|
get "/"
|
475
475
|
end
|
476
476
|
end
|
@@ -490,7 +490,7 @@ RSpec.describe Metrician do
|
|
490
490
|
|
491
491
|
it "hooks into rails automatically" do
|
492
492
|
agent.stub(:gauge)
|
493
|
-
agent.should_receive(:gauge).with("web.request", anything)
|
493
|
+
agent.should_receive(:gauge).with("app.web.request", anything)
|
494
494
|
|
495
495
|
get "/"
|
496
496
|
last_response.body.should == "foobar response"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metrician
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Expected Behavior
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: instrumental_agent
|
@@ -125,7 +125,6 @@ files:
|
|
125
125
|
- CHANGELOG.md
|
126
126
|
- Gemfile
|
127
127
|
- Gemfile.lock
|
128
|
-
- METRICS.MD
|
129
128
|
- README.md
|
130
129
|
- Rakefile
|
131
130
|
- gemfiles/Gemfile.4.2.sidekiq-4
|
data/METRICS.MD
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
# Metrics you can expect to report in a vanilla Rails app
|
2
|
-
|
3
|
-
### `GET /users`
|
4
|
-
|
5
|
-
* `active_record.users.find`
|
6
|
-
* `database.sql`
|
7
|
-
* `database.sql.select`
|
8
|
-
* `web.request`
|
9
|
-
* `web.request.users_controller.index.get`
|
10
|
-
* `web.request.middleware`
|
11
|
-
* `web.request.idle`
|
12
|
-
* `web.response_size`
|
13
|
-
* `web.response_size.users_controller.index.get`
|
14
|
-
|
15
|
-
*You may also see another instance of `database.sql` and an instance of `database.sql.other` if the table schema is loaded.*
|
16
|
-
|
17
|
-
*In development mode, you can expect to record one each of the following **per asset** on the page because they are served by Rack*
|
18
|
-
|
19
|
-
* `web.request`
|
20
|
-
* `web.request.assets`
|
21
|
-
* `web.request.middleware`
|
22
|
-
* `web.request.idle`
|
23
|
-
* `web.response_size`
|
24
|
-
* `web.response_size.assets`
|
25
|
-
|
26
|
-
|
27
|
-
### `PATCH /redis`
|
28
|
-
|
29
|
-
Assuming we have a form for setting a redis value, and a controller that looks like this:
|
30
|
-
|
31
|
-
```ruby
|
32
|
-
class RedisController < ApplicationController
|
33
|
-
def show
|
34
|
-
@value = $redis.get("foo")
|
35
|
-
end
|
36
|
-
|
37
|
-
def update
|
38
|
-
$redis.set("foo", params[:value])
|
39
|
-
redirect_to(redis_path)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
```
|
43
|
-
|
44
|
-
In addition to request metrics similar to those described above, we can expect the following redis-specific metrics to be recorded:
|
45
|
-
|
46
|
-
* `redis.set` - during the update
|
47
|
-
* `redis.get` - during the redirect/show
|
48
|
-
|