File: instrumentation.rb

package info (click to toggle)
ruby-net-ldap 0.19.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 640 kB
  • sloc: ruby: 4,583; sh: 53; makefile: 4
file content (23 lines) | stat: -rw-r--r-- 686 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
module Net::LDAP::Instrumentation
  attr_reader :instrumentation_service
  private     :instrumentation_service

  # Internal: Instrument a block with the defined instrumentation service.
  #
  # Yields the event payload if a block is given.
  #
  # Skips instrumentation if no service is set.
  #
  # Returns the return value of the block.
  def instrument(event, payload = {})
    payload = (payload || {}).dup
    if instrumentation_service
      instrumentation_service.instrument(event, payload) do |instr_payload|
        instr_payload[:result] = yield(instr_payload) if block_given?
      end
    else
      yield(payload) if block_given?
    end
  end
  private :instrument
end