class Skylight::Core::Normalizers::Coach::HandlerFinish

Constants

CAT

Public Instance Methods

normalize(trace, _name, payload) click to toggle source

Run when the handler first starts, we need to set the trace endpoint to be the handler name.

We can expect the payload to have the :middleware key.

# File lib/skylight/core/normalizers/coach/handler_finish.rb, line 26
def normalize(trace, _name, payload)
  trace.endpoint = payload[:middleware]
  [CAT, payload[:middleware], nil]
end
normalize_after(trace, _span, _name, payload) click to toggle source
# File lib/skylight/core/normalizers/coach/handler_finish.rb, line 31
def normalize_after(trace, _span, _name, payload)
  return unless config.enable_segments?

  segments = []

  response_status = payload.fetch(:response, {}).fetch(:status, "").to_s
  segments << "error" if response_status.start_with?("4", "5")

  if segments.any?
    trace.segment = segments.join("+")
  end
end