-
Notifications
You must be signed in to change notification settings - Fork 241
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
Introduce metrics #121
Introduce metrics #121
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.
Looks good! Added a few comments about TLS and metrics selection.
I also notice that you didn't add any metrics support to the jetstream driver. Is this an intentional omission?
@brandond Thanks for the comments! I have made changes accrodingly, PTAL. For the JetStream driver, I omit it because it's not a SQL backend and cannot be included in the metrics introduced in this PR. Also, I'm not quite familiar with it so maybe we shall leave its own metric implementations to some other one who really need them. |
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.
Rather than just labeling these with success/failure, I think we can extract the actual error code/number? It'll need to be done on a per-driver basis, but if you add type ErrCode func(error) string
to generic.go, and ErrCode ErrCode
to the Generic struct, you should be able to do something like this on each driver:
+ dialect.ErrCode = func(err error) string {
+ if err == nil {
+ return ""
+ }
+ if err, ok := err.(*mysql.MySQLError); ok {
+ return fmt.Sprint(err.Number)
+ }
+ return err.Error()
+ }
That's an example of mysql. postgres has err.Code, sqlite has err.ExtendedCode, and so on.
Signed-off-by: Zach Zhu <[email protected]>
@brandond Brilliant solution 👍 I have modifed the code accroding to your solution, PTAL. |
@brandond Hi, are there any blocking issue on this PR? Seems that the test can't proceed with arm64 build for some unknown reason. |
Restarted CI |
@brandond Mind merging this? We'd like to use this feature in community vendor, thanks! |
This PR introduce metrics to kine.
It'll expose below metrics:
If kine is running stand-alone, we can use the
metrics-bind-address
flag to configure the metrics http server address or disable the server.If kine is used as a library, we can set
MetricsRegisterer
ofendpoint.Config
to our own prometheus registerer to let kine register its metrics to it.fixes #119