-
Notifications
You must be signed in to change notification settings - Fork 13
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
add new highcardmetrics pkg to grpcmetrics #171
Conversation
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.
Yup, this is exactly what I was thinking.
|
||
service, method := parseFullMethod(info.FullMethod) | ||
|
||
labels := []string{"service", service, "method", method} |
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.
Will this service
conflict (or be confused) with the existing service*
columns?
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.
very true. how do you feel about grpc.service
and grpc.method
? Or any other suggestions welcome!
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 like you can read my mind, I love those choices!
In fact, I was wondering about changing ours in the httpmetrics middleware to use http.method
, http.path
, http.response-status
.
func ms(d time.Duration) float64 { | ||
return float64(d) / float64(time.Millisecond) | ||
} |
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.
There is a much easier way to do this now https://pkg.go.dev/time#Duration.Milliseconds
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.
good catch! just a copy/paste from the other code.
|
||
defer func(begin time.Time) { | ||
service, method := parseFullMethod(info.FullMethod) | ||
labels := []string{"service", service, "method", method, "response-status", code(err)} |
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.
These labels will need to get tweaked 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.
Looks great!
Context
We want to add two new options to the grpc server, which allows us to collect metrics using attributes.
The new
highcardmetrics
pkg provides high cardinality unary and stream server interceptors. The interceptors take anexplicit
bool arg, which makes the histogram type configurable. Passing intrue
will create explicit histograms with a default 5s distribution.Usage
To initialize a grpc server with high cardinality unary and stream servers using explicit histograms: