Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: configure sending an X-Request-Id header for use by twilio engineers in debugging requests #523

Closed
bf4 opened this issue Jul 21, 2020 · 4 comments
Labels
status: waiting for feedback waiting for feedback from the submitter type: question question directed at the library

Comments

@bf4
Copy link

bf4 commented Jul 21, 2020

Issue Summary

A twilio engineer in a support ticket has asked me to add an X-Request-Id header to requests we make, and though adding custom headers is supported in the library in general (since #516 ), there's no public interface for me to add this in twilio_client.messages.create(payload).

Short of generally exposing a custom headers interface, it seems that opting in to including a request-id might be a desirable feature.

I don't see an small surgical way to add the header on message creation, e.g. https://github.com/twilio/twilio-ruby/blob/5.39.1/lib/twilio-ruby/rest/api/v2010/account/message.rb

per #214 (comment) something like this was added a while ago, but I see no evidence of it beyond the comment.

I'd be willing to write it.

Steps to Reproduce

  1. get a net open timeout
  2. contact support
  3. support says add this header
  4. ?

Code Snippet

twilio_client.messages.create(payload)

Exception/Log

n/a

Technical details:

  • twilio-ruby version: 5.39.1
  • ruby version: 2.6.2
@bf4 bf4 changed the title RFC: configure sending an X-Request-Id header for by twilio engineers in debugging requests RFC: configure sending an X-Request-Id header for use by twilio engineers in debugging requests Jul 21, 2020
@bf4
Copy link
Author

bf4 commented Jul 22, 2020

In the meantime, I made this patch in our app

require 'twilio-ruby/http/http_client'

module TwilioHttpClientPatch
  # https://github.com/rails/rails/blob/6-0-stable/actionpack/lib/action_dispatch/middleware/request_id.rb
  X_REQUEST_ID = "X-Request-Id" #:nodoc:

  def request(host, port, method, url, params = {}, data = {}, headers = {}, auth = nil, timeout = nil)
    headers ||= {}
    headers[X_REQUEST_ID] ||= SecureRandom.uuid
    super
  end
end
Twilio::HTTP::Client.prepend(TwilioHttpClientPatch)

@eshanholtz
Copy link
Contributor

Hi @bf4

I would recommend using passing a custom HTTP client and adding your custom headers there for this use case. The custom headers referred to in #516 are the ones defined by the downstream API and auto-generated into the helper libraries.

@eshanholtz eshanholtz added status: waiting for feedback waiting for feedback from the submitter type: question question directed at the library labels Jul 24, 2020
@bf4
Copy link
Author

bf4 commented Jul 25, 2020

@eshanholtz my patch is working now so I think I'll just keep using it until either Twilio support says the header doesn't help or it gets first class support from Twilio

@eshanholtz
Copy link
Contributor

@bf4 Sounds good. I'm going to close this ticket. You can reopen if you require further library help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting for feedback waiting for feedback from the submitter type: question question directed at the library
Projects
None yet
Development

No branches or pull requests

2 participants