Class: Skylight::Core::Normalizers::Faraday::Request Private

Inherits:
Normalizer
  • Object
show all
Defined in:
lib/skylight/core/normalizers/faraday/request.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

DISABLED_KEY =

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.

:__skylight_faraday_disabled

Instance Attribute Summary

Attributes inherited from Normalizer

#config

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Normalizer

#initialize, #normalize_after, register

Constructor Details

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

Class Method Details

.disableObject

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.


11
12
13
14
15
16
# File 'lib/skylight/core/normalizers/faraday/request.rb', line 11

def self.disable
  Thread.current[DISABLED_KEY] = true
  yield
ensure
  Thread.current[DISABLED_KEY] = false
end

Instance Method Details

#disabled?Boolean

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.

Returns:

  • (Boolean)

18
19
20
# File 'lib/skylight/core/normalizers/faraday/request.rb', line 18

def disabled?
  !!Thread.current[DISABLED_KEY]
end

#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.


22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/skylight/core/normalizers/faraday/request.rb', line 22

def normalize(_trace, _name, payload)
  uri = payload[:url]

  if disabled?
    return :skip
  end

  opts = Formatters::HTTP.build_opts(payload[:method], uri.scheme, uri.host, uri.port, uri.path, uri.query)
  description = opts[:title]

  # We use "Faraday" as the title to differentiate it in the UI in
  # case it's wrapping or is wrapped by another HTTP backend
  [opts[:category], "Faraday", description, opts[:meta]]
end