Add request_duration_seconds metric #72
No reviewers
Labels
No Label
bug
feature
good-beginner-bug
needs-test
question
wontfix
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: electricdusk/rushlink#72
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "metrics"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This PR adds a new
request_duration_seconds
metrics, which records a histogram of the request latency, partitioned by status code and HTTP method.This PR also refactors other parts of the
metrics.go
file.46f26664a4
toea8c22c37c
ea8c22c37c
to0321bb72dc
@ -45,0 +47,4 @@
// partitioned by type and state.
//
// Its values are computed on the fly by updateMetrics().
var metricURLsTotalGauge = prometheus.NewGaugeVec(
(technically, the PR is for
request_duration_seconds
, so anything other than that should be omitted... or change the PR title and description)@ -61,0 +86,4 @@
for state := db.PasteStateUndef; state <= db.PasteStateDeleted; state++ {
for ty := db.PasteTypeUndef; ty <= db.PasteTypeFileUpload; ty++ {
var count int64
query := mh.db.Unscoped().Model(&db.Paste{}).Where("type = ? AND state = ?", ty, state).Count(&count)
Is it possible to query the database once, yielding all counts for all types and states?
I tried to find this, but thought it was not not possible. I have retried searching for this and found this: https://stackoverflow.com/a/19046871/5207081
That would fix this.
Ran this query on the test migration database:
Would that roughly be what you expect to get here?
See the other review comments.
0321bb72dc
toc4ff0ab1b7
ccd9d2f110
to306705cb28
Live.