1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package api
17
18 import (
19 "time"
20
21 "github.com/prometheus/client_golang/prometheus"
22 "github.com/prometheus/client_golang/prometheus/promauto"
23 "sigs.k8s.io/release-utils/version"
24 )
25
26 var (
27 MetricLatency = promauto.NewHistogramVec(prometheus.HistogramOpts{
28 Name: "timestamp_authority_api_latency",
29 Help: "API Latency on calls",
30 }, []string{"path", "code"})
31
32 MetricLatencySummary = promauto.NewSummaryVec(prometheus.SummaryOpts{
33 Name: "timestamp_authority_api_latency_summary",
34 Help: "API Latency on calls",
35 }, []string{"path", "code"})
36
37 MetricRequestLatency = promauto.NewHistogramVec(prometheus.HistogramOpts{
38 Name: "timestamp_authority_latency_by_api",
39 Help: "API Latency (in ns) by path and method",
40 Buckets: prometheus.ExponentialBucketsRange(
41 float64(time.Millisecond),
42 float64(4*time.Second),
43 10),
44 }, []string{"path", "method"})
45
46 MetricRequestCount = promauto.NewCounterVec(prometheus.CounterOpts{
47 Name: "timestamp_authority_http_requests_total",
48 Help: "Total number of HTTP requests by status code, path, and method.",
49 }, []string{"code", "path", "method"})
50
51 MetricNTPLatency = promauto.NewHistogramVec(prometheus.HistogramOpts{
52 Name: "timestamp_authority_ntp_latency",
53 Help: "NTP request latency",
54 }, []string{"host"})
55
56 MetricNTPSyncCount = promauto.NewCounterVec(prometheus.CounterOpts{
57 Name: "timestamp_authority_ntp_sync_total",
58 Help: "Total number of NTP requests against a remote server",
59 }, []string{"host", "failed"})
60
61 MetricNTPErrorCount = promauto.NewCounterVec(prometheus.CounterOpts{
62 Name: "timestamp_authority_ntp_errors_total",
63 Help: "Total number of NTP related errors",
64 }, []string{"reason"})
65
66 _ = promauto.NewGaugeFunc(
67 prometheus.GaugeOpts{
68 Namespace: "timestamp_authority",
69 Name: "build_info",
70 Help: "A metric with a constant '1' value labeled by version, revision, branch, and goversion from which timestamp-authority was built.",
71 ConstLabels: prometheus.Labels{
72 "version": version.GetVersionInfo().GitVersion,
73 "revision": version.GetVersionInfo().GitCommit,
74 "build_date": version.GetVersionInfo().BuildDate,
75 "goversion": version.GetVersionInfo().GoVersion,
76 },
77 },
78 func() float64 { return 1 },
79 )
80 )
81
View as plain text