Module: TingYun::Agent::Collector::ErrorCollector::Tag

Included in:
TingYun::Agent::Collector::ErrorCollector
Defined in:
lib/ting_yun/agent/collector/error_collector.rb

Overview

tag the exception,avoid the same exception record multiple times in the middlwars and other point

Constant Summary collapse

EXCEPTION_TAG_IVAR =
:'@__ty_seen_exception'

Instance Method Summary collapse

Instance Method Details

#exception_tagged?(exception) ⇒ Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/ting_yun/agent/collector/error_collector.rb', line 41

def exception_tagged?(exception)
  exception.instance_variable_defined?(EXCEPTION_TAG_IVAR)
end

#tag_exception(exception) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/ting_yun/agent/collector/error_collector.rb', line 33

def tag_exception(exception)
  begin
    exception.instance_variable_set(EXCEPTION_TAG_IVAR, true)
  rescue => e
    TingYun::Agent.logger.warn("Failed to tag exception: #{exception}: ", e)
  end
end