Sha256: c0938bc8b0185298fcc9b11c36a0e2bf6345fc41398d845e2f744e0b0de05249

Contents?: true

Size: 916 Bytes

Versions: 1

Compression:

Stored size: 916 Bytes

Contents

require 'tracebin/events'
require 'tracebin/helpers'

module Tracebin
  module CustomInstrumentation
    class << self
      include Tracebin::Helpers

      def instrument(identifier)
        unless block_given?
          raise ArgumentError, 'Tracebin instrumentation must receive a block'
        end

        start_time = timestamp_string
        yield
        end_time = timestamp_string

        event_data = [
          'custom.tracebin',
          start_time,
          end_time,
          {
            identifier: identifier
          }
        ]

        handle_event event_data
      end

      private

      def handle_event(event_data)
        event = Tracebin::CustomEvent.new event_data
        Tracebin::Recorder << event
      end
    end
  end

  # Module Tracebin
  class << self
    def instrument(*args, &block)
      Tracebin::CustomInstrumentation.instrument *args, &block
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tracebin-0.0.13 lib/tracebin/custom_instrumentation.rb