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 automatic promethues metrics for roundtrip db query times #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zdjones
Copy link
Contributor

@zdjones zdjones commented Dec 10, 2019

This change adds a prometheus Histogram to each database connection. The
promauto.Histogram will automatically register with the default
prometheus client, if one exists. This change also adds a set of methods
to the the coresql.DB that override the Exec/Query methods of the
underlying sql.DB. These methods record, to the prometheus histogram, the
duration of the Exec/Query call to the underlying sql.DB.

If the application uses the core metrics server from
LUSHDigital/core/workers/metricsrv, the database histogram will be available
via that metrics server's endpoint without any further changes to your
code.

This change adds a prometheus Histogram to each database connection. The
promauto.Histogram will automatically register with the default
prometheus client, if one exists. This change also adds a set of methods
to the the coresql.DB that override the Exec/Query methods of the
underlying sql.DB. These methods record, to the prometheus histogram, the
duration of the Exec/Query call to the underlying sql.DB.

If the application uses the core metrics server from
LUSHDigital/core/workers/metricsrv, the database histogram will be available
via that metrics server's endpoint without any further changes to your
code.
}

// Check will attempt to ping the database to see if the connection is still alive.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you accidentally removed comment/docs for Check function, which broke the build.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you fix this, I can get this merged. This is really useful.

}

// Check will attempt to ping the database to see if the connection is still alive.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you fix this, I can get this merged. This is really useful.

@zeevallin
Copy link
Contributor

Sorry @zdjones I completely missed this MR. My bad.

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.

3 participants