Sha256: 69aff85ea13c79461cf0a4c193080841d7996e622d7d290c6b3845fd45a4e07d

Contents?: true

Size: 785 Bytes

Versions: 3

Compression:

Stored size: 785 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.dup
             else
               DEFAULT_TRACE_OPTIONS.merge(opts)
             end

      span_name = opts.delete(:span_name)

      proc do |klass, next_blk, actual_code|
        passed_ops = opts.dup
        passed_ops[:resource] ||= context.trace_name(klass)
        passed_ops[:tags] ||= {}

        InstrumentAllTheThings.tracer.trace(span_name, passed_ops) do
          next_blk.call(klass, actual_code)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
instrument_all_the_things-1.2.0 lib/instrument_all_the_things/instrumentors/tracing.rb
instrument_all_the_things-1.1.1 lib/instrument_all_the_things/instrumentors/tracing.rb
instrument_all_the_things-1.1.0 lib/instrument_all_the_things/instrumentors/tracing.rb