Class: Skylight::Core::Normalizers::Coach::HandlerFinish Private

Inherits:
Normalizer
  • Object
show all
Defined in:
lib/skylight/core/normalizers/coach/handler_finish.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Constant Summary collapse

CAT =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

"app.coach.handler".freeze

Instance Attribute Summary

Attributes inherited from Normalizer

#config

Instance Method Summary collapse

Methods inherited from Normalizer

#initialize, register

Constructor Details

This class inherits a constructor from Skylight::Core::Normalizers::Normalizer

Instance Method Details

#normalize(trace, name, payload) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

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.



16
17
18
19
# File 'lib/skylight/core/normalizers/coach/handler_finish.rb', line 16

def normalize(trace, name, payload)
  trace.endpoint = payload[:middleware]
  [ CAT, payload[:middleware], nil ]
end

#normalize_after(trace, span, name, payload) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/skylight/core/normalizers/coach/handler_finish.rb', line 21

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.endpoint += "<sk-segment>#{segments.join("+")}</sk-segment>"
  end
end