-
Notifications
You must be signed in to change notification settings - Fork 5
/
vitals.go
36 lines (29 loc) · 850 Bytes
/
vitals.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
package webvitals_exporter
import "github.com/prometheus/client_golang/prometheus"
type Vital = *prometheus.SummaryVec
type WebVitals struct {
TTFB *prometheus.SummaryVec
FCP *prometheus.SummaryVec
LCP *prometheus.SummaryVec
FID *prometheus.SummaryVec
CLS *prometheus.SummaryVec
}
var labelNames = []string{"app"}
var Vitals = WebVitals{
TTFB: createVital("TTFB", "Time To First Byte"),
FCP: createVital("FCP", "First Contentful Paint"),
LCP: createVital("LCP", "Largest Contentful Paint"),
FID: createVital("FID", "First Input Delay"),
CLS: createVital("ClS", "Cumulative Layout Shift"),
}
func createVital(name string, help string) *prometheus.SummaryVec {
vital := prometheus.NewSummaryVec(
prometheus.SummaryOpts{
Name: name,
Help: help,
},
labelNames,
)
prometheus.MustRegister(vital)
return vital
}