class FastlyNsq::NewRelic
FastlyNsq::NewRelic
supports tracing methods with NewRelic
if the newrelic_rpm
is enabled
Constants
- CATEGORY
Attributes
agent[R]
Public Class Methods
new(agent = nil)
click to toggle source
Create a FastlyNsq::NewRelic
instance @param agent [#notice_error] optional and should only be used if you need to override the default NewRelic::Agent
@example
tracer = FastlyNsq::NewRelic.new tracer.notice_error(exception)
# File lib/fastly_nsq/new_relic.rb, line 24 def initialize(agent = nil) @agent = agent || (Object.const_defined?('NewRelic') ? NewRelic::Agent : nil) end
Public Instance Methods
enabled?()
click to toggle source
Returns true if NewRelic
is loaded and available. @return [Boolean]
# File lib/fastly_nsq/new_relic.rb, line 31 def enabled? @enabled ||= Object.const_defined?('NewRelic') end
notice_error(exception)
click to toggle source
Notify NewRelic
of an exception only if `enabled? == true` and an agent
is defined @param exception [Exception]
# File lib/fastly_nsq/new_relic.rb, line 39 def notice_error(exception) return unless enabled? && agent agent.notice_error(exception) end
trace_with_newrelic(**args) { || ... }
click to toggle source
Trace passed block with new relic if `enabled? == true` @param trace_args
[Hash] tracing parameters passed to NewRelic
# File lib/fastly_nsq/new_relic.rb, line 50 def trace_with_newrelic(**args) if enabled? perform_action_with_newrelic_trace(trace_args(args)) do yield end else yield end end
Private Instance Methods
trace_args(**args)
click to toggle source
# File lib/fastly_nsq/new_relic.rb, line 62 def trace_args(**args) { name: 'call', category: CATEGORY, }.merge(args) end