Sha256: 865058b17b8f1347e114b87e10f59136f299587c57aac51eae2f1d89fed9ed44

Contents?: true

Size: 1.35 KB

Versions: 8

Compression:

Stored size: 1.35 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.to_f, 0.0].max
        start_time_in_seconds = [transaction.start_time.to_f, 0.0].max
        app_time_in_seconds   = Time.now.to_f - start_time_in_seconds

        [
          NewRelic::Agent.config[:cross_process_id],
          transaction.best_name,
          queue_time_in_seconds.to_f,
          app_time_in_seconds.to_f,
          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

8 entries across 8 versions & 1 rubygems

Version Path
newrelic_rpm-7.2.0 lib/new_relic/agent/distributed_tracing/cross_app_payload.rb
newrelic_rpm-7.1.0 lib/new_relic/agent/distributed_tracing/cross_app_payload.rb
newrelic_rpm-7.0.0 lib/new_relic/agent/distributed_tracing/cross_app_payload.rb
newrelic_rpm-6.15.0 lib/new_relic/agent/distributed_tracing/cross_app_payload.rb
newrelic_rpm-6.14.0 lib/new_relic/agent/distributed_tracing/cross_app_payload.rb
newrelic_rpm-6.13.1 lib/new_relic/agent/distributed_tracing/cross_app_payload.rb
newrelic_rpm-6.13.0 lib/new_relic/agent/distributed_tracing/cross_app_payload.rb
newrelic_rpm-6.12.0.367 lib/new_relic/agent/distributed_tracing/cross_app_payload.rb