-
Notifications
You must be signed in to change notification settings - Fork 4
/
metrics.go
43 lines (37 loc) · 1.1 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
package instrumenter
import (
"go.opencensus.io/stats"
"go.opencensus.io/stats/view"
"go.opencensus.io/tag"
"github.com/insolar/assured-ledger/ledger-core/instrumentation/insmetrics"
)
var (
tagError = insmetrics.MustTagKey("error")
tagMethod = insmetrics.MustTagKey("method")
tagSubMethod = insmetrics.MustTagKey("subMethod")
)
var (
incomingRequests = stats.Int64("api_incoming", "Count of incoming requests", stats.UnitDimensionless)
statLatency = stats.Int64("api_time", "The latency in milliseconds per API call", stats.UnitMilliseconds)
)
func init() {
err := view.Register(
&view.View{
Name: statLatency.Name(),
Description: statLatency.Description(),
Measure: statLatency,
Aggregation: view.Distribution(25, 500, 1000, 5000, 10000, 15000, 24800),
TagKeys: []tag.Key{tagMethod, tagSubMethod, tagError},
},
&view.View{
Name: incomingRequests.Name(),
Description: incomingRequests.Description(),
TagKeys: []tag.Key{tagMethod},
Measure: incomingRequests,
Aggregation: view.Count(),
},
)
if err != nil {
panic(err)
}
}