instrument_all_the_things 1.0.2 → 1.0.3
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 +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +2 -2
- data/lib/instrument_all_the_things.rb +1 -1
- data/lib/instrument_all_the_things/context.rb +1 -1
- data/lib/instrument_all_the_things/instrumentors/execution_count_and_timing.rb +7 -6
- data/lib/instrument_all_the_things/instrumentors/tracing.rb +1 -1
- data/lib/instrument_all_the_things/method_proxy.rb +20 -0
- data/lib/instrument_all_the_things/version.rb +1 -1
- data/vendor/cache/ddtrace-0.33.1.gem +0 -0
- metadata +4 -4
- data/vendor/cache/ddtrace-0.33.0.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: ac64a9b7acfa4de004260992b1c4f664587345e692a6f08f9798442b0568619d
|
4
|
+
data.tar.gz: 6bd26e6ea3186c4ca0883a4a2971dc2980f0c71409f6654a5da1ab183539b372
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97d28f7d5a86fbaf0cc1a9792ad26d39cc2a34ddc9bbbba9c82d413f19b785136af1319dc27f1a44c72f494b701fcf11003743edae6276c30a0ec100da054de8
|
7
|
+
data.tar.gz: d78092b9f1ad421ba8674ad830821558399dd471117f4fe1efda3905ef0dc472e421c4105288790582d76f15d60f8881a3da6554050ff69f50ae1a071e46fc19
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
instrument_all_the_things (1.0.
|
4
|
+
instrument_all_the_things (1.0.3)
|
5
5
|
ddtrace
|
6
6
|
dogstatsd-ruby
|
7
7
|
|
@@ -11,7 +11,7 @@ GEM
|
|
11
11
|
ast (2.4.0)
|
12
12
|
benchmark-ips (2.7.2)
|
13
13
|
coderay (1.1.2)
|
14
|
-
ddtrace (0.33.
|
14
|
+
ddtrace (0.33.1)
|
15
15
|
msgpack
|
16
16
|
diff-lcs (1.3)
|
17
17
|
docile (1.3.2)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module InstrumentAllTheThings
|
4
|
-
Context = Struct.new(:method_name, :instance, keyword_init: true) do
|
4
|
+
Context = Struct.new(:method_name, :instance, :tags, keyword_init: true) do
|
5
5
|
def stats_name(klass_or_instance)
|
6
6
|
@stats_name ||= [
|
7
7
|
class_name(klass_or_instance),
|
@@ -2,17 +2,18 @@
|
|
2
2
|
|
3
3
|
module InstrumentAllTheThings
|
4
4
|
module Instrumentors
|
5
|
-
DEFAULT_EXECUTION_COUNT_AND_TIMING_OPTIONS = {
|
5
|
+
DEFAULT_EXECUTION_COUNT_AND_TIMING_OPTIONS = {}.freeze
|
6
6
|
|
7
|
-
EXECUTION_COUNT_AND_TIMING_WRAPPER = proc do |
|
7
|
+
EXECUTION_COUNT_AND_TIMING_WRAPPER = proc do |_opts, context|
|
8
8
|
proc do |klass, next_blk, actual_code|
|
9
|
-
|
9
|
+
context.tags ||= []
|
10
10
|
|
11
|
-
InstrumentAllTheThings.
|
11
|
+
InstrumentAllTheThings.increment("#{context.stats_name(klass)}.executed", { tags: context.tags })
|
12
|
+
InstrumentAllTheThings.time("#{context.stats_name(klass)}.duration", { tags: context.tags }) do
|
12
13
|
next_blk.call(klass, actual_code)
|
13
14
|
end
|
14
|
-
rescue
|
15
|
-
InstrumentAllTheThings.increment("#{context.stats_name(klass)}.errored")
|
15
|
+
rescue StandardError
|
16
|
+
InstrumentAllTheThings.increment("#{context.stats_name(klass)}.errored", { tags: context.tags })
|
16
17
|
raise
|
17
18
|
end
|
18
19
|
end
|
@@ -19,7 +19,7 @@ module InstrumentAllTheThings
|
|
19
19
|
proc do |klass, next_blk, actual_code|
|
20
20
|
InstrumentAllTheThings.tracer.trace(
|
21
21
|
opts[:span_name],
|
22
|
-
tags:
|
22
|
+
tags: context[:tags] || {},
|
23
23
|
service: opts[:service],
|
24
24
|
resource: opts[:resource] || context.trace_name(klass),
|
25
25
|
span_type: opts[:span_type]
|
@@ -40,10 +40,30 @@ module InstrumentAllTheThings
|
|
40
40
|
@_iatt_built_for = val
|
41
41
|
end
|
42
42
|
|
43
|
+
def set_context_tags(klass, settings, *args, **kwargs) # rubocop:disable Lint/UnusedMethodArgument
|
44
|
+
return unless settings.is_a?(Hash) && settings[:trace].is_a?(Hash) && settings[:trace][:tags]
|
45
|
+
|
46
|
+
settings[:context][:tags] = settings[:trace][:tags].map do |tag|
|
47
|
+
if tag.is_a?(Proc)
|
48
|
+
if tag.arity == 1
|
49
|
+
tag.call(eval(tag.parameters[0][1].to_s))
|
50
|
+
else
|
51
|
+
klass.instance_exec(&tag)
|
52
|
+
end
|
53
|
+
else
|
54
|
+
tag
|
55
|
+
end
|
56
|
+
rescue StandardError
|
57
|
+
nil
|
58
|
+
end.compact
|
59
|
+
end
|
60
|
+
|
43
61
|
def wrap_implementation(method_name, settings)
|
44
62
|
wrap = MethodInstrumentor.new(**settings)
|
63
|
+
set_tags = method(:set_context_tags)
|
45
64
|
|
46
65
|
define_method(method_name) do |*args, **kwargs, &blk|
|
66
|
+
set_tags.call(self, settings, args, kwargs)
|
47
67
|
wrap.invoke(klass: is_a?(Class) ? self : self.class) do
|
48
68
|
super(*args, **kwargs, &blk)
|
49
69
|
end
|
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.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Malinconico
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ddtrace
|
@@ -176,7 +176,7 @@ files:
|
|
176
176
|
- vendor/cache/ast-2.4.0.gem
|
177
177
|
- vendor/cache/benchmark-ips-2.7.2.gem
|
178
178
|
- vendor/cache/coderay-1.1.2.gem
|
179
|
-
- vendor/cache/ddtrace-0.33.
|
179
|
+
- vendor/cache/ddtrace-0.33.1.gem
|
180
180
|
- vendor/cache/diff-lcs-1.3.gem
|
181
181
|
- vendor/cache/docile-1.3.2.gem
|
182
182
|
- vendor/cache/dogstatsd-ruby-4.7.0.gem
|
@@ -220,7 +220,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
220
220
|
- !ruby/object:Gem::Version
|
221
221
|
version: '0'
|
222
222
|
requirements: []
|
223
|
-
rubygems_version: 3.1
|
223
|
+
rubygems_version: 3.0.1
|
224
224
|
signing_key:
|
225
225
|
specification_version: 4
|
226
226
|
summary: Make instrumentation with DataDog easy peasy
|
Binary file
|