scout_apm 1.5.0.pre → 1.5.0.pre2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9392c2916f2f51cd4d8f6deb672069f15f3d8e68
4
- data.tar.gz: dd764e893e93e818a22c487a0c986701153160eb
3
+ metadata.gz: 62d8acd6b57cf347630cbdd43dcea3ff0fd04769
4
+ data.tar.gz: a3cefdd503a1e87ed55469084a0906d02611c745
5
5
  SHA512:
6
- metadata.gz: 8421818c942298451ee690625cb35670088740f2862ecea8d2fceb3b4cc1cb7f15439497e3b2fede3bb52cab4756e0e48f64d30c8fdb71bbafe7b33b577ed8a6
7
- data.tar.gz: 3486c303a0509ea19042ffba56c9045329a8e91ea25181a7b0fc4817b79468853ef7d1b5608813923e488f373cf494546d0c2b842cf7b318b6693118173e0f94
6
+ metadata.gz: 09c3d488fc83ebbedcf9b5e0b543945459f5b3ab44ad1a5c92fe37165e732e92f0b691d4d203567a058805bcb636099e8987b57b1d697bc5d15b43908b36e3d3
7
+ data.tar.gz: ff962282beaff96d28866bb1fe00c811a09e87676a452d549858dbec63f67e1afa0eb6842c661d1ea8e1995903df05bb406510e3c049c060d813d0b8b20e7953
data/.gitignore CHANGED
@@ -5,4 +5,5 @@ Gemfile.lock
5
5
  pkg/*
6
6
  .rvmrc
7
7
  .idea
8
- test/tmp/*
8
+ test/tmp/*coverage/*
9
+ coverage/*
@@ -1,6 +1,11 @@
1
1
  module ScoutApm
2
2
  module LayerConverters
3
3
  class SlowJobConverter < ConverterBase
4
+ def initialize(*)
5
+ @backtraces = []
6
+ super
7
+ end
8
+
4
9
  def call
5
10
  return unless request.job?
6
11
 
@@ -68,8 +73,18 @@ module ScoutApm
68
73
  # Specific Metric
69
74
  meta_options.merge!(:desc => layer.desc.to_s) if layer.desc
70
75
  meta = MetricMeta.new(layer.legacy_metric_name, meta_options)
71
- # this has moved - commenting out for now. will copy over bits from SlowRequestConverter
72
- # meta.extra.merge!(:backtrace => ScoutApm::SlowTransaction.backtrace_parser(layer.backtrace)) if layer.backtrace
76
+ if layer.backtrace
77
+ bt = ScoutApm::Utils::BacktraceParser.new(layer.backtrace).call
78
+ if bt.any? # we could walk thru the call stack and not find in-app code
79
+ meta.backtrace = bt
80
+ # Why not just call meta.backtrace and call it done? The walker could access a later later that generates the same MetricMeta but doesn't have a backtrace. This could be
81
+ # lost in the metric_hash if it is replaced by the new key.
82
+ @backtraces << meta
83
+ else
84
+ ScoutApm::Agent.instance.logger.debug { "Unable to capture an app-specific backtrace for #{meta.inspect}\n#{layer.backtrace}" }
85
+ end
86
+ end
87
+
73
88
  metric_hash[meta] ||= MetricStats.new( meta_options.has_key?(:scope) )
74
89
  stat = metric_hash[meta]
75
90
  stat.update!(layer.total_call_time, layer.total_exclusive_time)
@@ -81,6 +96,16 @@ module ScoutApm
81
96
  stat.update!(layer.total_call_time, layer.total_exclusive_time)
82
97
  end
83
98
 
99
+ metric_hash = attach_backtraces(metric_hash)
100
+
101
+ metric_hash
102
+ end
103
+
104
+ def attach_backtraces(metric_hash)
105
+ ScoutApm::Agent.instance.logger.info("Attaching backtraces to job #{@backtraces}")
106
+ @backtraces.each do |meta_with_backtrace|
107
+ metric_hash.keys.find { |k| k == meta_with_backtrace }.backtrace = meta_with_backtrace.backtrace
108
+ end
84
109
  metric_hash
85
110
  end
86
111
  end
@@ -1,6 +1,11 @@
1
1
  module ScoutApm
2
2
  module LayerConverters
3
3
  class SlowRequestConverter < ConverterBase
4
+ def initialize(*)
5
+ @backtraces = [] # An Array of MetricMetas that have a backtrace
6
+ super
7
+ end
8
+
4
9
  def call
5
10
  scope = scope_layer
6
11
  return [nil, {}] unless scope
@@ -15,8 +20,6 @@ module ScoutApm
15
20
  stat = MetricStats.new
16
21
  stat.update!(1)
17
22
 
18
- @backtraces = [] # An Array of MetricMetas that have a backtrace
19
-
20
23
  uri = request.annotations[:uri] || ""
21
24
 
22
25
  metrics = create_metrics
@@ -84,8 +87,10 @@ module ScoutApm
84
87
  bt = ScoutApm::Utils::BacktraceParser.new(layer.backtrace).call
85
88
  if bt.any? # we could walk thru the call stack and not find in-app code
86
89
  meta.backtrace = bt
87
- # Why not just call meta.backtrace and call it done? The walker could access a later later that generates the same MetricMeta but doesn't have a backtrace. This could be
88
- # lost in the metric_hash if it is replaced by the new key.
90
+ # Why not just call meta.backtrace and call it done? The walker
91
+ # could access a later later that generates the same MetricMeta
92
+ # but doesn't have a backtrace. This could be lost in the
93
+ # metric_hash if it is replaced by the new key.
89
94
  @backtraces << meta
90
95
  else
91
96
  ScoutApm::Agent.instance.logger.debug { "Unable to capture an app-specific backtrace for #{meta.inspect}\n#{layer.backtrace}" }
@@ -16,7 +16,6 @@ module ScoutApm
16
16
  # Supports only a single-level nesting, until we have redone metric
17
17
  # classes, instead of Meta and Stats
18
18
  def metric_as_json(meta, stat, child_metrics={})
19
-
20
19
  { "bucket" => meta.type,
21
20
  "name" => meta.name, # No scope values needed here, since it's implied by the nesting.
22
21
 
@@ -19,7 +19,7 @@ module ScoutApm
19
19
  "exclusive_time" => job.exclusive_time,
20
20
 
21
21
  "metrics" => MetricsToJsonSerializer.new(job.metrics).as_json, # New style of metrics
22
- "context" => job.context,
22
+ "context" => job.context.to_hash,
23
23
  }
24
24
  end
25
25
  end
@@ -1,4 +1,4 @@
1
1
  module ScoutApm
2
- VERSION = "1.5.0.pre"
2
+ VERSION = "1.5.0.pre2"
3
3
  end
4
4
 
data/scout_apm.gemspec CHANGED
@@ -21,4 +21,5 @@ Gem::Specification.new do |s|
21
21
  s.add_development_dependency "minitest"
22
22
  s.add_development_dependency "pry"
23
23
  s.add_development_dependency "m"
24
+ s.add_development_dependency "simplecov"
24
25
  end
data/test/test_helper.rb CHANGED
@@ -1,10 +1,12 @@
1
-
2
1
  require 'minitest/autorun'
3
2
  require 'minitest/unit'
4
3
  require 'minitest/pride'
5
-
6
4
  require 'pry'
7
5
 
6
+ # Load & Start simplecov before loading scout_apm
7
+ require 'simplecov'
8
+ SimpleCov.start
9
+
8
10
  require 'scout_apm'
9
11
 
10
12
  Kernel.module_eval do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scout_apm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0.pre
4
+ version: 1.5.0.pre2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Derek Haynes
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-04-19 00:00:00.000000000 Z
12
+ date: 2016-04-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
@@ -53,6 +53,20 @@ dependencies:
53
53
  - - ">="
54
54
  - !ruby/object:Gem::Version
55
55
  version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: simplecov
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
56
70
  description: Monitors Ruby apps and reports detailed metrics on performance to Scout.
57
71
  email:
58
72
  - support@scoutapp.com