Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Instrument the Atlas HTTP Client RoundTripper #16

Open
Freyert opened this issue Nov 1, 2021 · 0 comments
Open

Instrument the Atlas HTTP Client RoundTripper #16

Freyert opened this issue Nov 1, 2021 · 0 comments
Labels
help wanted Extra attention is needed

Comments

@Freyert
Copy link
Contributor

Freyert commented Nov 1, 2021

I've added a special Error type HTTPError in #14. This was outside the scope of the PR and therefore I didn't not focus on doing this correctly. Sometimes doing things the inefficiently helps us learn to do things more efficiently.

Instead of handling/counting each error code whenever they occur in the code it is much better practice to wrap the RoundTripper for an HTTPClient. This wrapping acts as a sort of middleware from which we can instrument all HTTP calls at a single point.

Specifically we need to wrap the round tripper with InstrumentRoundTripperCounter. It will partition the CounterVec by method and code. This is exactly what we want.

The prometheus team has provided an example in their tests:
https://github.com/prometheus/client_golang/blob/0400fc44d42dd0bca7fb16e87ea0313bb2eb8c53/prometheus/promhttp/instrument_client_test.go#L204-L210

@Freyert Freyert added the help wanted Extra attention is needed label Nov 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant