experimental/stats: Add up down counter for A94#8581
Conversation
20f43a0 to
e4d9b0e
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #8581 +/- ##
==========================================
+ Coverage 81.64% 81.92% +0.27%
==========================================
Files 413 415 +2
Lines 40621 40744 +123
==========================================
+ Hits 33167 33381 +214
- Misses 5991 6003 +12
+ Partials 1463 1360 -103
🚀 New features to boost your workflow:
|
|
Please follow the instructions mentioned here and update the PR description: https://github.com/grpc/grpc-go/blob/master/CONTRIBUTING.md#pr-descriptions Specifically the following: |
easwars
left a comment
There was a problem hiding this comment.
LGTM
I'm completely new to the otel codebase in grpc-go though. So, hopefully a second reviewer knows more :)
| recorder.RecordInt64Count(h, incr, labels...) | ||
| } | ||
|
|
||
| // Int64UpDownCountHandle is a typed handle for an int up-down counter metric. |
There was a problem hiding this comment.
I understand this docstring is very similar to the existing one for Int64CountHandle. But I'm curious as to what the "typed handle" means here.
There was a problem hiding this comment.
It's a newtype for MetricDescriptor - all different metric types have the same Descriptor information, but we give them all their own types so that they can be used correctly. (I.e. they have proper method signatures on Record.) The Register function returns a Handle, which is just a pointer, that it uses to access the metric's info in the Recorder. E.g. on line 111, the Record call passes the Handle to the recorder, which the recorder uses to look up the metric in a map.
| } | ||
| ret, err := meter.Int64UpDownCounter(string(metricName), options...) | ||
| if err != nil { | ||
| logger.Errorf("failed to register metric \"%v\", will not record: %v", metricName, err) |
There was a problem hiding this comment.
Nit: Log statements should follow capitalization rules for regular sentences, and not the ones that apply to error strings. See: go/go-style/decisions#error-strings
| recorder.RecordInt64Count(h, incr, labels...) | ||
| } | ||
|
|
||
| // Int64UpDownCountHandle is a typed handle for an int up-down counter metric. |
There was a problem hiding this comment.
It's a newtype for MetricDescriptor - all different metric types have the same Descriptor information, but we give them all their own types so that they can be used correctly. (I.e. they have proper method signatures on Record.) The Register function returns a Handle, which is just a pointer, that it uses to access the metric's info in the Recorder. E.g. on line 111, the Record call passes the Handle to the recorder, which the recorder uses to look up the metric in a map.
| @@ -93,6 +94,23 @@ func (h *Int64CountHandle) Record(recorder MetricsRecorder, incr int64, labels . | |||
| recorder.RecordInt64Count(h, incr, labels...) | |||
There was a problem hiding this comment.
What happens if incr is negative here?
| } | ||
| ret, err := meter.Int64UpDownCounter(string(metricName), options...) | ||
| if err != nil { | ||
| logger.Errorf("failed to register metric \"%v\", will not record: %v", metricName, err) |
Part 1 for A94
Adds up down counter boiler plate code
RELEASE NOTES: