Add request_duration_seconds metric #72

Merged
mrngm merged 3 commits from metrics into master 2021-05-16 21:10:49 +02:00
Owner

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.

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.
electricdusk force-pushed metrics from 46f26664a4 to ea8c22c37c 2021-05-07 10:14:51 +02:00 Compare
electricdusk force-pushed metrics from ea8c22c37c to 0321bb72dc 2021-05-08 22:42:08 +02:00 Compare
mrngm approved these changes 2021-05-16 14:35:11 +02:00
metrics.go Outdated
@ -45,0 +47,4 @@
// partitioned by type and state.
//
// Its values are computed on the fly by updateMetrics().
var metricURLsTotalGauge = prometheus.NewGaugeVec(
Collaborator

(technically, the PR is for request_duration_seconds, so anything other than that should be omitted... or change the PR title and description)

(technically, the PR is for `request_duration_seconds`, so anything other than that should be omitted... or change the PR title and description)
mrngm marked this conversation as resolved
metrics.go Outdated
@ -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)
Collaborator

Is it possible to query the database once, yielding all counts for all types and states?

Is it possible to query the database once, yielding all counts for all types and states?
Author
Owner

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.

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.
Collaborator

Ran this query on the test migration database:

sqlite> SELECT type, state, COUNT(*) FROM pastes GROUP BY type, state;
0|2|136  // type: undef      state: deleted
2|1|118  // type: redirect   state: present
3|1|1376 // type: fileupload state: present

Would that roughly be what you expect to get here?

Ran this query on the test migration database: ``` sqlite> SELECT type, state, COUNT(*) FROM pastes GROUP BY type, state; 0|2|136 // type: undef state: deleted 2|1|118 // type: redirect state: present 3|1|1376 // type: fileupload state: present ``` Would that roughly be what you expect to get here?
electricdusk marked this conversation as resolved
mrngm requested changes 2021-05-16 14:37:58 +02:00
mrngm left a comment
Collaborator

See the other review comments.

See the other review comments.
electricdusk force-pushed metrics from 0321bb72dc to c4ff0ab1b7 2021-05-16 20:20:44 +02:00 Compare
electricdusk force-pushed metrics from ccd9d2f110 to 306705cb28 2021-05-16 20:42:27 +02:00 Compare
mrngm approved these changes 2021-05-16 21:10:44 +02:00
mrngm merged commit 29ee3dc6fd into master 2021-05-16 21:10:49 +02:00
Collaborator

Live.

Live.
electricdusk deleted branch metrics 2021-05-17 22:40:29 +02:00
Sign in to join this conversation.
No reviewers
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: electricdusk/rushlink#72
No description provided.