-
Notifications
You must be signed in to change notification settings - Fork 0
/
metrics.go
101 lines (86 loc) · 2.18 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
package prepare
import (
gometrics "github.com/armon/go-metrics"
"github.com/jinxprotocol/v4-chain/protocol/lib/metrics"
"github.com/cosmos/cosmos-sdk/telemetry"
)
const (
ModuleName = "prepare_proposal"
)
// successMetricParams defines params needed for reporting a successful `PrepareProposal`.
type successMetricParams struct {
txs PrepareProposalTxs
pricesTx PricesTxResponse
fundingTx FundingTxResponse
bridgeTx BridgeTxResponse
operationsTx OperationsTxResponse
numTxsToReturn int
numTxsInOriginalReq int
}
// recordErrorMetricsWithLabel records an error metric in `PrepareProposalHandler` with a label.
func recordErrorMetricsWithLabel(label string) {
telemetry.IncrCounterWithLabels(
[]string{ModuleName, metrics.Handler, metrics.Error, metrics.Count},
1,
[]gometrics.Label{metrics.GetLabelForStringValue(metrics.Detail, label)},
)
}
// recordSuccessMetrics records a success metric details for `PrepareProposalHandler`.
func recordSuccessMetrics(params successMetricParams) {
// Record success.
telemetry.IncrCounter(
1,
ModuleName,
metrics.Handler,
metrics.Success,
metrics.Count,
)
// Prices tx.
telemetry.SetGauge(
float32(params.pricesTx.NumMarkets),
ModuleName,
metrics.NumMarketPricesToUpdate,
)
// Funding tx.
telemetry.SetGauge(
float32(params.fundingTx.NumVotes),
ModuleName,
metrics.NumPremiumVotes,
)
// Bridge tx.
telemetry.IncrCounter(
float32(params.bridgeTx.NumBridges),
ModuleName,
metrics.NumBridges,
)
// Operations tx.
telemetry.SetGauge(
float32(params.operationsTx.NumOperations),
ModuleName,
metrics.NumProposedOperations,
)
// Other txs.
telemetry.SetGauge(
float32(len(params.txs.OtherTxs)),
ModuleName,
metrics.NumOtherTxs,
)
// Total # of txs in the new proposal.
telemetry.SetGauge(
float32(params.numTxsToReturn),
ModuleName,
metrics.TotalNumTxs,
)
// Total # of bytes in txs in the new proposal.
telemetry.SetGauge(
float32(params.txs.UsedBytes),
ModuleName,
metrics.TotalNumBytes,
)
// Total # of txs in the original req.
telemetry.SetGauge(
float32(params.numTxsInOriginalReq),
ModuleName,
metrics.OriginalNumTxs,
)
}