Sha256: 032b578914990c671fe3a9ddb57cfdbaf0165a6a12f6b77023b1c301b863f399

Contents?: true

Size: 769 Bytes

Versions: 11

Compression:

Stored size: 769 Bytes

Contents

# frozen_string_literal: true

module InstrumentAllTheThings
  module Instrumentors
    DEFAULT_TRACE_OPTIONS = {
      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

11 entries across 11 versions & 1 rubygems

Version Path
instrument_all_the_things-4.0.0 lib/instrument_all_the_things/instrumentors/tracing.rb
instrument_all_the_things-3.1.2 lib/instrument_all_the_things/instrumentors/tracing.rb
instrument_all_the_things-3.1.2.pre1 lib/instrument_all_the_things/instrumentors/tracing.rb
instrument_all_the_things-3.1.1 lib/instrument_all_the_things/instrumentors/tracing.rb
instrument_all_the_things-3.1.0 lib/instrument_all_the_things/instrumentors/tracing.rb
instrument_all_the_things-3.1.0.pre1 lib/instrument_all_the_things/instrumentors/tracing.rb
instrument_all_the_things-3.0.0 lib/instrument_all_the_things/instrumentors/tracing.rb
instrument_all_the_things-3.0.0.pre1 lib/instrument_all_the_things/instrumentors/tracing.rb
instrument_all_the_things-2.0.2 lib/instrument_all_the_things/instrumentors/tracing.rb
instrument_all_the_things-2.0.1 lib/instrument_all_the_things/instrumentors/tracing.rb
instrument_all_the_things-2.0.0 lib/instrument_all_the_things/instrumentors/tracing.rb