Skip to content

Instantly share code, notes, and snippets.

@devotdev
Created May 15, 2026 13:09
Show Gist options
  • Select an option

  • Save devotdev/9ffe67f65775d78c28eb673b8b8c31d3 to your computer and use it in GitHub Desktop.

Select an option

Save devotdev/9ffe67f65775d78c28eb673b8b8c31d3 to your computer and use it in GitHub Desktop.
app/services/partner_api/application.rb - execute_request!
def execute_request!(method, path, body: {}, query: {})
start_time = Time.current
request_id = SecureRandom.hex(8)
Rails.logger.info("[PartnerApi][#{request_id}][REQUEST] #{method.upcase} #{path}")
response = self.class.public_send(
method,
"#{base_url}#{path}",
headers: default_headers,
body: body.to_json,
query: query,
timeout: @timeout || REQUEST_TIMEOUT,
open_timeout: OPEN_TIMEOUT
)
duration_ms = ((Time.current - start_time) * 1000).round(2)
Rails.logger.info(
"[PartnerApi][#{request_id}][RESPONSE] #{method.upcase} #{path} " \
"status=#{response.code} duration=#{duration_ms}ms"
)
if duration_ms > 5_000
Slack::Post.perform_later("Slow PartnerApi call: #{method.upcase} #{path} took #{duration_ms}ms")
end
response
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment