On one of our app hosted on Heroku we do a backend call (in Ruby) to generate access token:
require "uri"
require "net/http"
parameters = {
code: params[:code],
client_id: "my_client_id",
client_secret: "my_client_secret",
redirect_uri: "http://#{YAML.load_file("config/domains.yml")[Rails.env]['domain']}/oauth2callback",
grant_type: "authorization_code"
}
response = Net::HTTP.post_form(URI.parse('https://accounts.google.com/o/oauth2/token'), parameters)
But each time Newrelic reports a response time always (90%) above 800 ms (and up to 3sec).
You can see that in Newrelic report graph
On the other hand, refreshing the access_token is consistently below 250ms.
Is there something wrong in the code, on Google side or should I blame heroku DNS?