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

Track usage of raw_request #1779

Merged
merged 15 commits into from
Dec 13, 2023
Merged

Track usage of raw_request #1779

merged 15 commits into from
Dec 13, 2023

Conversation

richardm-stripe
Copy link
Contributor

@richardm-stripe richardm-stripe commented Dec 7, 2023

Summary

  • Adds infrastructure for reporting usage to X-Stripe-Client-Telemetry, without breaking changes to the public interface.
  • Reports usage for raw_request in the beta branch.

Details

Release

The first commit Usage infrastructure I intend to merge into master in a follow-up, after discussion.

The second commit Usage for raw_reuest is only applicable to the beta branch. I've opened the PR against beta showing both for a more holistic review.

Implementation

The tricky part about all this is: we have a struct BackendImplementation with public Do and Call methods (Call invokes Do). Only the Do method has access to Params which is where we want to put usage, but only the Call method has access to duration, which also needs to go on the telemetry header. The ideal solution would involve changing the signature of Do so that it can shuffle the information back to Call in the return value, but that's breaking. To avoid a breaking change, what we instead have to do is pass this information through the LastResponseSetter.

BackendImplementation although "public" is marked as internal and we say that public use is deprecated since 2018. Things would be much simpler if we broke it.

It also turns out, there's not much code sharing in the RawRequest implementation right now, it doesn't go through backend.Call, for instance.

@richardm-stripe richardm-stripe requested review from a team and pakrym-stripe and removed request for a team December 7, 2023 00:24
params.go Outdated Show resolved Hide resolved
stripe_test.go Outdated Show resolved Hide resolved
stripe.go Outdated Show resolved Hide resolved
@pakrym-stripe
Copy link
Contributor

Should we target master first and then merge the infrastructure change into beta?

stripe.go Outdated Show resolved Hide resolved
@richardm-stripe
Copy link
Contributor Author

richardm-stripe commented Dec 7, 2023

Should we target master first and then merge the infrastructure change into beta?

Yes. That's available now in #1780.

@richardm-stripe richardm-stripe merged commit 44d2af9 into beta Dec 13, 2023
7 checks passed
@richardm-stripe richardm-stripe deleted the richardm-usage branch December 13, 2023 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants