Sha256: 0996219a77cf1a10ff3bfb10a640c2b33551fe1f1b49108b5516d4657d5f6796

Contents?: true

Size: 786 Bytes

Versions: 1

Compression:

Stored size: 786 Bytes

Contents

# frozen_string_literal: true

module Trifle
  module Traces
    class Configuration
      attr_accessor :tracer_class, :callbacks, :bump_every

      def initialize
        @tracer_class = Trifle::Traces::Tracer::Hash
        @callbacks = { liftoff: [], bump: [], wrapup: [] }
        @bump_every = 15.seconds
      end

      def on_liftoff(tracer)
        @callbacks.fetch(:liftoff, []).map do |c|
          c.call(tracer)
        end
      end

      def on_bump(tracer)
        @callbacks.fetch(:bump, []).map do |c|
          c.call(tracer)
        end
      end

      def on_wrapup(tracer)
        @callbacks.fetch(:wrapup, []).map do |c|
          c.call(tracer)
        end
      end

      def on(event, &block)
        @callbacks[event] << block
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
trifle-traces-1.0.1 lib/trifle/traces/configuration.rb