Sha256: 6cd4bbedd4410a1360c5d98e54c08cba232f6a5d351d9157ca5fedcd20cf318e

Contents?: true

Size: 1.09 KB

Versions: 5

Compression:

Stored size: 1.09 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.

module NewRelic
  module Agent

    class AgentThread < ::Thread
      def initialize(label)
        ::NewRelic::Agent.logger.debug("Creating New Relic thread: #{label}")
        self[:newrelic_label] = label
        super
      end

      def self.bucket_thread(thread, profile_agent_code)
        if thread.key?(:newrelic_label)
          return profile_agent_code ? :agent : :ignore
        elsif !thread[:newrelic_transaction].nil?
          thread[:newrelic_transaction].request.nil? ? :background : :request
        else
          :other
        end
      end

      def self.scrub_backtrace(thread, profile_agent_code)
        begin
          bt = thread.backtrace
        rescue Exception => e
          ::NewRelic::Agent.logger.debug("Failed to backtrace #{thread.inspect}: #{e.class.name}: #{e.to_s}")
        end
        return nil unless bt
        profile_agent_code ? bt : bt.select { |t| t !~ /\/newrelic_rpm-\d/ }
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
newrelic_rpm-3.6.2.90.beta lib/new_relic/agent/thread.rb
newrelic_rpm-3.6.1.88 lib/new_relic/agent/thread.rb
newrelic_rpm-3.6.1.87 lib/new_relic/agent/thread.rb
newrelic_rpm-3.6.1.86.beta lib/new_relic/agent/thread.rb
newrelic_rpm-3.6.1.85.beta lib/new_relic/agent/thread.rb