generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 5
/
metrics.go
114 lines (98 loc) 路 3.42 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
102
103
104
105
106
107
108
109
110
111
112
113
114
package observability
import (
"context"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/metric"
"github.com/TBD54566975/ftl/internal/rpc"
)
func MeterWithVerb(ctx context.Context) metric.Meter {
verb, ok := rpc.VerbFromContext(ctx)
if !ok {
panic("traces: no verb in context")
}
return otel.GetMeterProvider().Meter(verb.Name)
}
func Int64Counter(ctx context.Context, name string, options ...metric.Int64CounterOption) metric.Int64Counter {
counter, err := MeterWithVerb(ctx).Int64Counter(name, options...)
if err != nil {
panic(err)
}
return counter
}
func Int64UpDownCounter(ctx context.Context, name string, options ...metric.Int64UpDownCounterOption) metric.Int64UpDownCounter {
counter, err := MeterWithVerb(ctx).Int64UpDownCounter(name, options...)
if err != nil {
panic(err)
}
return counter
}
func Int64Histogram(ctx context.Context, name string, options ...metric.Int64HistogramOption) metric.Int64Histogram {
counter, err := MeterWithVerb(ctx).Int64Histogram(name, options...)
if err != nil {
panic(err)
}
return counter
}
func Int64ObservableCounter(ctx context.Context, name string, options ...metric.Int64ObservableCounterOption) metric.Int64ObservableCounter {
counter, err := MeterWithVerb(ctx).Int64ObservableCounter(name, options...)
if err != nil {
panic(err)
}
return counter
}
func Int64ObservableUpDownCounter(ctx context.Context, name string, options ...metric.Int64ObservableUpDownCounterOption) metric.Int64ObservableUpDownCounter {
counter, err := MeterWithVerb(ctx).Int64ObservableUpDownCounter(name, options...)
if err != nil {
panic(err)
}
return counter
}
func Int64ObservableGauge(ctx context.Context, name string, options ...metric.Int64ObservableGaugeOption) metric.Int64ObservableGauge {
counter, err := MeterWithVerb(ctx).Int64ObservableGauge(name, options...)
if err != nil {
panic(err)
}
return counter
}
func Float64Counter(ctx context.Context, name string, options ...metric.Float64CounterOption) metric.Float64Counter {
counter, err := MeterWithVerb(ctx).Float64Counter(name, options...)
if err != nil {
panic(err)
}
return counter
}
func Float64UpDownCounter(ctx context.Context, name string, options ...metric.Float64UpDownCounterOption) metric.Float64UpDownCounter {
counter, err := MeterWithVerb(ctx).Float64UpDownCounter(name, options...)
if err != nil {
panic(err)
}
return counter
}
func Float64Histogram(ctx context.Context, name string, options ...metric.Float64HistogramOption) metric.Float64Histogram {
counter, err := MeterWithVerb(ctx).Float64Histogram(name, options...)
if err != nil {
panic(err)
}
return counter
}
func Float64ObservableCounter(ctx context.Context, name string, options ...metric.Float64ObservableCounterOption) metric.Float64ObservableCounter {
counter, err := MeterWithVerb(ctx).Float64ObservableCounter(name, options...)
if err != nil {
panic(err)
}
return counter
}
func Float64ObservableUpDownCounter(ctx context.Context, name string, options ...metric.Float64ObservableUpDownCounterOption) metric.Float64ObservableUpDownCounter {
counter, err := MeterWithVerb(ctx).Float64ObservableUpDownCounter(name, options...)
if err != nil {
panic(err)
}
return counter
}
func Float64ObservableGauge(ctx context.Context, name string, options ...metric.Float64ObservableGaugeOption) metric.Float64ObservableGauge {
counter, err := MeterWithVerb(ctx).Float64ObservableGauge(name, options...)
if err != nil {
panic(err)
}
return counter
}