Class: NewRelic::Agent::Instrumentation::StripeSubscriber

Inherits:
Object
  • Object
show all
Defined in:
lib/new_relic/agent/instrumentation/stripe_subscriber.rb

Constant Summary collapse

DEFAULT_DESTINATIONS =
AttributeFilter::DST_SPAN_EVENTS
EVENT_ATTRIBUTES =
%i[http_status method num_retries path request_id].freeze
ATTRIBUTE_NAMESPACE =
'stripe.user_data'
ATTRIBUTE_FILTER_TYPES =
%i[include exclude].freeze
PATH_PORTION_PATTERN =
%r{^/([^/]+/[^/]+)(?:/|\z)}.freeze

Instance Method Summary collapse

Instance Method Details

#finish_segment(event) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/new_relic/agent/instrumentation/stripe_subscriber.rb', line 24

def finish_segment(event)
  return unless is_execution_traced?

  segment = remove_and_return_nr_segment(event)
  add_stripe_attributes(segment, event)
  add_custom_attributes(segment, event)
rescue => e
  NewRelic::Agent.logger.error("Error finishing New Relic Stripe segment: #{e}")
ensure
  segment&.finish
end

#start_segment(event) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/new_relic/agent/instrumentation/stripe_subscriber.rb', line 15

def start_segment(event)
  return unless is_execution_traced?

  segment = NewRelic::Agent::Tracer.start_segment(name: metric_name(event))
  event.user_data[:newrelic_segment] = segment
rescue => e
  NewRelic::Agent.logger.error("Error starting New Relic Stripe segment: #{e}")
end