Sha256: 8fa3668ed8b6282be605442778ed8b1ce5699ba454001e93fda6653ac58486cb

Contents?: true

Size: 746 Bytes

Versions: 4

Compression:

Stored size: 746 Bytes

Contents

require 'active_support/notifications'

ActiveSupport::Notifications.subscribe(/\.faraday$/) do |event, started, finished, _, payload|

  render_http_header = ->(headers) {
    (headers || []).map do |key,value|
      if %{ PRIVATE-TOKEN Authorization }.include?(key)
        value = value.gsub(/./, "*")
      end
      "#{key}: #{value}"
    end.join("\n")
  }

  payload = {
    method:           payload[:method],
    url:              payload[:url].to_s,
    status:           payload[:status],
    response_headers: render_http_header.call(payload[:response_headers]),
    request_headers:  render_http_header.call(payload[:request_headers])
  }

  Vx::Lib::Instrumentation.delivery event, payload, event.split("."), started, finished
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
vx-lib-instrumentation-0.1.12 lib/vx/lib/instrumentation/probe/faraday.rb
vx-lib-instrumentation-0.1.11 lib/vx/lib/instrumentation/probe/faraday.rb
vx-lib-instrumentation-0.1.10 lib/vx/lib/instrumentation/probe/faraday.rb
vx-lib-instrumentation-0.1.9 lib/vx/lib/instrumentation/probe/faraday.rb