opentelemetry-go-contrib
opentelemetry-go-contrib copied to clipboard
Add request count metric with status code label
Signed-off-by: m.nabokikh [email protected]
Closes https://github.com/open-telemetry/opentelemetry-go-contrib/issues/711
This PR adds a counter for the total amount of requests with the http_status_code label. It will help us to be aware of the ratio of errors.
I decided to avoid adding status code to other metrics because it looks excessive. Instead, counting the number of requests seems more sensible.
P.S.: I accidentally closed the previous PR https://github.com/open-telemetry/opentelemetry-go-contrib/pull/771
@Aneurysm9 fyi
Codecov Report
Merging #2138 (4501944) into main (e915b7c) will increase coverage by
0.0%
. The diff coverage is100.0%
.
Additional details and impacted files
@@ Coverage Diff @@
## main #2138 +/- ##
=====================================
Coverage 69.9% 69.9%
=====================================
Files 147 147
Lines 6934 6936 +2
=====================================
+ Hits 4851 4853 +2
Misses 1959 1959
Partials 124 124
Impacted Files | Coverage Δ | |
---|---|---|
instrumentation/net/http/otelhttp/handler.go | 82.8% <100.0%> (+0.1%) |
:arrow_up: |
The spec recommends that the status code be added to the duration metrics, which can provide a count when aggregated as a histogram. Should we do that and rely on the user to configure a view to do dimension reduction if histograms with status codes is a cardinality concern?
From my point of view, it would be better to avoid using updown counter for errors, because you cannot apply rate functions to it.
Adding status code label for histograms sounds ok to me. It is a common practice. Should we go this way then?
@MrAlias @Aneurysm9, just a friendly reminder. Is it ok to add the status code label to the server latency metric?
@MrAlias @Aneurysm9, just a friendly reminder. Is it ok to add the status code label to the server latency metric?
I'm good with that approach.
I've just added the status code label, so everything should be good now.
Folks, any updates on this one? It would be best if we resolve all concerns about this PR before the next release 🙏
I rebased this branch on the main. Just a friendly reminder, still waiting for the feedback 😸
Any update on this PR?
Already implemented: https://github.com/open-telemetry/opentelemetry-go-contrib/blob/c52452d90ab05a5a92f54398c0093376883cca2a/instrumentation/net/http/otelhttp/handler.go#L246
Already implemented:
Your link is setting attributes for the spans, not metrics.
@dmathieu hello there! A test is not included for this PR. Do you want me to add one, or should I wait for the initial review?
I believe adding a test would make the review easier.
@dmathieu I checked this out, and it seems like the issue is fixed by the following code https://github.com/open-telemetry/opentelemetry-go-contrib/blob/c52452d90ab05a5a92f54398c0093376883cca2a/instrumentation/net/http/otelhttp/handler.go#L219-L221
All thanks to @MrAlias. Now everything works as expected. Thanks to everyone. It was a two years journey that came to an end (I'm going to close the PR).