-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
internal/stats: Add metrics recorder list and usage in ClientConn #7428
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #7428 +/- ##
==========================================
- Coverage 81.52% 81.32% -0.20%
==========================================
Files 350 354 +4
Lines 26879 27053 +174
==========================================
+ Hits 21913 22002 +89
- Misses 3772 3839 +67
- Partials 1194 1212 +18
|
01f6995
to
c777496
Compare
c777496
to
dc37567
Compare
997f9a0
to
6c69fc7
Compare
Thanks for the pass; got to all comments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall, just some minor things..
logger.Infof("length of labels passed to RecordInt64Count incorrect got: %v, want: %v", got, want) | ||
func verifyLabels(labels []string, optionalLabels []string, labelsRecv ...string) { | ||
if got, want := len(labelsRecv), len(labels)+len(optionalLabels); got != want { | ||
logger.Fatalf("Length of labels passed to Record incorrect, got: %v, want: %v.", got, want) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO delete the logger now and call panic(fmt.Sprintf)
here.
Also if we pass the descriptor let's print the metric name with %q
as well. Maybe lose the got, want
formatting which I believe is unique to Go test assertions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got rid of got, want. Recorded the metric name with %q from desc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I didn't mean to remove the counts.. Just to turn it into a more english-y thing than a Go test error message. E.g.
Like Received %d labels in call to record metric %q, but expected %d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok noted switched to that.
52373fa
to
8183987
Compare
8183987
to
e410855
Compare
} | ||
} | ||
|
||
func (l *MetricsRecorderList) RecordInt64Count(handle *estats.Int64CountHandle, incr int64, labels ...string) { | ||
verifyLabels(handle.Labels, handle.OptionalLabels, labels...) | ||
verifyLabels((*estats.MetricDescriptor)(handle), labels...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh..I was thinking we wouldn't need to do the cast here for some reason... I wonder if it's worth adding a method to the handles like:
func (h handle) Descriptor() *estats.MetricDescriptor {
return (*estats.MetricDescriptor)(h)
}
...in order to keep the ugliness out of the places we do the cast.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, these are also cast like this in OTel, we could add but then that populates exported namespace. Although if a user does use the metrics registry and writes their own stats handlers, they will need to key on a property of the descriptor, and perhaps they will use the pointer as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll keep it as a separate commit and you can see how it looks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sent out a separate commit: 619b20e, let me know what you think.
logger.Infof("length of labels passed to RecordInt64Count incorrect got: %v, want: %v", got, want) | ||
func verifyLabels(labels []string, optionalLabels []string, labelsRecv ...string) { | ||
if got, want := len(labelsRecv), len(labels)+len(optionalLabels); got != want { | ||
logger.Fatalf("Length of labels passed to Record incorrect, got: %v, want: %v.", got, want) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I didn't mean to remove the counts.. Just to turn it into a more english-y thing than a Go test error message. E.g.
Like Received %d labels in call to record metric %q, but expected %d
@@ -223,7 +223,7 @@ func (s) TestMetricRecorderListPanic(t *testing.T) { | |||
}) | |||
mrl := istats.NewMetricsRecorderList(nil) | |||
|
|||
want := "Length of labels passed to Record incorrect, got: 1, want: 2." | |||
want := `Length of labels passed to Record incorrect for metric "simple counter".` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not super important to check the string, especially in its entirety, if you don't want to keep adjusting this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left it I like it.
This PR adds a metrics recorder list component as a top level component of the ClientConn. It also forwards this to balancer by scaling up balancer.BuildOptions.
The Server Side equivalent will come when needed to pass down to xDS Client, but no need for now.
RELEASE NOTES: N/A