File tree Expand file tree Collapse file tree 2 files changed +30
-13
lines changed Expand file tree Collapse file tree 2 files changed +30
-13
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,9 @@ class Ldap
8
8
require 'github/ldap/posix_group'
9
9
require 'github/ldap/virtual_group'
10
10
require 'github/ldap/virtual_attributes'
11
+ require 'github/ldap/instrumentation'
12
+
13
+ include Instrumentation
11
14
12
15
extend Forwardable
13
16
@@ -189,18 +192,5 @@ def configure_virtual_attributes(attributes)
189
192
VirtualAttributes . new ( false )
190
193
end
191
194
end
192
-
193
- # Internal: Instrument the block if an instrumentation servie is set.
194
- #
195
- # Returns the result of the block.
196
- def instrument ( event , payload = { } )
197
- if instrumentation_service
198
- instrumentation_service . instrument ( event , payload ) do
199
- yield payload
200
- end
201
- else
202
- yield payload
203
- end
204
- end
205
195
end
206
196
end
Original file line number Diff line number Diff line change
1
+ module GitHub
2
+ class Ldap
3
+ # Encapsulates common instrumentation behavior.
4
+ class Instrumentation
5
+ attr_reader :instrumentation_service
6
+ private :instrumentation_service
7
+
8
+ # Internal: Instrument a block with the defined instrumentation service.
9
+ #
10
+ # Yields the event payload if a block is given.
11
+ #
12
+ # Skips instrumentation if no service is set.
13
+ #
14
+ # Returns the return value of the block.
15
+ def instrument ( event , payload = { } )
16
+ if instrumentation_service
17
+ instrumentation_service . instrument ( event , payload ) do |payload |
18
+ payload [ :result ] = yield ( payload ) if block_given?
19
+ end
20
+ else
21
+ yield ( payload ) if block_given?
22
+ end
23
+ end
24
+ private :instrument
25
+ end
26
+ end
27
+ end
You can’t perform that action at this time.
0 commit comments