instrument_all_the_things 1.0.4 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -0
- data/.ruby-version +1 -1
- data/CHANGELOG.md +3 -0
- data/Gemfile +3 -1
- data/Gemfile.lock +46 -39
- data/Rakefile +5 -3
- data/instrument_all_the_things.gemspec +4 -3
- data/lib/instrument_all_the_things/clients/tracer/blackhole.rb +5 -6
- data/lib/instrument_all_the_things/context.rb +1 -1
- data/lib/instrument_all_the_things/helpers.rb +5 -2
- data/lib/instrument_all_the_things/instrumentors/gc_stats.rb +4 -4
- data/lib/instrument_all_the_things/instrumentors/tracing.rb +11 -9
- data/lib/instrument_all_the_things/method_instrumentor.rb +1 -1
- data/lib/instrument_all_the_things/method_proxy.rb +12 -4
- data/lib/instrument_all_the_things/testing/rspec_matchers.rb +16 -12
- data/lib/instrument_all_the_things/testing/stat_tracker.rb +13 -12
- data/lib/instrument_all_the_things/testing/trace_tracker.rb +1 -1
- data/lib/instrument_all_the_things/version.rb +1 -1
- data/lib/instrument_all_the_things.rb +30 -5
- data/vendor/cache/ast-2.4.2.gem +0 -0
- data/vendor/cache/benchmark-ips-2.9.1.gem +0 -0
- data/vendor/cache/coderay-1.1.3.gem +0 -0
- data/vendor/cache/ddtrace-0.52.0.gem +0 -0
- data/vendor/cache/diff-lcs-1.4.4.gem +0 -0
- data/vendor/cache/docile-1.4.0.gem +0 -0
- data/vendor/cache/dogstatsd-ruby-5.2.0.gem +0 -0
- data/vendor/cache/ffi-1.15.4.gem +0 -0
- data/vendor/cache/method_source-1.0.0.gem +0 -0
- data/vendor/cache/msgpack-1.4.2.gem +0 -0
- data/vendor/cache/parallel-1.21.0.gem +0 -0
- data/vendor/cache/parser-3.0.2.0.gem +0 -0
- data/vendor/cache/pry-0.14.1.gem +0 -0
- data/vendor/cache/regexp_parser-2.1.1.gem +0 -0
- data/vendor/cache/rexml-3.2.5.gem +0 -0
- data/vendor/cache/rspec-3.10.0.gem +0 -0
- data/vendor/cache/rspec-core-3.10.1.gem +0 -0
- data/vendor/cache/rspec-expectations-3.10.1.gem +0 -0
- data/vendor/cache/rspec-mocks-3.10.2.gem +0 -0
- data/vendor/cache/rspec-support-3.10.2.gem +0 -0
- data/vendor/cache/ruby-progressbar-1.11.0.gem +0 -0
- data/vendor/cache/simplecov-0.21.2.gem +0 -0
- data/vendor/cache/simplecov-html-0.12.3.gem +0 -0
- data/vendor/cache/simplecov_json_formatter-0.1.3.gem +0 -0
- data/vendor/cache/unicode-display_width-2.1.0.gem +0 -0
- metadata +48 -46
- data/vendor/cache/ast-2.4.0.gem +0 -0
- data/vendor/cache/benchmark-ips-2.7.2.gem +0 -0
- data/vendor/cache/coderay-1.1.2.gem +0 -0
- data/vendor/cache/ddtrace-0.34.0.gem +0 -0
- data/vendor/cache/diff-lcs-1.3.gem +0 -0
- data/vendor/cache/docile-1.3.2.gem +0 -0
- data/vendor/cache/dogstatsd-ruby-4.7.0.gem +0 -0
- data/vendor/cache/jaro_winkler-1.5.4.gem +0 -0
- data/vendor/cache/method_source-0.9.2.gem +0 -0
- data/vendor/cache/msgpack-1.3.3.gem +0 -0
- data/vendor/cache/parallel-1.19.1.gem +0 -0
- data/vendor/cache/parser-2.7.0.2.gem +0 -0
- data/vendor/cache/pry-0.12.2.gem +0 -0
- data/vendor/cache/rexml-3.2.4.gem +0 -0
- data/vendor/cache/rspec-3.9.0.gem +0 -0
- data/vendor/cache/rspec-core-3.9.1.gem +0 -0
- data/vendor/cache/rspec-expectations-3.9.0.gem +0 -0
- data/vendor/cache/rspec-mocks-3.9.1.gem +0 -0
- data/vendor/cache/rspec-support-3.9.2.gem +0 -0
- data/vendor/cache/rubocop-0.80.0.gem +0 -0
- data/vendor/cache/ruby-progressbar-1.10.1.gem +0 -0
- data/vendor/cache/simplecov-0.18.1.gem +0 -0
- data/vendor/cache/simplecov-html-0.11.0.gem +0 -0
- data/vendor/cache/unicode-display_width-1.6.1.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19a589699de098a3b92a317e37a7a901f6d3d90868fd889a41a1c7e04ebaa124
|
4
|
+
data.tar.gz: 2f7b79adb14a1ac4fcfc85f8993508d357d6bcd4caa63b9e1f482c95dcf9b85e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6403abcf56557ca5dcd873c3f7133d6947eab41a4a1854cc7d25d8e0b55879478691d5682fa27c54833fa4e750c4893230852bd4edc6c2ac9516f1c2d720fa8d
|
7
|
+
data.tar.gz: ced3427628d48fc19f064b93c2647d991e0fbe4eec76e9365d1b7184d171b4c86d06b5d1ad0ac037eee703cc3a0f1d16beea4b13b1c1cd39d7ae6b4ba12c4f32
|
data/.rubocop.yml
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
3.0.2
|
data/CHANGELOG.md
ADDED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,60 +1,67 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
instrument_all_the_things (1.0
|
4
|
+
instrument_all_the_things (1.3.0)
|
5
5
|
ddtrace
|
6
6
|
dogstatsd-ruby
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
ast (2.4.
|
12
|
-
benchmark-ips (2.
|
13
|
-
coderay (1.1.
|
14
|
-
ddtrace (0.
|
11
|
+
ast (2.4.2)
|
12
|
+
benchmark-ips (2.9.1)
|
13
|
+
coderay (1.1.3)
|
14
|
+
ddtrace (0.52.0)
|
15
|
+
ffi (~> 1.0)
|
15
16
|
msgpack
|
16
|
-
diff-lcs (1.
|
17
|
-
docile (1.
|
18
|
-
dogstatsd-ruby (
|
19
|
-
|
20
|
-
method_source (0.
|
21
|
-
msgpack (1.
|
22
|
-
parallel (1.
|
23
|
-
parser (
|
24
|
-
ast (~> 2.4.
|
25
|
-
pry (0.
|
26
|
-
coderay (~> 1.1
|
27
|
-
method_source (~>
|
17
|
+
diff-lcs (1.4.4)
|
18
|
+
docile (1.4.0)
|
19
|
+
dogstatsd-ruby (5.2.0)
|
20
|
+
ffi (1.15.4)
|
21
|
+
method_source (1.0.0)
|
22
|
+
msgpack (1.4.2)
|
23
|
+
parallel (1.21.0)
|
24
|
+
parser (3.0.2.0)
|
25
|
+
ast (~> 2.4.1)
|
26
|
+
pry (0.14.1)
|
27
|
+
coderay (~> 1.1)
|
28
|
+
method_source (~> 1.0)
|
28
29
|
rainbow (3.0.0)
|
29
30
|
rake (10.5.0)
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
rspec-
|
34
|
-
rspec-
|
35
|
-
|
36
|
-
|
37
|
-
|
31
|
+
regexp_parser (2.1.1)
|
32
|
+
rexml (3.2.5)
|
33
|
+
rspec (3.10.0)
|
34
|
+
rspec-core (~> 3.10.0)
|
35
|
+
rspec-expectations (~> 3.10.0)
|
36
|
+
rspec-mocks (~> 3.10.0)
|
37
|
+
rspec-core (3.10.1)
|
38
|
+
rspec-support (~> 3.10.0)
|
39
|
+
rspec-expectations (3.10.1)
|
38
40
|
diff-lcs (>= 1.2.0, < 2.0)
|
39
|
-
rspec-support (~> 3.
|
40
|
-
rspec-mocks (3.
|
41
|
+
rspec-support (~> 3.10.0)
|
42
|
+
rspec-mocks (3.10.2)
|
41
43
|
diff-lcs (>= 1.2.0, < 2.0)
|
42
|
-
rspec-support (~> 3.
|
43
|
-
rspec-support (3.
|
44
|
-
rubocop (
|
45
|
-
jaro_winkler (~> 1.5.1)
|
44
|
+
rspec-support (~> 3.10.0)
|
45
|
+
rspec-support (3.10.2)
|
46
|
+
rubocop (1.22.0)
|
46
47
|
parallel (~> 1.10)
|
47
|
-
parser (>=
|
48
|
+
parser (>= 3.0.0.0)
|
48
49
|
rainbow (>= 2.2.2, < 4.0)
|
50
|
+
regexp_parser (>= 1.8, < 3.0)
|
49
51
|
rexml
|
52
|
+
rubocop-ast (>= 1.12.0, < 2.0)
|
50
53
|
ruby-progressbar (~> 1.7)
|
51
|
-
unicode-display_width (>= 1.4.0, <
|
52
|
-
|
53
|
-
|
54
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
55
|
+
rubocop-ast (1.12.0)
|
56
|
+
parser (>= 3.0.1.1)
|
57
|
+
ruby-progressbar (1.11.0)
|
58
|
+
simplecov (0.21.2)
|
54
59
|
docile (~> 1.1)
|
55
|
-
simplecov-html (~> 0.11
|
56
|
-
|
57
|
-
|
60
|
+
simplecov-html (~> 0.11)
|
61
|
+
simplecov_json_formatter (~> 0.1)
|
62
|
+
simplecov-html (0.12.3)
|
63
|
+
simplecov_json_formatter (0.1.3)
|
64
|
+
unicode-display_width (2.1.0)
|
58
65
|
|
59
66
|
PLATFORMS
|
60
67
|
ruby
|
@@ -71,4 +78,4 @@ DEPENDENCIES
|
|
71
78
|
simplecov
|
72
79
|
|
73
80
|
BUNDLED WITH
|
74
|
-
2.
|
81
|
+
2.2.22
|
data/Rakefile
CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.description = 'Wrappers to make instrumentation of methods easy and pleasant to read'
|
15
15
|
spec.homepage = 'https://github.com/GetTerminus/instrument-all-the-things'
|
16
16
|
|
17
|
-
spec.metadata['allowed_push_host'] =
|
17
|
+
spec.metadata['allowed_push_host'] = 'https://www.rubygems.org'
|
18
18
|
|
19
19
|
spec.metadata['homepage_uri'] = spec.homepage
|
20
20
|
spec.metadata['source_code_uri'] = 'https://github.com/GetTerminus/instrument-all-the-things'
|
@@ -28,15 +28,16 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.bindir = 'exe'
|
29
29
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
30
30
|
spec.require_paths = ['lib']
|
31
|
+
spec.required_ruby_version = '>= 2.6.0'
|
31
32
|
|
32
33
|
spec.add_dependency 'ddtrace'
|
33
34
|
spec.add_dependency 'dogstatsd-ruby'
|
34
35
|
|
36
|
+
spec.add_development_dependency 'benchmark-ips'
|
35
37
|
spec.add_development_dependency 'bundler', '~> 2.0'
|
36
38
|
spec.add_development_dependency 'pry'
|
37
39
|
spec.add_development_dependency 'rake', '~> 10.0'
|
38
40
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
39
|
-
spec.add_development_dependency 'simplecov'
|
40
41
|
spec.add_development_dependency 'rubocop'
|
41
|
-
spec.add_development_dependency '
|
42
|
+
spec.add_development_dependency 'simplecov'
|
42
43
|
end
|
@@ -1,20 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module InstrumentAllTheThings
|
2
4
|
module Clients
|
3
5
|
class Blackhole
|
4
6
|
class Span
|
5
|
-
def initialize
|
6
|
-
end
|
7
|
+
def initialize; end
|
7
8
|
|
8
|
-
def set_tag(name, value)
|
9
|
-
end
|
9
|
+
def set_tag(name, value); end
|
10
10
|
end
|
11
11
|
|
12
|
-
|
13
12
|
def initialize
|
14
13
|
reset!
|
15
14
|
end
|
16
15
|
|
17
|
-
def trace(
|
16
|
+
def trace(_name, _options)
|
18
17
|
yield Span.new
|
19
18
|
end
|
20
19
|
end
|
@@ -21,7 +21,7 @@ module InstrumentAllTheThings
|
|
21
21
|
|
22
22
|
settings[:context] = Context.new(
|
23
23
|
method_name: method_name,
|
24
|
-
instance: false
|
24
|
+
instance: false,
|
25
25
|
)
|
26
26
|
|
27
27
|
InstrumentAllTheThings::MethodProxy
|
@@ -37,7 +37,7 @@ module InstrumentAllTheThings
|
|
37
37
|
|
38
38
|
settings[:context] = Context.new(
|
39
39
|
method_name: method_name,
|
40
|
-
instance: true
|
40
|
+
instance: true,
|
41
41
|
)
|
42
42
|
|
43
43
|
InstrumentAllTheThings::MethodProxy
|
@@ -50,6 +50,9 @@ module InstrumentAllTheThings
|
|
50
50
|
|
51
51
|
def self.included(other_class)
|
52
52
|
other_class.extend(ClassMethods)
|
53
|
+
|
54
|
+
InstrumentAllTheThings::MethodProxy.for_class(other_class)
|
55
|
+
InstrumentAllTheThings::MethodProxy.for_class(other_class.singleton_class)
|
53
56
|
end
|
54
57
|
end
|
55
58
|
end
|
@@ -7,7 +7,7 @@ module InstrumentAllTheThings
|
|
7
7
|
total_allocated_pages
|
8
8
|
total_allocated_objects
|
9
9
|
count
|
10
|
-
].freeze
|
10
|
+
].freeze,
|
11
11
|
}.freeze
|
12
12
|
|
13
13
|
# This is to make it easier to spec since other
|
@@ -19,12 +19,12 @@ module InstrumentAllTheThings
|
|
19
19
|
DEFAULT_GC_STATS_OPTIONS
|
20
20
|
else
|
21
21
|
DEFAULT_GC_STATS_OPTIONS.merge(opts)
|
22
|
-
|
22
|
+
end
|
23
23
|
|
24
24
|
report_value = proc do |klass, stat_name, value|
|
25
25
|
InstrumentAllTheThings.stat_reporter.histogram(
|
26
26
|
context.stats_name(klass) + ".#{stat_name}_change",
|
27
|
-
value
|
27
|
+
value,
|
28
28
|
)
|
29
29
|
end
|
30
30
|
|
@@ -38,7 +38,7 @@ module InstrumentAllTheThings
|
|
38
38
|
end
|
39
39
|
|
40
40
|
if (span = InstrumentAllTheThings.tracer.active_span)
|
41
|
-
span.
|
41
|
+
span.set_tags(IATT.to_tracer_tags(diff, 'gc_stats'))
|
42
42
|
end
|
43
43
|
|
44
44
|
diff.each { |s, v| report_value.call(klass, s, v) }
|
@@ -6,24 +6,26 @@ module InstrumentAllTheThings
|
|
6
6
|
service: '',
|
7
7
|
span_type: '',
|
8
8
|
tags: {},
|
9
|
-
span_name: 'method.execution'
|
9
|
+
span_name: 'method.execution',
|
10
10
|
}.freeze
|
11
11
|
|
12
12
|
TRACE_WRAPPER = proc do |opts, context|
|
13
13
|
opts = if opts == true
|
14
|
-
DEFAULT_TRACE_OPTIONS
|
14
|
+
DEFAULT_TRACE_OPTIONS.dup
|
15
15
|
else
|
16
16
|
DEFAULT_TRACE_OPTIONS.merge(opts)
|
17
17
|
end
|
18
18
|
|
19
|
+
span_name = opts.delete(:span_name)
|
20
|
+
|
19
21
|
proc do |klass, next_blk, actual_code|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
passed_ops = opts.dup
|
23
|
+
passed_ops[:resource] ||= context.trace_name(klass)
|
24
|
+
passed_ops[:tags] ||= {}
|
25
|
+
|
26
|
+
InstrumentAllTheThings.tracer.trace(span_name, passed_ops) do
|
27
|
+
next_blk.call(klass, actual_code)
|
28
|
+
end
|
27
29
|
end
|
28
30
|
end
|
29
31
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# rubocop:todo Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
4
|
+
|
3
5
|
require_relative './method_instrumentor'
|
4
6
|
|
5
7
|
module InstrumentAllTheThings
|
@@ -22,9 +24,13 @@ module InstrumentAllTheThings
|
|
22
24
|
end
|
23
25
|
|
24
26
|
def self.construct_for_class(klass)
|
25
|
-
Module.new do
|
27
|
+
mod = Module.new do
|
26
28
|
extend Instrumentor
|
27
|
-
end
|
29
|
+
end
|
30
|
+
|
31
|
+
mod._iatt_built_for = klass
|
32
|
+
|
33
|
+
mod
|
28
34
|
end
|
29
35
|
|
30
36
|
module Instrumentor
|
@@ -56,8 +62,8 @@ module InstrumentAllTheThings
|
|
56
62
|
else
|
57
63
|
tag
|
58
64
|
end
|
59
|
-
|
60
|
-
|
65
|
+
rescue StandardError
|
66
|
+
nil
|
61
67
|
end.compact
|
62
68
|
end
|
63
69
|
|
@@ -75,3 +81,5 @@ module InstrumentAllTheThings
|
|
75
81
|
end
|
76
82
|
end
|
77
83
|
end
|
84
|
+
|
85
|
+
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
@@ -1,11 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# rubocop:todo Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
4
|
+
|
3
5
|
module InstrumentAllTheThings
|
4
6
|
module Testing
|
5
7
|
module RSpecMatchers
|
6
8
|
def histogram_value(counter_name)
|
7
9
|
stats = InstrumentAllTheThings.stat_reporter.emitted_values[:histogram][counter_name]
|
8
|
-
stats.inject(0){|l, n| l + n[:args][0] }
|
10
|
+
stats.inject(0) { |l, n| l + n[:args][0] }
|
9
11
|
end
|
10
12
|
|
11
13
|
def distribution_values(distribution_name, with_tags: nil)
|
@@ -13,11 +15,11 @@ module InstrumentAllTheThings
|
|
13
15
|
|
14
16
|
if with_tags && !stats.empty?
|
15
17
|
stats = stats.select do |s|
|
16
|
-
with_tags.all?{|t| s[:tags].include?(t) }
|
18
|
+
with_tags.all? { |t| s[:tags].include?(t) }
|
17
19
|
end
|
18
20
|
end
|
19
21
|
|
20
|
-
stats&.map{|i| i[:args] }&.map(&:first) || []
|
22
|
+
stats&.map { |i| i[:args] }&.map(&:first) || []
|
21
23
|
end
|
22
24
|
|
23
25
|
def histogram_values(histogram_name, with_tags: nil)
|
@@ -25,11 +27,11 @@ module InstrumentAllTheThings
|
|
25
27
|
|
26
28
|
if with_tags && !stats.empty?
|
27
29
|
stats = stats.select do |s|
|
28
|
-
with_tags.all?{|t| s[:tags].include?(t) }
|
30
|
+
with_tags.all? { |t| s[:tags].include?(t) }
|
29
31
|
end
|
30
32
|
end
|
31
33
|
|
32
|
-
stats&.map{|i| i[:args] }&.map(&:first) || []
|
34
|
+
stats&.map { |i| i[:args] }&.map(&:first) || []
|
33
35
|
end
|
34
36
|
|
35
37
|
def timing_values(timing_name, with_tags: nil)
|
@@ -37,11 +39,11 @@ module InstrumentAllTheThings
|
|
37
39
|
|
38
40
|
if with_tags && !stats.empty?
|
39
41
|
stats = stats.select do |s|
|
40
|
-
with_tags.all?{|t| s[:tags].include?(t) }
|
42
|
+
with_tags.all? { |t| s[:tags].include?(t) }
|
41
43
|
end
|
42
44
|
end
|
43
45
|
|
44
|
-
stats&.map{|i| i[:args] }&.map(&:first) || []
|
46
|
+
stats&.map { |i| i[:args] }&.map(&:first) || []
|
45
47
|
end
|
46
48
|
|
47
49
|
def set_value(counter_name, with_tags: nil)
|
@@ -49,11 +51,11 @@ module InstrumentAllTheThings
|
|
49
51
|
|
50
52
|
if with_tags && !stats.empty?
|
51
53
|
stats = stats.select do |s|
|
52
|
-
with_tags.all?{|t| s[:tags].include?(t) }
|
54
|
+
with_tags.all? { |t| s[:tags].include?(t) }
|
53
55
|
end
|
54
56
|
end
|
55
57
|
|
56
|
-
data = stats&.map{|i| i[:args] }&.map(&:first)
|
58
|
+
data = stats&.map { |i| i[:args] }&.map(&:first)
|
57
59
|
data ? data.uniq.length : 0
|
58
60
|
end
|
59
61
|
|
@@ -62,7 +64,7 @@ module InstrumentAllTheThings
|
|
62
64
|
|
63
65
|
if with_tags && !stats.empty?
|
64
66
|
stats = stats.select do |s|
|
65
|
-
with_tags.all?{|t| s[:tags].include?(t) }
|
67
|
+
with_tags.all? { |t| s[:tags].include?(t) }
|
66
68
|
end
|
67
69
|
end
|
68
70
|
stats.last&.fetch(:args)&.first
|
@@ -72,10 +74,10 @@ module InstrumentAllTheThings
|
|
72
74
|
stats = InstrumentAllTheThings.stat_reporter.emitted_values[:count][counter_name]
|
73
75
|
if with_tags && !stats.empty?
|
74
76
|
stats = stats.select do |s|
|
75
|
-
with_tags.all?{|t| s[:tags].include?(t) }
|
77
|
+
with_tags.all? { |t| s[:tags].include?(t) }
|
76
78
|
end
|
77
79
|
end
|
78
|
-
stats.inject(0){|l, n| l + n[:args][0] }
|
80
|
+
stats.inject(0) { |l, n| l + n[:args][0] }
|
79
81
|
end
|
80
82
|
|
81
83
|
def flush_traces
|
@@ -95,3 +97,5 @@ module InstrumentAllTheThings
|
|
95
97
|
end
|
96
98
|
end
|
97
99
|
end
|
100
|
+
|
101
|
+
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
@@ -6,23 +6,24 @@ module InstrumentAllTheThings
|
|
6
6
|
module Testing
|
7
7
|
class StatTracker < Clients::StatReporter::DataDog
|
8
8
|
attr_reader :emitted_values
|
9
|
+
|
9
10
|
%i[
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
11
|
+
count
|
12
|
+
distribution
|
13
|
+
gauge
|
14
|
+
histogram
|
15
|
+
set
|
16
|
+
time
|
17
|
+
timing
|
17
18
|
].each do |meth|
|
18
|
-
define_method(meth) do |*args,
|
19
|
+
define_method(meth) do |*args, &blk|
|
20
|
+
opts = args.last.is_a?(Hash) ? args.last : {}
|
19
21
|
@emitted_values[meth][args[0]] << {
|
20
|
-
args: args[1
|
21
|
-
tags:
|
22
|
-
kwargs: kwargs,
|
22
|
+
args: args[1..],
|
23
|
+
tags: opts.fetch(:tags, []),
|
23
24
|
}
|
24
25
|
|
25
|
-
super(*args,
|
26
|
+
super(*args, &blk)
|
26
27
|
end
|
27
28
|
end
|
28
29
|
|
@@ -23,13 +23,11 @@ module InstrumentAllTheThings
|
|
23
23
|
App.logger
|
24
24
|
else
|
25
25
|
require 'logger'
|
26
|
-
Logger.new(
|
26
|
+
Logger.new($stdout)
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
30
|
def stat_reporter
|
31
|
-
return @stat_reporter if defined?(@stat_reporter)
|
32
|
-
|
33
31
|
@stat_reporter ||= Clients::StatReporter::DataDog.new(
|
34
32
|
ENV.fetch('DATADOG_HOST', 'localhost'),
|
35
33
|
ENV.fetch('DATADOG_PORT', 8125),
|
@@ -54,10 +52,10 @@ module InstrumentAllTheThings
|
|
54
52
|
timing
|
55
53
|
time
|
56
54
|
].each do |method_name|
|
57
|
-
define_method(method_name) do |*args,
|
55
|
+
define_method(method_name) do |*args, &blk|
|
58
56
|
return unless stat_reporter
|
59
57
|
|
60
|
-
stat_reporter.public_send(method_name, *args,
|
58
|
+
stat_reporter.public_send(method_name, *args, &blk)
|
61
59
|
end
|
62
60
|
end
|
63
61
|
end
|
@@ -65,6 +63,33 @@ module InstrumentAllTheThings
|
|
65
63
|
def self.included(other)
|
66
64
|
other.include(Helpers)
|
67
65
|
end
|
66
|
+
|
67
|
+
def self.tag_active_span(tag_name, tag_value)
|
68
|
+
tracer&.active_span&.set_tags(to_tracer_tags(tag_name => tag_value))
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.tag_active_root_span(tag_name, tag_value)
|
72
|
+
tracer&.active_span&.set_tags(to_tracer_tags(tag_name => tag_value))
|
73
|
+
end
|
74
|
+
|
75
|
+
def self.to_tracer_tags(hsh, prefix = nil)
|
76
|
+
hsh.each_with_object({}) do |(hash_key, value), acc|
|
77
|
+
key = prefix ? "#{prefix}.#{hash_key}" : hash_key
|
78
|
+
|
79
|
+
case value
|
80
|
+
when Hash
|
81
|
+
acc.merge!(to_tracer_tags(value, key))
|
82
|
+
when Array
|
83
|
+
content = value.each_with_index.each_with_object({}) do |(item, index), reformed|
|
84
|
+
reformed[index] = item
|
85
|
+
end
|
86
|
+
|
87
|
+
acc.merge!(to_tracer_tags(content, key))
|
88
|
+
else
|
89
|
+
acc[key] = value
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
68
93
|
end
|
69
94
|
|
70
95
|
IATT = InstrumentAllTheThings unless defined?(IATT)
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: instrument_all_the_things
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Malinconico
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ddtrace
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: benchmark-ips
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: bundler
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,20 +108,6 @@ dependencies:
|
|
94
108
|
- - "~>"
|
95
109
|
- !ruby/object:Gem::Version
|
96
110
|
version: '3.0'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: simplecov
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - ">="
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - ">="
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: rubocop
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -123,7 +123,7 @@ dependencies:
|
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
|
-
name:
|
126
|
+
name: simplecov
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
129
|
- - ">="
|
@@ -149,6 +149,7 @@ files:
|
|
149
149
|
- ".rubocop.yml"
|
150
150
|
- ".ruby-version"
|
151
151
|
- ".travis.yml"
|
152
|
+
- CHANGELOG.md
|
152
153
|
- Gemfile
|
153
154
|
- Gemfile.lock
|
154
155
|
- README.md
|
@@ -173,39 +174,40 @@ files:
|
|
173
174
|
- lib/instrument_all_the_things/testing/trace_tracker.rb
|
174
175
|
- lib/instrument_all_the_things/version.rb
|
175
176
|
- logo.jpg
|
176
|
-
- vendor/cache/ast-2.4.
|
177
|
-
- vendor/cache/benchmark-ips-2.
|
178
|
-
- vendor/cache/coderay-1.1.
|
179
|
-
- vendor/cache/ddtrace-0.
|
180
|
-
- vendor/cache/diff-lcs-1.
|
181
|
-
- vendor/cache/docile-1.
|
182
|
-
- vendor/cache/dogstatsd-ruby-
|
183
|
-
- vendor/cache/
|
184
|
-
- vendor/cache/method_source-0.
|
185
|
-
- vendor/cache/msgpack-1.
|
186
|
-
- vendor/cache/parallel-1.
|
187
|
-
- vendor/cache/parser-
|
188
|
-
- vendor/cache/pry-0.
|
177
|
+
- vendor/cache/ast-2.4.2.gem
|
178
|
+
- vendor/cache/benchmark-ips-2.9.1.gem
|
179
|
+
- vendor/cache/coderay-1.1.3.gem
|
180
|
+
- vendor/cache/ddtrace-0.52.0.gem
|
181
|
+
- vendor/cache/diff-lcs-1.4.4.gem
|
182
|
+
- vendor/cache/docile-1.4.0.gem
|
183
|
+
- vendor/cache/dogstatsd-ruby-5.2.0.gem
|
184
|
+
- vendor/cache/ffi-1.15.4.gem
|
185
|
+
- vendor/cache/method_source-1.0.0.gem
|
186
|
+
- vendor/cache/msgpack-1.4.2.gem
|
187
|
+
- vendor/cache/parallel-1.21.0.gem
|
188
|
+
- vendor/cache/parser-3.0.2.0.gem
|
189
|
+
- vendor/cache/pry-0.14.1.gem
|
189
190
|
- vendor/cache/rainbow-3.0.0.gem
|
190
191
|
- vendor/cache/rake-10.5.0.gem
|
191
|
-
- vendor/cache/
|
192
|
-
- vendor/cache/
|
193
|
-
- vendor/cache/rspec-
|
194
|
-
- vendor/cache/rspec-
|
195
|
-
- vendor/cache/rspec-
|
196
|
-
- vendor/cache/rspec-
|
197
|
-
- vendor/cache/
|
198
|
-
- vendor/cache/ruby-progressbar-1.
|
199
|
-
- vendor/cache/simplecov-0.
|
200
|
-
- vendor/cache/simplecov-html-0.
|
201
|
-
- vendor/cache/
|
192
|
+
- vendor/cache/regexp_parser-2.1.1.gem
|
193
|
+
- vendor/cache/rexml-3.2.5.gem
|
194
|
+
- vendor/cache/rspec-3.10.0.gem
|
195
|
+
- vendor/cache/rspec-core-3.10.1.gem
|
196
|
+
- vendor/cache/rspec-expectations-3.10.1.gem
|
197
|
+
- vendor/cache/rspec-mocks-3.10.2.gem
|
198
|
+
- vendor/cache/rspec-support-3.10.2.gem
|
199
|
+
- vendor/cache/ruby-progressbar-1.11.0.gem
|
200
|
+
- vendor/cache/simplecov-0.21.2.gem
|
201
|
+
- vendor/cache/simplecov-html-0.12.3.gem
|
202
|
+
- vendor/cache/simplecov_json_formatter-0.1.3.gem
|
203
|
+
- vendor/cache/unicode-display_width-2.1.0.gem
|
202
204
|
homepage: https://github.com/GetTerminus/instrument-all-the-things
|
203
205
|
licenses: []
|
204
206
|
metadata:
|
205
207
|
allowed_push_host: https://www.rubygems.org
|
206
208
|
homepage_uri: https://github.com/GetTerminus/instrument-all-the-things
|
207
209
|
source_code_uri: https://github.com/GetTerminus/instrument-all-the-things
|
208
|
-
post_install_message:
|
210
|
+
post_install_message:
|
209
211
|
rdoc_options: []
|
210
212
|
require_paths:
|
211
213
|
- lib
|
@@ -213,15 +215,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
213
215
|
requirements:
|
214
216
|
- - ">="
|
215
217
|
- !ruby/object:Gem::Version
|
216
|
-
version:
|
218
|
+
version: 2.6.0
|
217
219
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
218
220
|
requirements:
|
219
221
|
- - ">="
|
220
222
|
- !ruby/object:Gem::Version
|
221
223
|
version: '0'
|
222
224
|
requirements: []
|
223
|
-
rubygems_version: 3.
|
224
|
-
signing_key:
|
225
|
+
rubygems_version: 3.2.22
|
226
|
+
signing_key:
|
225
227
|
specification_version: 4
|
226
228
|
summary: Make instrumentation with DataDog easy peasy
|
227
229
|
test_files: []
|
data/vendor/cache/ast-2.4.0.gem
DELETED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/vendor/cache/pry-0.12.2.gem
DELETED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|