forked from hyperledger/fabric
-
Notifications
You must be signed in to change notification settings - Fork 6
/
metrics.go
92 lines (83 loc) · 3.01 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
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package chaincode
import "github.com/hyperledger/fabric/common/metrics"
var (
launchDuration = metrics.HistogramOpts{
Namespace: "chaincode",
Name: "launch_duration",
Help: "The time to launch a chaincode.",
LabelNames: []string{"chaincode", "success"},
StatsdFormat: "%{#fqname}.%{chaincode}.%{success}",
}
launchFailures = metrics.CounterOpts{
Namespace: "chaincode",
Name: "launch_failures",
Help: "The number of chaincode launches that have failed.",
LabelNames: []string{"chaincode"},
StatsdFormat: "%{#fqname}.%{chaincode}",
}
launchTimeouts = metrics.CounterOpts{
Namespace: "chaincode",
Name: "launch_timeouts",
Help: "The number of chaincode launches that have timed out.",
LabelNames: []string{"chaincode"},
StatsdFormat: "%{#fqname}.%{chaincode}",
}
shimRequestsReceived = metrics.CounterOpts{
Namespace: "chaincode",
Name: "shim_requests_received",
Help: "The number of chaincode shim requests received.",
LabelNames: []string{"type", "channel", "chaincode"},
StatsdFormat: "%{#fqname}.%{type}.%{channel}.%{chaincode}",
}
shimRequestsCompleted = metrics.CounterOpts{
Namespace: "chaincode",
Name: "shim_requests_completed",
Help: "The number of chaincode shim requests completed.",
LabelNames: []string{"type", "channel", "chaincode", "success"},
StatsdFormat: "%{#fqname}.%{type}.%{channel}.%{chaincode}.%{success}",
}
shimRequestDuration = metrics.HistogramOpts{
Namespace: "chaincode",
Name: "shim_request_duration",
Help: "The time to complete chaincode shim requests.",
LabelNames: []string{"type", "channel", "chaincode", "success"},
StatsdFormat: "%{#fqname}.%{type}.%{channel}.%{chaincode}.%{success}",
}
executeTimeouts = metrics.CounterOpts{
Namespace: "chaincode",
Name: "execute_timeouts",
Help: "The number of chaincode executions (Init or Invoke) that have timed out.",
LabelNames: []string{"chaincode"},
StatsdFormat: "%{#fqname}.%{chaincode}",
}
)
type HandlerMetrics struct {
ShimRequestsReceived metrics.Counter
ShimRequestsCompleted metrics.Counter
ShimRequestDuration metrics.Histogram
ExecuteTimeouts metrics.Counter
}
func NewHandlerMetrics(p metrics.Provider) *HandlerMetrics {
return &HandlerMetrics{
ShimRequestsReceived: p.NewCounter(shimRequestsReceived),
ShimRequestsCompleted: p.NewCounter(shimRequestsCompleted),
ShimRequestDuration: p.NewHistogram(shimRequestDuration),
ExecuteTimeouts: p.NewCounter(executeTimeouts),
}
}
type LaunchMetrics struct {
LaunchDuration metrics.Histogram
LaunchFailures metrics.Counter
LaunchTimeouts metrics.Counter
}
func NewLaunchMetrics(p metrics.Provider) *LaunchMetrics {
return &LaunchMetrics{
LaunchDuration: p.NewHistogram(launchDuration),
LaunchFailures: p.NewCounter(launchFailures),
LaunchTimeouts: p.NewCounter(launchTimeouts),
}
}