-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
Copy pathgenerated_telemetry.go
128 lines (110 loc) · 4.96 KB
/
generated_telemetry.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
// Code generated by mdatagen. DO NOT EDIT.
package metadata
import (
"context"
"errors"
"sync"
"go.opentelemetry.io/otel/metric"
"go.opentelemetry.io/otel/trace"
"go.opentelemetry.io/collector/component"
)
func Meter(settings component.TelemetrySettings) metric.Meter {
return settings.MeterProvider.Meter("go.opentelemetry.io/collector/processor/memorylimiterprocessor")
}
func Tracer(settings component.TelemetrySettings) trace.Tracer {
return settings.TracerProvider.Tracer("go.opentelemetry.io/collector/processor/memorylimiterprocessor")
}
// TelemetryBuilder provides an interface for components to report telemetry
// as defined in metadata and user config.
type TelemetryBuilder struct {
meter metric.Meter
mu sync.Mutex
registrations []metric.Registration
ProcessorAcceptedLogRecords metric.Int64Counter
ProcessorAcceptedMetricPoints metric.Int64Counter
ProcessorAcceptedSpans metric.Int64Counter
ProcessorRefusedLogRecords metric.Int64Counter
ProcessorRefusedMetricPoints metric.Int64Counter
ProcessorRefusedSpans metric.Int64Counter
}
// TelemetryBuilderOption applies changes to default builder.
type TelemetryBuilderOption interface {
apply(*TelemetryBuilder)
}
type telemetryBuilderOptionFunc func(mb *TelemetryBuilder)
func (tbof telemetryBuilderOptionFunc) apply(mb *TelemetryBuilder) {
tbof(mb)
}
// Shutdown unregister all registered callbacks for async instruments.
func (builder *TelemetryBuilder) Shutdown() {
builder.mu.Lock()
defer builder.mu.Unlock()
for _, reg := range builder.registrations {
reg.Unregister()
}
}
// NewTelemetryBuilder provides a struct with methods to update all internal telemetry
// for a component
func NewTelemetryBuilder(settings component.TelemetrySettings, options ...TelemetryBuilderOption) (*TelemetryBuilder, error) {
builder := TelemetryBuilder{}
for _, op := range options {
op.apply(&builder)
}
builder.meter = Meter(settings)
var err, errs error
builder.ProcessorAcceptedLogRecords, err = builder.meter.Int64Counter(
"otelcol_processor_accepted_log_records",
metric.WithDescription("Number of log records successfully pushed into the next component in the pipeline. [deprecated since v0.110.0]"),
metric.WithUnit("{records}"),
)
errs = errors.Join(errs, err)
builder.ProcessorAcceptedMetricPoints, err = builder.meter.Int64Counter(
"otelcol_processor_accepted_metric_points",
metric.WithDescription("Number of metric points successfully pushed into the next component in the pipeline. [deprecated since v0.110.0]"),
metric.WithUnit("{datapoints}"),
)
errs = errors.Join(errs, err)
builder.ProcessorAcceptedSpans, err = builder.meter.Int64Counter(
"otelcol_processor_accepted_spans",
metric.WithDescription("Number of spans successfully pushed into the next component in the pipeline. [deprecated since v0.110.0]"),
metric.WithUnit("{spans}"),
)
errs = errors.Join(errs, err)
builder.ProcessorRefusedLogRecords, err = builder.meter.Int64Counter(
"otelcol_processor_refused_log_records",
metric.WithDescription("Number of log records that were rejected by the next component in the pipeline. [deprecated since v0.110.0]"),
metric.WithUnit("{records}"),
)
errs = errors.Join(errs, err)
builder.ProcessorRefusedMetricPoints, err = builder.meter.Int64Counter(
"otelcol_processor_refused_metric_points",
metric.WithDescription("Number of metric points that were rejected by the next component in the pipeline. [deprecated since v0.110.0]"),
metric.WithUnit("{datapoints}"),
)
errs = errors.Join(errs, err)
builder.ProcessorRefusedSpans, err = builder.meter.Int64Counter(
"otelcol_processor_refused_spans",
metric.WithDescription("Number of spans that were rejected by the next component in the pipeline. [deprecated since v0.110.0]"),
metric.WithUnit("{spans}"),
)
errs = errors.Join(errs, err)
return &builder, errs
}
func (builder *TelemetryBuilder) RecordProcessorAcceptedLogRecords(ctx context.Context, val int64, opts ...metric.AddOption) {
builder.ProcessorAcceptedLogRecords.Add(ctx, val, opts...)
}
func (builder *TelemetryBuilder) RecordProcessorAcceptedMetricPoints(ctx context.Context, val int64, opts ...metric.AddOption) {
builder.ProcessorAcceptedMetricPoints.Add(ctx, val, opts...)
}
func (builder *TelemetryBuilder) RecordProcessorAcceptedSpans(ctx context.Context, val int64, opts ...metric.AddOption) {
builder.ProcessorAcceptedSpans.Add(ctx, val, opts...)
}
func (builder *TelemetryBuilder) RecordProcessorRefusedLogRecords(ctx context.Context, val int64, opts ...metric.AddOption) {
builder.ProcessorRefusedLogRecords.Add(ctx, val, opts...)
}
func (builder *TelemetryBuilder) RecordProcessorRefusedMetricPoints(ctx context.Context, val int64, opts ...metric.AddOption) {
builder.ProcessorRefusedMetricPoints.Add(ctx, val, opts...)
}
func (builder *TelemetryBuilder) RecordProcessorRefusedSpans(ctx context.Context, val int64, opts ...metric.AddOption) {
builder.ProcessorRefusedSpans.Add(ctx, val, opts...)
}