instrument_all_the_things 1.0.3 → 1.0.4

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
  SHA256:
3
- metadata.gz: ac64a9b7acfa4de004260992b1c4f664587345e692a6f08f9798442b0568619d
4
- data.tar.gz: 6bd26e6ea3186c4ca0883a4a2971dc2980f0c71409f6654a5da1ab183539b372
3
+ metadata.gz: 8233c84f173a53f91f896e019fa3ad70cbf0834cc43b3291c341c633099cc13b
4
+ data.tar.gz: 71cb7736c90caa59f66e7666eb20d8b3c0a71510c0e0dd2b740ee6f3397174d0
5
5
  SHA512:
6
- metadata.gz: 97d28f7d5a86fbaf0cc1a9792ad26d39cc2a34ddc9bbbba9c82d413f19b785136af1319dc27f1a44c72f494b701fcf11003743edae6276c30a0ec100da054de8
7
- data.tar.gz: d78092b9f1ad421ba8674ad830821558399dd471117f4fe1efda3905ef0dc472e421c4105288790582d76f15d60f8881a3da6554050ff69f50ae1a071e46fc19
6
+ metadata.gz: 6614358e22371b877b9b79f63807906dcc08560a8585dcaeb985599ef889ef900c60a911ef15a1554749da0d84f0bcc92c4cffa4bd38b7b8ef5c3d0e8dbd3704
7
+ data.tar.gz: 8a19bb27f82820e1bb8695355e6e8761c02e3237e0a33c441831a57969d21a7192c96e1ccf92c35fc008d03f075227d1306583ccdbaea352ea9e2dd6a365a063
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- instrument_all_the_things (1.0.3)
4
+ instrument_all_the_things (1.0.4)
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.1)
14
+ ddtrace (0.34.0)
15
15
  msgpack
16
16
  diff-lcs (1.3)
17
17
  docile (1.3.2)
@@ -71,4 +71,4 @@ DEPENDENCIES
71
71
  simplecov
72
72
 
73
73
  BUNDLED WITH
74
- 2.0.2
74
+ 2.1.4
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:
@@ -40,21 +40,24 @@ 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
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
- if tag.arity == 1
49
- tag.call(eval(tag.parameters[0][1].to_s))
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
- rescue StandardError
57
- nil
59
+ rescue StandardError
60
+ nil
58
61
  end.compact
59
62
  end
60
63
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module InstrumentAllTheThings
4
- VERSION = '1.0.3'
4
+ VERSION = '1.0.4'
5
5
  end
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.3
4
+ version: 1.0.4
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-04-01 00:00:00.000000000 Z
11
+ date: 2020-04-08 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.1.gem
179
+ - vendor/cache/ddtrace-0.34.0.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