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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0f1d534cb7c6454c3d80e42c5a5d6c43eb399fe4
4
- data.tar.gz: 50874cb30661dc750183cc6aa0694bbc78db3cd2
3
+ metadata.gz: 26c9a55f5ae8de27e0b1607ba223096d78e5e6dd
4
+ data.tar.gz: 61ffda192893aed8a11f769b55e31ba12cf364fd
5
5
  SHA512:
6
- metadata.gz: 701c5cb8ef98c9c27c5d368cec5bddcc90b6627a7d676887424f4b6277e3ad13d337235815afa938660f5a4586a30ff9680cc4da1fe4dd7e2b5069a8e0eb8694
7
- data.tar.gz: 4710a3e60d589f3d5582fbe989d0de66e50da4dbb5c92a78be225c7f90bee37567bee4425fde4a7655ce294089d3ff905443833991a318c0c19f13d68f219db2
6
+ metadata.gz: e747d3db5d12695d933acb7b92dfb1ff564b8a8dbdc9e78ced3bbe1763d9b07276a1ab9d7edabf0c4b694daa147551cf3e99c31e27a35bbb723548eec5970f22
7
+ data.tar.gz: 5d178d6e1c0a16ee59edf0d53fcab5799cf80fa528f148f79bdf6caf714dcad26589441139b18c016df4ce9bbbe072613aa051dcfda82ba07c91fa89de245477
@@ -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 = Set.new(['Sql', 'Elastic', 'Redis'])
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.include?(meta.type)
39
- key = -"#{meta.type.downcase}_time"
40
- values[key] += stat.total_exclusive_time
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
@@ -1,3 +1,3 @@
1
1
  module HeimdallApm
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
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.0
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-10 00:00:00.000000000 Z
11
+ date: 2018-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler