Sha256: e6328978f325d5ea88318fade8942014b2eafe4ab9459f282a52f8eb4671768e

Contents?: true

Size: 777 Bytes

Versions: 4

Compression:

Stored size: 777 Bytes

Contents

# frozen_string_literal: true

module InstrumentAllTheThings
  module Instrumentors
    DEFAULT_TRACE_OPTIONS = {
      service: '',
      span_type: '',
      tags: {},
      span_name: 'method.execution'
    }.freeze

    TRACE_WRAPPER = proc do |opts, context|
      opts = if opts == true
               DEFAULT_TRACE_OPTIONS
             else
               DEFAULT_TRACE_OPTIONS.merge(opts)
             end

      proc do |klass, next_blk, actual_code|
        InstrumentAllTheThings.tracer.trace(
          opts[:span_name],
          tags: opts[:tags],
          service: opts[:service],
          resource: opts[:resource] || context.trace_name(klass),
          span_type: opts[:span_type]
        ) { next_blk.call(klass, actual_code) }
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
instrument_all_the_things-1.0.2 lib/instrument_all_the_things/instrumentors/tracing.rb
instrument_all_the_things-1.0.1 lib/instrument_all_the_things/instrumentors/tracing.rb
instrument_all_the_things-0.9.1.alpha lib/instrument_all_the_things/instrumentors/tracing.rb
instrument_all_the_things-0.9.0.alpha lib/instrument_all_the_things/instrumentors/tracing.rb