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

Query duration metrics with user specified label #103

Open
thilak009 opened this issue Apr 23, 2024 · 1 comment
Open

Query duration metrics with user specified label #103

thilak009 opened this issue Apr 23, 2024 · 1 comment
Assignees

Comments

@thilak009
Copy link

Describe the feature

A metric likegorm_query_duration_seconds_bucket which takes a label say query_name, now we can have a chain method on each query and specify this label
This metric collects the time taken for a query execution.

Motivation

I was looking at enabling prometheus metrics for my postgres DB, and wanted to capture how long each of my queries are taking to execute.
I can currently see that in postgres gorm logs print how long a query took to run, so i am guessing we have this information and that this can be emitted as a prometheus metric with user specified label.
So instead of measuring the duration myself and emitting prometheus metrics in the application, i thought gorm can do that easily by adding a chain method for this.

I don't have much idea about the architecture of code and so not sure if this would be simple change or something that does not fit well with the structure, but wanted to see if this is something that would be a good addition

Related Issues

NA

@batman-gotham99
Copy link

batman-gotham99 commented Sep 14, 2024

Make sense, as I believe all the query calls Execute method at the end for finisher methods, also the spent duration is already tracked and part of GORM logger, however wondering how GORM can maintain the cardinality in the metrics 🤔

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

No branches or pull requests

3 participants