Sha256: a54868f9c904899348eddc16da80659fe7bce6cd855906e64199771b857167f2

Contents?: true

Size: 834 Bytes

Versions: 11

Compression:

Stored size: 834 Bytes

Contents

module GitHub
  class Ldap
    # Encapsulates common instrumentation behavior.
    module 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 |payload|
            payload[:result] = yield(payload) if block_given?
          end
        else
          yield(payload) if block_given?
        end
      end
      private :instrument
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
github-ldap-1.10.1 lib/github/ldap/instrumentation.rb
github-ldap-1.10.0 lib/github/ldap/instrumentation.rb
github-ldap-1.9.0 lib/github/ldap/instrumentation.rb
github-ldap-1.8.2 lib/github/ldap/instrumentation.rb
github-ldap-1.8.1 lib/github/ldap/instrumentation.rb
github-ldap-1.8.0 lib/github/ldap/instrumentation.rb
github-ldap-1.7.1 lib/github/ldap/instrumentation.rb
github-ldap-1.7.0 lib/github/ldap/instrumentation.rb
github-ldap-1.6.0 lib/github/ldap/instrumentation.rb
github-ldap-1.5.0 lib/github/ldap/instrumentation.rb
github-ldap-1.4.0 lib/github/ldap/instrumentation.rb