This repository has been archived by the owner on Oct 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 62
/
metrics.go
42 lines (38 loc) · 1.52 KB
/
metrics.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package gormimpl
import (
"time"
"github.com/flyteorg/flytestdlib/promutils"
)
// Common metrics emitted by gormimpl repos.
type gormMetrics struct {
Scope promutils.Scope
CreateDuration promutils.StopWatch
GetDuration promutils.StopWatch
UpdateDuration promutils.StopWatch
ListDuration promutils.StopWatch
ListIdentifiersDuration promutils.StopWatch
DeleteDuration promutils.StopWatch
ExistsDuration promutils.StopWatch
CountDuration promutils.StopWatch
}
func newMetrics(scope promutils.Scope) gormMetrics {
return gormMetrics{
Scope: scope,
CreateDuration: scope.MustNewStopWatch(
"create", "time taken to create a new entry", time.Millisecond),
GetDuration: scope.MustNewStopWatch(
"get", "time taken to get an entry", time.Millisecond),
UpdateDuration: scope.MustNewStopWatch(
"update", "time taken to update an entry", time.Millisecond),
ListDuration: scope.MustNewStopWatch(
"list", "time taken to list entries", time.Millisecond),
ListIdentifiersDuration: scope.MustNewStopWatch(
"list_identifiers", "time taken to list identifier entries", time.Millisecond),
DeleteDuration: scope.MustNewStopWatch(
"delete", "time taken to delete an individual entry", time.Millisecond),
ExistsDuration: scope.MustNewStopWatch(
"exists", "time taken to determine whether an individual entry exists", time.Millisecond),
CountDuration: scope.MustNewStopWatch(
"count", "time taken to count entries", time.Millisecond),
}
}