Sha256: 4c1459a24320de05c87acd9119a3f4375f9332c9c5a5af28a9669cf31e09f1a3

Contents?: true

Size: 1.16 KB

Versions: 10

Compression:

Stored size: 1.16 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].respond_to?(:last) &&
            thread[:newrelic_transaction].last
          thread[:newrelic_transaction].last.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

10 entries across 10 versions & 1 rubygems

Version Path
newrelic_rpm-3.6.6.147 lib/new_relic/agent/thread.rb
newrelic_rpm-3.6.5.130 lib/new_relic/agent/thread.rb
newrelic_rpm-3.6.4.122 lib/new_relic/agent/thread.rb
newrelic_rpm-3.6.4.113.beta lib/new_relic/agent/thread.rb
newrelic_rpm-3.6.3.111 lib/new_relic/agent/thread.rb
newrelic_rpm-3.6.3.106 lib/new_relic/agent/thread.rb
newrelic_rpm-3.6.3.105.beta lib/new_relic/agent/thread.rb
newrelic_rpm-3.6.3.104 lib/new_relic/agent/thread.rb
newrelic_rpm-3.6.3.103.beta lib/new_relic/agent/thread.rb
newrelic_rpm-3.6.2.96 lib/new_relic/agent/thread.rb