Sha256: 991b6ba9d9abec05a8664c9fd575b1c1a3ead69d6113a2cdb2d709bee2c790ec

Contents?: true

Size: 1 KB

Versions: 7

Compression:

Stored size: 1 KB

Contents

# frozen_string_literal: true

module Mnemosyne
  module Probes
    module Msgr
      module Client
        NAME = 'external.publish.msgr'

        class Probe < ::Mnemosyne::Probe
          def setup
            ::Msgr::Client.prepend Instrumentation
          end
        end

        module Instrumentation
          def publish(payload, **options)
            if (trace = ::Mnemosyne::Instrumenter.current_trace)
              meta = {}
              span = ::Mnemosyne::Span.new(NAME, meta: meta)
              span.start!

              options[:headers] ||= {}
              options[:headers][:'mnemosyne.transaction'] = trace.transaction
              options[:headers][:'mnemosyne.origin'] = span.uuid

              begin
                super
              ensure
                span.finish!
                trace << span
              end
            else
              super
            end
          end
        end
      end
    end

    register 'Msgr::Client', 'msgr/client', Msgr::Client::Probe.new
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
mnemosyne-ruby-1.14.0 lib/mnemosyne/probes/msgr/client.rb
mnemosyne-ruby-1.13.0 lib/mnemosyne/probes/msgr/client.rb
mnemosyne-ruby-1.12.1 lib/mnemosyne/probes/msgr/client.rb
mnemosyne-ruby-1.12.0 lib/mnemosyne/probes/msgr/client.rb
mnemosyne-ruby-1.11.0 lib/mnemosyne/probes/msgr/client.rb
mnemosyne-ruby-1.10.0 lib/mnemosyne/probes/msgr/client.rb
mnemosyne-ruby-1.10.0.beta1 lib/mnemosyne/probes/msgr/client.rb