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 a gRPC interceptor for function metrics #5006
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
if err != nil { | ||
return errors.Wrap(err, "cannot load client TLS certificates") | ||
} | ||
|
||
m := xfn.NewMetrics() | ||
metrics.Registry.MustRegister(m) |
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.
metrics registration should go to an init func. Otherwise, you will never be able to create multiple instances of this (e.g. for testing) without a panic.
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 don't think it's that cut-and-dry, and would generally prefer to setup things like metrics, loggers etc here in "main" 1 and plumb them down rather than relying on init functions hidden away in individual packages.
Footnotes
-
This isn't literally
func main
but it's close enough in practice. I can't see us unit testing this plumbing. ↩
This adds some basic metrics for functions: * RPCs started (count) * RPCs handled (count) * RPC compleition time (histogram) While we probably want metrics like this, I don't think this premade interceptor will work for us. It's close, but we probably want function name/target as a label and this doesn't seem to give us that. Signed-off-by: Nic Cope <nicc@rk0n.org>
This allows us to add useful, function-specific metric labels including what function is being called and the severity of the result. Signed-off-by: Nic Cope <nicc@rk0n.org>
This is useful to be able to look at metrics after an E2E run. Signed-off-by: Nic Cope <nicc@rk0n.org>
Signed-off-by: Nic Cope <nicc@rk0n.org>
Signed-off-by: Nic Cope <nicc@rk0n.org>
62c7f5e
to
4c9ebcc
Compare
Description of your changes
Fixes #5001
This adds some basic RED metrics for functions:
All metrics are labelled by function name, package, and gRPC target. Responses are also labelled with gRPC status code and "severity". The gRPC status code represents whether the function successfully returned a response. The severity indicates whether the response was successful. We consider the severity of the response to be the severity of the most severe result in the response. So a response that returns a fatal result has a severity of fatal. This will allow folks to monitor how often a function is successfully returning a response, but a fatal response.
Example metrics from an E2E test run:
I have:
make reviewable
to ensure this PR is ready for review.Added or updated unit tests.Added or updated e2e tests.Linked a PR or a docs tracking issue to document this change.Addedbackport release-x.y
labels to auto-backport this PR.Need help with this checklist? See the cheat sheet.