Sha256: 84a877fed2771f478e8a8ccaf770af18a8074f44c0315586e9313b528f3ab230

Contents?: true

Size: 1.36 KB

Versions: 3

Compression:

Stored size: 1.36 KB

Contents

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

module NewRelic
  module Agent
    class CrossAppPayload
      attr_reader :id, :transaction, :referring_guid, :referring_trip_id, :referring_path_hash

      def initialize(id, transaction, transaction_info)
        @id                  = id
        @transaction         = transaction

        transaction_info ||= []
        @referring_guid      = transaction_info[0]
        # unused_flag        = transaction_info[1]
        @referring_trip_id   = string_or_false_for(transaction_info[2])
        @referring_path_hash = string_or_false_for(transaction_info[3])
      end

      def as_json_array(content_length)
        queue_time_in_seconds = [transaction.queue_time, 0.0].max
        start_time_in_seconds = [transaction.start_time, 0.0].max
        app_time_in_seconds   = Process.clock_gettime(Process::CLOCK_REALTIME) - start_time_in_seconds

        [
          NewRelic::Agent.config[:cross_process_id],
          transaction.best_name,
          queue_time_in_seconds,
          app_time_in_seconds,
          content_length,
          transaction.guid,
          false
        ]
      end

      private

      def string_or_false_for(value)
        value.is_a?(String) && value
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
newrelic_rpm-8.2.0 lib/new_relic/agent/distributed_tracing/cross_app_payload.rb
newrelic_rpm-8.1.0 lib/new_relic/agent/distributed_tracing/cross_app_payload.rb
newrelic_rpm-8.0.0 lib/new_relic/agent/distributed_tracing/cross_app_payload.rb