Sha256: bc5f365837a53628e0255355cb1bbbd3fbf056c3f0a1a8bfff27ab21a1ef0aa8

Contents?: true

Size: 1.09 KB

Versions: 3

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_metric_frame].nil?
          thread[:newrelic_metric_frame].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

3 entries across 3 versions & 1 rubygems

Version Path
newrelic_rpm-3.6.0.83 lib/new_relic/agent/thread.rb
newrelic_rpm-3.6.0.78 lib/new_relic/agent/thread.rb
newrelic_rpm-3.6.0.74.beta lib/new_relic/agent/thread.rb