Skip to content
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 collector for database/sql#DBStats #848

Closed
wants to merge 1 commit into from

Conversation

johejo
Copy link
Contributor

@johejo johejo commented Mar 19, 2021

MaxIdleTimeClosed is not available below go1.15.
Therefore it is TODO.

Signed-off-by: Mitsuo Heijo [email protected]

@beorn7
Copy link
Member

beorn7 commented Mar 21, 2021

Thanks. This is a neat idea. I'm just not sure if it should live in the Go instrumentation client or if it should rather be a separate tool. Another question is if the metrics should be prefixed with go_.... While the database/sql package is Go-specific, those metrics aren't really coming from the Go runtime.

I would like to discuss that with the Prometheus community first. This kind of discussions happens on the prometheus-developers mailing list. @johejo would you like to start a thread there? Otherwise, I can do it.

@johejo
Copy link
Contributor Author

johejo commented Mar 22, 2021

Thank you.
I posted a new conversation.
https://groups.google.com/g/prometheus-developers/c/Zexpd_oRYRQ

@beorn7
Copy link
Member

beorn7 commented Apr 13, 2021

To put the conclusion from the mailing list thread here:

In general, it's fine to have this kind of collector here in prometheus/client_golang. Nobody voiced their opinion if we should have a separate collectors package. We already have four similar collectors directly in the prometheus package, and we cannot move them out without a breaking change. But at some point, we have to draw a line, so I'd say let's put it into a new collectors package, and move other collectors (like NewBuildInfoCollector) over in the next major release. (We could already now replicate the existing collectors and deprecate them.)

However, this PR is already the third implementation after https://github.com/dlmiddlecote/sqlstats and https://github.com/krpn/go-sql-db-stats . At first glance, the latter seems more elaborate, but it's still not following all best practices (e.g. counters don't end on _total). Same is true for this PR.

Next step would be to take the best of all three implementations and unite them here (could be in this PR or a new one) and also make sure naming conventions are honored (e.g. counter names end on _total, unit in the metric name where applicable, etc. see https://prometheus.io/docs/practices/naming/ ).

MaxIdleTimeClosed is not available below go1.15.
Therefore it is TODO.

Signed-off-by: Mitsuo Heijo <[email protected]>
@johejo
Copy link
Contributor Author

johejo commented Apr 16, 2021

Fixed label naming.

@beorn7
Copy link
Member

beorn7 commented Apr 22, 2021

Hi @johejo , are you still working on this? If you feel it's ready for a detailed review, please let me know. (At first glance, I saw that you haven't moved the code into a new collectors package as discussed above.)

@johejo
Copy link
Contributor Author

johejo commented Apr 22, 2021

It's okay.
I will work this weekend.
Thanks.
@beorn7

@johejo
Copy link
Contributor Author

johejo commented Apr 24, 2021

I thought it would be better to have a separate PR for the dbstats collector and the new package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants