Sha256: de023701b19487af8d6b84ff9311dd08c05c69c5bf9d6ddc2cce0d5b5df0e599

Contents?: true

Size: 1.56 KB

Versions: 25

Compression:

Stored size: 1.56 KB

Contents

require 'erb'

module NewRelic
  module Agent
    class TransactionInfo

      attr_accessor :token, :capture_deep_tt, :transaction_name
      attr_reader :start_time

      def initialize
        @guid = ""
        @transaction_name = "(unknown)"
        @start_time = Time.now
      end

      def force_persist_sample?(sample)
        token && sample.duration > NewRelic::Control.instance.apdex_t
      end

      def include_guid?
        token && duration > NewRelic::Control.instance.apdex_t
      end

      def guid
        @guid
      end

      def guid=(value)
        @guid = value
      end

      def duration
        Time.now - start_time
      end

      def self.get()
        Thread.current[:newrelic_transaction_info] ||= TransactionInfo.new
      end

      def self.set(instance)
        Thread.current[:newrelic_transaction_info] = instance
      end

      def self.clear
        Thread.current[:newrelic_transaction_info] = nil
      end

      # clears any existing transaction info object and initializes a new one.
      # This starts the timer for the transaction.
      def self.reset(request=nil)
        clear
        instance = get
        instance.token = get_token(request)
      end

      def self.get_token(request)
        return nil unless request
        
        agent_flag = request.cookies['NRAGENT']
        if agent_flag
          s = agent_flag.split("=")
          if s.length == 2
            if s[0] == "tk" && s[1]
              ERB::Util.h(s[1])
            end
          end
        else
          nil
        end
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 4 rubygems

Version Path
newrelic_rpm-3.4.1 lib/new_relic/agent/transaction_info.rb
newrelic_rpm-3.4.1.beta1 lib/new_relic/agent/transaction_info.rb
ghazel-newrelic_rpm-3.4.0.2 lib/new_relic/agent/transaction_info.rb
newrelic_rpm-3.4.0.1 lib/new_relic/agent/transaction_info.rb
newrelic_rpm-3.4.0 lib/new_relic/agent/transaction_info.rb
newrelic_rpm-3.4.0.beta2 lib/new_relic/agent/transaction_info.rb
newrelic_rpm-3.3.5 lib/new_relic/agent/transaction_info.rb
newrelic_rpm-3.3.5.beta1 lib/new_relic/agent/transaction_info.rb
newrelic_rpm-3.4.0.beta1 lib/new_relic/agent/transaction_info.rb
dolores_rpm-3.3.4.8 lib/new_relic/agent/transaction_info.rb
dolores_rpm-3.3.4.7 lib/new_relic/agent/transaction_info.rb
dolores_rpm-3.3.4.6 lib/new_relic/agent/transaction_info.rb
dolores_rpm-3.3.4.5 lib/new_relic/agent/transaction_info.rb
dolores_rpm-3.3.4.4 lib/new_relic/agent/transaction_info.rb
dolores_rpm-3.3.4.3 lib/new_relic/agent/transaction_info.rb
dolores_rpm-3.3.4.1.fork2 lib/new_relic/agent/transaction_info.rb
dolores_rpm-3.3.4.1.fork lib/new_relic/agent/transaction_info.rb
wd_newrelic_rpm-3.3.4.1 lib/new_relic/agent/transaction_info.rb
dolores_rpm-3.3.4.fork lib/new_relic/agent/transaction_info.rb
newrelic_rpm-3.3.4.1 lib/new_relic/agent/transaction_info.rb