instrument_all_the_things 1.0.3 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/CHANGELOG.md +3 -0
- data/Gemfile.lock +46 -39
- data/README.md +26 -0
- data/lib/instrument_all_the_things/helpers.rb +3 -0
- data/lib/instrument_all_the_things/instrumentors/tracing.rb +10 -8
- data/lib/instrument_all_the_things/method_proxy.rb +8 -5
- data/lib/instrument_all_the_things/testing/stat_tracker.rb +4 -4
- data/lib/instrument_all_the_things/version.rb +1 -1
- data/lib/instrument_all_the_things.rb +2 -4
- 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/rubocop-1.21.0.gem +0 -0
- data/vendor/cache/rubocop-ast-1.11.0.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 +34 -30
- 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.33.1.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: f94f90a7539a296a29d43cac30fe9766addbe951afd9d1b6334457e167ae9941
|
4
|
+
data.tar.gz: 91827ee4e9ffb1da8eda1f630f322fa1d20e5ef7183d41352ce8f505405491a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50a2eeba0febe1f181402c216b42ad8ef91e976cc77acfc107acf78c57eab990cf4e250c16a94de934a23039a88b930c96dd370a59e980a0ccece378eff42f8d
|
7
|
+
data.tar.gz: a18c47fd122cfc81c950aae89c8595013e451d361dfadeaf1aed56d7768d08835241d59d35b094ee340c75e51adfc7e8e1fcb7459ee75192bda5b66960b8e2bf
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
3.0.2
|
data/CHANGELOG.md
ADDED
data/Gemfile.lock
CHANGED
@@ -1,60 +1,67 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
instrument_all_the_things (1.
|
4
|
+
instrument_all_the_things (1.1.1)
|
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.21.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.9.1, < 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.11.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/README.md
CHANGED
@@ -93,6 +93,32 @@ also be passed to the DataDog tracer, and their [options](https://github.com/Dat
|
|
93
93
|
| span_type | See DD Docs. | `nil`
|
94
94
|
| tags | Set of tags to be added to the span, expected to be a hash | {}
|
95
95
|
|
96
|
+
#### Dynamic Tags
|
97
|
+
|
98
|
+
If a trace's tags need to reference either an instance variable or a parameter to the method being traced, you must pass in a proc for the tag value.
|
99
|
+
|
100
|
+
For instance variables, this will look like this:
|
101
|
+
```ruby
|
102
|
+
instrument trace: { tags: [-> { "some_stat:#{some_instance_var}" }]}
|
103
|
+
def my_instance_method
|
104
|
+
...
|
105
|
+
end
|
106
|
+
```
|
107
|
+
|
108
|
+
For parameter references, your proc will need to to have a parameter of `args` or `kwargs` (or both), depending on if the parameter you need to reference is a normal parameter or a keyword parameter. Examples:
|
109
|
+
|
110
|
+
```ruby
|
111
|
+
instrument trace: { tags: [->(args) { "log_args:#{args[0]}" }]}
|
112
|
+
def my_instance_method(my_var)
|
113
|
+
...
|
114
|
+
end
|
115
|
+
|
116
|
+
instrument trace: { tags: [->(kwargs) { "log_args:#{kwargs[:my_arg]}" }]}
|
117
|
+
def my_instance_method(my_arg:)
|
118
|
+
...
|
119
|
+
end
|
120
|
+
```
|
121
|
+
|
96
122
|
## Testing Support
|
97
123
|
|
98
124
|
You can setup your test environment by running the following setup:
|
@@ -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
|
@@ -11,19 +11,21 @@ module InstrumentAllTheThings
|
|
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
|
@@ -40,21 +40,24 @@ module InstrumentAllTheThings
|
|
40
40
|
@_iatt_built_for = val
|
41
41
|
end
|
42
42
|
|
43
|
-
def set_context_tags(klass, settings,
|
43
|
+
def set_context_tags(klass, settings, args, kwargs)
|
44
44
|
return unless settings.is_a?(Hash) && settings[:trace].is_a?(Hash) && settings[:trace][:tags]
|
45
45
|
|
46
46
|
settings[:context][:tags] = settings[:trace][:tags].map do |tag|
|
47
47
|
if tag.is_a?(Proc)
|
48
|
-
|
49
|
-
|
48
|
+
case tag.arity
|
49
|
+
when 2
|
50
|
+
tag.call(args, kwargs)
|
51
|
+
when 1
|
52
|
+
tag.parameters[0][1].to_s == 'args' ? tag.call(args) : tag.call(kwargs)
|
50
53
|
else
|
51
54
|
klass.instance_exec(&tag)
|
52
55
|
end
|
53
56
|
else
|
54
57
|
tag
|
55
58
|
end
|
56
|
-
|
57
|
-
|
59
|
+
rescue StandardError
|
60
|
+
nil
|
58
61
|
end.compact
|
59
62
|
end
|
60
63
|
|
@@ -15,14 +15,14 @@ module InstrumentAllTheThings
|
|
15
15
|
time
|
16
16
|
timing
|
17
17
|
].each do |meth|
|
18
|
-
define_method(meth) do |*args,
|
18
|
+
define_method(meth) do |*args, &blk|
|
19
|
+
opts = args.last.is_a?(Hash) ? args.last : {}
|
19
20
|
@emitted_values[meth][args[0]] << {
|
20
21
|
args: args[1..-1],
|
21
|
-
tags:
|
22
|
-
kwargs: kwargs,
|
22
|
+
tags: opts.fetch(:tags, []),
|
23
23
|
}
|
24
24
|
|
25
|
-
super(*args,
|
25
|
+
super(*args, &blk)
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
@@ -28,8 +28,6 @@ module InstrumentAllTheThings
|
|
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
|
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
|
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.2.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-09-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ddtrace
|
@@ -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,42 @@ 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/
|
199
|
-
- vendor/cache/
|
200
|
-
- vendor/cache/
|
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/rubocop-1.21.0.gem
|
200
|
+
- vendor/cache/rubocop-ast-1.11.0.gem
|
201
|
+
- vendor/cache/ruby-progressbar-1.11.0.gem
|
202
|
+
- vendor/cache/simplecov-0.21.2.gem
|
203
|
+
- vendor/cache/simplecov-html-0.12.3.gem
|
204
|
+
- vendor/cache/simplecov_json_formatter-0.1.3.gem
|
205
|
+
- vendor/cache/unicode-display_width-2.1.0.gem
|
202
206
|
homepage: https://github.com/GetTerminus/instrument-all-the-things
|
203
207
|
licenses: []
|
204
208
|
metadata:
|
205
209
|
allowed_push_host: https://www.rubygems.org
|
206
210
|
homepage_uri: https://github.com/GetTerminus/instrument-all-the-things
|
207
211
|
source_code_uri: https://github.com/GetTerminus/instrument-all-the-things
|
208
|
-
post_install_message:
|
212
|
+
post_install_message:
|
209
213
|
rdoc_options: []
|
210
214
|
require_paths:
|
211
215
|
- lib
|
@@ -220,8 +224,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
220
224
|
- !ruby/object:Gem::Version
|
221
225
|
version: '0'
|
222
226
|
requirements: []
|
223
|
-
rubygems_version: 3.
|
224
|
-
signing_key:
|
227
|
+
rubygems_version: 3.2.22
|
228
|
+
signing_key:
|
225
229
|
specification_version: 4
|
226
230
|
summary: Make instrumentation with DataDog easy peasy
|
227
231
|
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
|