Sha256: 0e0eea5d295863eadb222a784e6218de07907e061c695d65550d9315b93c485f

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

# encoding: utf-8
# This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.

require 'new_relic/agent/distributed_trace_transport_type'
require 'new_relic/agent/inbound_request_monitor'
require 'new_relic/agent/cross_app_tracing'

module NewRelic
  module Agent
    class DistributedTraceMonitor < InboundRequestMonitor
      def on_finished_configuring(events)
        return unless NewRelic::Agent.config[:'distributed_tracing.enabled']
        events.subscribe(:before_call, &method(:on_before_call))
      end

      NEWRELIC_TRACE_KEY = 'HTTP_NEWRELIC'

      def on_before_call(request)
        return unless NewRelic::Agent.config[:'distributed_tracing.enabled']
        return unless payload = request[NEWRELIC_TRACE_KEY]
        return unless txn = Tracer.current_transaction

        if txn.accept_distributed_trace_payload payload
          txn.distributed_trace_payload.caller_transport_type = DistributedTraceTransportType.for_rack_request(request)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
newrelic_rpm-6.8.0.360 lib/new_relic/agent/distributed_trace_monitor.rb