Class: JSONAPI::Support::ProsopiteInstrumentationLogger

Inherits:
Object
  • Object
show all
Defined in:
lib/json_api/support/prosopite_instrumentation_logger.rb

Instance Method Summary collapse

Instance Method Details

#warn(progname = nil) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/json_api/support/prosopite_instrumentation_logger.rb', line 6

def warn(progname = nil, &)
  n1_details = block_given? ? yield : progname.to_s
  return if n1_details.nil? || n1_details.empty?

  env = Thread.current[:jpie_request_env]
  payload = build_payload(env, n1_details)

  return unless defined?(Rails) && Rails.respond_to?(:event)

  Rails.event.tagged("jsonapi", "n1") do
    Rails.event.notify("jpie.n1_detected", payload)
  end
end