heimdall_apm 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/heimdall_apm/agent.rb +4 -2
- data/lib/heimdall_apm/agent_context.rb +12 -0
- data/lib/heimdall_apm/points_collection.rb +9 -4
- data/lib/heimdall_apm/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26c9a55f5ae8de27e0b1607ba223096d78e5e6dd
|
4
|
+
data.tar.gz: 61ffda192893aed8a11f769b55e31ba12cf364fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e747d3db5d12695d933acb7b92dfb1ff564b8a8dbdc9e78ced3bbe1763d9b07276a1ab9d7edabf0c4b694daa147551cf3e99c31e27a35bbb723548eec5970f22
|
7
|
+
data.tar.gz: 5d178d6e1c0a16ee59edf0d53fcab5799cf80fa528f148f79bdf6caf714dcad26589441139b18c016df4ce9bbbe072613aa051dcfda82ba07c91fa89de245477
|
data/lib/heimdall_apm/agent.rb
CHANGED
@@ -45,8 +45,6 @@ module HeimdallApm
|
|
45
45
|
def start(options = {})
|
46
46
|
return unless context.config.value('enabled')
|
47
47
|
|
48
|
-
@background_thread = Thread.new { background_run }
|
49
|
-
|
50
48
|
# TODO: use instruments manager
|
51
49
|
require 'heimdall_apm/instruments/active_record' if defined?(ActiveRecord)
|
52
50
|
require 'heimdall_apm/instruments/action_controller' if defined?(ActionController)
|
@@ -57,10 +55,14 @@ module HeimdallApm
|
|
57
55
|
# TODO: make the position configurable
|
58
56
|
options[:app].config.middleware.insert_after Rack::Cors, HeimdallApm::Instruments::Middleware
|
59
57
|
end
|
58
|
+
|
59
|
+
context.started!
|
60
|
+
@background_thread = Thread.new { background_run }
|
60
61
|
end
|
61
62
|
|
62
63
|
def stop
|
63
64
|
@stopped = true
|
65
|
+
context.stopped!
|
64
66
|
if @background_thread.alive?
|
65
67
|
@background_thread.wakeup
|
66
68
|
@background_thread.join
|
@@ -11,6 +11,18 @@ module HeimdallApm
|
|
11
11
|
# Global configuration object
|
12
12
|
attr_writer :config
|
13
13
|
|
14
|
+
def started!
|
15
|
+
@started = true
|
16
|
+
end
|
17
|
+
|
18
|
+
def stopped!
|
19
|
+
@started = false
|
20
|
+
end
|
21
|
+
|
22
|
+
def started?
|
23
|
+
@started
|
24
|
+
end
|
25
|
+
|
14
26
|
def config
|
15
27
|
@config ||= ::HeimdallApm::Config.new
|
16
28
|
end
|
@@ -12,7 +12,10 @@ module HeimdallApm
|
|
12
12
|
class PointsCollection
|
13
13
|
# Metrics we want to explicitely keep separated into measurements. Everything
|
14
14
|
# else will be label as Ruby.
|
15
|
-
ROOT_METRICS =
|
15
|
+
ROOT_METRICS = ['Sql', 'Elastic', 'Redis'].map do |key|
|
16
|
+
downcased = key.downcase
|
17
|
+
[key, ["#{downcased}_time", "#{downcased}_count"]]
|
18
|
+
end.to_h
|
16
19
|
|
17
20
|
def initialize
|
18
21
|
@points = []
|
@@ -35,9 +38,11 @@ module HeimdallApm
|
|
35
38
|
tags[:endpoint] = txn.scope
|
36
39
|
|
37
40
|
metrics.each do |meta, stat|
|
38
|
-
if ROOT_METRICS.
|
39
|
-
|
40
|
-
|
41
|
+
if ROOT_METRICS.key?(meta.type)
|
42
|
+
time_key, count_key = ROOT_METRICS[meta.type]
|
43
|
+
|
44
|
+
values[time_key] += stat.total_exclusive_time
|
45
|
+
values[count_key] += stat.call_count
|
41
46
|
else
|
42
47
|
values['ruby_time'] += stat.total_exclusive_time
|
43
48
|
end
|
data/lib/heimdall_apm/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: heimdall_apm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christopher Cocchi-Perrier
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-07-
|
11
|
+
date: 2018-07-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|