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

feat(remote.Client): Add current context to Fetch and FetchV2 #29

Merged
merged 4 commits into from
Aug 22, 2024

Conversation

hbiarge
Copy link
Contributor

@hbiarge hbiarge commented Aug 9, 2024

Summary

Add a field in the Config type to provide the internal http.Client the remote.Client is going to use.

No breaking changes. Same default behaviour as before.

Allow instrumenting remote http calls providing a wrapped http.Client.

Pass the current Context to Fetch and FetchV2 to enable distributed tracing.

Fixes #28

Checklist

  • [ x] Does your PR title have the correct title format?
  • Does your PR have a breaking change?: No
  • Does your PR have a breaking change?: Yes

@hbiarge
Copy link
Contributor Author

hbiarge commented Aug 9, 2024

Well, I'm not an expert in Go, but, after investigating a little bit my problem, I can instrument the underlying RoundTripper used by the http.Client.
So the issue is now that we need the current context when we call Fetch and FetchV2 to be able to retrieve the current parent span from the current context and let the distributed tracing system to make it's magic.

@hbiarge hbiarge changed the title feat(remote.Client): Allow providing an externally created http client feat(remote.Client): Add current context to Fetch and FetchV2 Aug 9, 2024
@bgiori
Copy link
Collaborator

bgiori commented Aug 12, 2024

Hey @hbiarge thanks so much for submitting this PR. Unfortunately I don't want to break the existing API on the client for Fetch and FetchV2, but your approach is correct.

Can you add FetchV2WithContext instead of update the existing function? Then FetchV2 can just call FetchV2WithContext.

@hbiarge
Copy link
Contributor Author

hbiarge commented Aug 13, 2024

Sure, it makes totally sense.
I'm on holiday this week, but I will update the PR when I find some time.
Thank you so much!

@hbiarge
Copy link
Contributor Author

hbiarge commented Aug 16, 2024

Ready for review @bgiori...

pkg/experiment/remote/client.go Outdated Show resolved Hide resolved
@bgiori bgiori merged commit 2113bed into amplitude:main Aug 22, 2024
github-actions bot pushed a commit that referenced this pull request Aug 26, 2024
# [1.6.0](v1.5.0...v1.6.0) (2024-08-26)

### Features

* **remote.Client:** Add current context to Fetch and FetchV2 ([#29](#29)) ([2113bed](2113bed))
Copy link

🎉 This issue has been resolved in version 1.6.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow remote internal http.Client to be configured.
2 participants