Sha256: 036c73ea4c01427af9977968f7dcd6fde32fdd8e514d2c6848f330aef9754069

Contents?: true

Size: 1.22 KB

Versions: 15

Compression:

Stored size: 1.22 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
    module Threading

      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)
            profile_agent_code ? :agent : :ignore
          elsif TransactionState.in_background_transaction?(thread)
            :background
          elsif TransactionState.in_request_transaction?(thread)
            :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
          bt.reject! { |t| t.include?('/newrelic_rpm-') } unless profile_agent_code
          bt
        end
      end

    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
newrelic_rpm-3.8.1.221 lib/new_relic/agent/threading/agent_thread.rb
newrelic_rpm-3.8.0.218 lib/new_relic/agent/threading/agent_thread.rb
newrelic_rpm-3.7.3.204 lib/new_relic/agent/threading/agent_thread.rb
newrelic_rpm-3.7.3.199 lib/new_relic/agent/threading/agent_thread.rb
newrelic_rpm-3.7.2.195 lib/new_relic/agent/threading/agent_thread.rb
newrelic_rpm-3.7.2.192 lib/new_relic/agent/threading/agent_thread.rb
newrelic_rpm-3.7.2.190.beta lib/new_relic/agent/threading/agent_thread.rb
newrelic_rpm-3.7.1.188 lib/new_relic/agent/threading/agent_thread.rb
newrelic_rpm-3.7.1.182 lib/new_relic/agent/threading/agent_thread.rb
newrelic_rpm-3.7.1.180 lib/new_relic/agent/threading/agent_thread.rb
newrelic_rpm-3.7.0.177 lib/new_relic/agent/threading/agent_thread.rb
newrelic_rpm-3.7.0.174.beta lib/new_relic/agent/threading/agent_thread.rb
newrelic_rpm-3.6.9.171 lib/new_relic/agent/threading/agent_thread.rb
newrelic_rpm-3.6.8.168 lib/new_relic/agent/threading/agent_thread.rb
newrelic_rpm-3.6.8.164 lib/new_relic/agent/threading/agent_thread.rb