forked from xmidt-org/scytale
-
Notifications
You must be signed in to change notification settings - Fork 0
/
metrics.go
57 lines (47 loc) · 1.38 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// SPDX-FileCopyrightText: 2019 Comcast Cable Communications Management, LLC
// SPDX-License-Identifier: Apache-2.0
package main
import (
"github.com/go-kit/kit/metrics"
// nolint:staticcheck
"github.com/xmidt-org/webpa-common/v2/xmetrics"
)
// Names for our metrics
const (
ReceivedWRPMessageCount = "received_wrp_message_total"
)
// labels
const (
ClientIDLabel = "clientid"
OutcomeLabel = "outcome"
ReasonLabel = "reason"
)
// label values
const (
Accepted = "accepted"
Rejected = "rejected"
TokenMissing = "token_not_found"
// nolint:gosec
TokenTypeMismatch = "token_type_mismatch"
WRPPIDMissing = "wrp_pid_missing"
WRPPIDMismatch = "wrp_pid_mismatch"
WRPPIDMatch = "wrp_pid_match"
JWTPIDWildcard = "jwt_pid_wildcard"
JWTPIDInvalid = "jwt_pid_invalid"
)
// Metrics returns the metrics relevant to this package
func Metrics() []xmetrics.Metric {
return []xmetrics.Metric{
{
Name: ReceivedWRPMessageCount,
Type: xmetrics.CounterType,
Help: "Number of WRP Messages successfully decoded and ready for fanout.",
LabelNames: []string{OutcomeLabel, ClientIDLabel, ReasonLabel},
},
}
}
// NewReceivedWRPCounter initializes a counter to keep track of
// scytale users which do not populate the partnerIDs field in their WRP messages
func NewReceivedWRPCounter(r xmetrics.Registry) metrics.Counter {
return r.NewCounter(ReceivedWRPMessageCount)
}