getlantern / browsersunbounded

Interoperable browser-based P2P proxies for censorship circumvention
GNU General Public License v3.0
14 stars 0 forks source link

Switch metrics up to be able to print concurrent request count via /healthz #213

Closed Crosse closed 9 months ago

Crosse commented 9 months ago

In order to troubleshoot some observability issues we're seeing with the current request metrics, this switches to using atomic.Int64 values to track the current number of GET and POST requests in-flight. We can use these values with an Int64ObservableUpDownCounter to send to our o11y platform, but we can also print them out via the /healthz endpoint and use that for troubleshooting whether the value we see in our dashboards is the same value that the application is actually tracking.

This also consolidates the metrics from four (concurrent GETs, POSTs, and total GETs, POSTs) down to two by setting the HTTP method as a tag on the metric instead of encoding it in the name. I think this is probably more idiomatic.

(I don't need this merged to be able to use the branch for our testing purposes, which is why it's marked as a draft PR.)

Crosse commented 9 months ago

This change seems to be working. I guess I need to go read up on when to use each type of counter, and when to use the synchronous vs asynchronous versions...

If it's okay by you, @noahlevenson, I'll merge this one on Monday along with my other PR and update l-c's go.mod to pull in this change (which will be a no-op, but :shrug:).

noahlevenson commented 9 months ago

@Crosse Most definitely OK by me!