-
Notifications
You must be signed in to change notification settings - Fork 432
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
Add Stripe client telemetry to request headers #518
Conversation
cc @stripe/api-libraries for awareness |
Pinging @akropp-stripe @ob-stripe @brandur-stripe for review as you were all part of stripe/stripe-ruby#696. The 2 failing tests are also failing on master and are unrelated to my changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comment below, but generally LGTM! Thanks for following the same conventions set by the Ruby version.
OB's informally the main Python maintainer, so I'll leave final review to him.
@@ -12,6 +12,7 @@ | |||
from stripe.multipart_data_generator import MultipartDataGenerator | |||
from stripe.six.moves.urllib.parse import urlencode, urlsplit, urlunsplit | |||
from stripe.stripe_response import StripeResponse | |||
from stripe.request_metrics import RequestMetrics |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you try to arrange this as alphabetically as possible (since it's already roughly in that order)? Just swap it with the line above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
@@ -0,0 +1,10 @@ | |||
class RequestMetrics(object): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor note, but the one in Ruby is called StripeRequestMetrics
, and it'd be nice to standardize on a name. RequestMetrics
is probably better given it's already in the Stripe namespace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine either way, I just figured from stripe.stripe_request_metrics import StripeRequestMetrics
was overly verbose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the Stripe
prefix seems pretty redundant. Let's stick with what you have.
@ob-stripe I looked into the test failures that are happening on class TestPycurlClientHttpProxy(TestPycurlClient):
...
@pytest.fixture
def check_call(self, request_mocks, curl_mock):
def check_call(mock, meth, url, post_data, headers):
...
super(TestPycurlClientHttpProxy, self).check_call(request_mocks)(
mock, meth, url, post_data, headers) Because all our I could fix this by just moving |
@jameshageman-stripe Can you rebase on the latest master? I fixed the unrelated test error. @brandur-stripe Oops, sorry, I'm only seeing your comment now! FWIW I initially went with your suggestion, but changed my mind to make the new method slightly more consistent with what we already do in |
NP. Your fix ended up being better than what I was imagining. |
c9d9702
to
6caa1fc
Compare
@ob-stripe Rebased: all tests are passing except |
r? @ob-stripe |
@@ -0,0 +1,10 @@ | |||
class RequestMetrics(object): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add from __future__ import absolute_import, division, print_function
at the beginning of the file? Even though that line won't do anything here, it's present in all source files to prevent Python 2/3 compatibility issues.
Requested one minor change, but otherwise LGTM!
Yes, this is an issue with |
@ob-stripe Done! |
@jameshageman-stripe Thanks! Mind squashing the commits before I merge and cut a release? |
65ad482
to
3e01e7e
Compare
@ob-stripe squashed |
Released as 2.18.0. |
Follows stripe/stripe-ruby#696 and stripe/stripe-php#549 in adding telemetry metadata to request headers.
The telemetry is disabled by default, and can be enabled like so: