-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinfo.go
More file actions
47 lines (41 loc) · 1.11 KB
/
info.go
File metadata and controls
47 lines (41 loc) · 1.11 KB
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
package beholder
import (
"go.opentelemetry.io/otel/metric"
)
// Define a new struct for metrics information
type MetricInfo struct {
Name string
Unit string
Description string
}
// ChainInfo contains the chain information (used as execution context)
type ChainInfo struct {
FamilyName string
ChainID string
NetworkName string
NetworkNameFull string
}
// NewInt64Counter creates a new Int64Counter metric
func (m MetricInfo) NewInt64Counter(meter metric.Meter) (metric.Int64Counter, error) {
return meter.Int64Counter(
m.Name,
metric.WithUnit(m.Unit),
metric.WithDescription(m.Description),
)
}
// NewInt64Gauge creates a new Int64Gauge metric
func (m MetricInfo) NewInt64Gauge(meter metric.Meter) (metric.Int64Gauge, error) {
return meter.Int64Gauge(
m.Name,
metric.WithUnit(m.Unit),
metric.WithDescription(m.Description),
)
}
// NewFloat64Gauge creates a new Float64Gauge metric
func (m MetricInfo) NewFloat64Gauge(meter metric.Meter) (metric.Float64Gauge, error) {
return meter.Float64Gauge(
m.Name,
metric.WithUnit(m.Unit),
metric.WithDescription(m.Description),
)
}