-
Notifications
You must be signed in to change notification settings - Fork 486
/
logging.go
75 lines (63 loc) · 2.5 KB
/
logging.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
// Package logging provides an otelcol.exporter.logging component.
package logging
import (
"github.com/grafana/agent/component"
"github.com/grafana/agent/component/otelcol"
"github.com/grafana/agent/component/otelcol/exporter"
otel_service "github.com/grafana/agent/service/otel"
otelcomponent "go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config/configtelemetry"
loggingexporter "go.opentelemetry.io/collector/exporter/loggingexporter"
otelextension "go.opentelemetry.io/collector/extension"
)
func init() {
component.Register(component.Registration{
Name: "otelcol.exporter.logging",
Args: Arguments{},
Exports: otelcol.ConsumerExports{},
NeedsServices: []string{otel_service.ServiceName},
Build: func(opts component.Options, args component.Arguments) (component.Component, error) {
fact := loggingexporter.NewFactory()
return exporter.New(opts, fact, args.(Arguments), exporter.TypeAll)
},
})
}
// Arguments configures the otelcol.exporter.logging component.
type Arguments struct {
Verbosity configtelemetry.Level `river:"verbosity,attr,optional"`
SamplingInitial int `river:"sampling_initial,attr,optional"`
SamplingThereafter int `river:"sampling_thereafter,attr,optional"`
// DebugMetrics configures component internal metrics. Optional.
DebugMetrics otelcol.DebugMetricsArguments `river:"debug_metrics,block,optional"`
}
var _ exporter.Arguments = Arguments{}
// DefaultArguments holds default values for Arguments.
var DefaultArguments = Arguments{
Verbosity: configtelemetry.LevelNormal,
SamplingInitial: 2,
SamplingThereafter: 500,
}
// SetToDefault implements river.Defaulter.
func (args *Arguments) SetToDefault() {
*args = DefaultArguments
}
// Convert implements exporter.Arguments.
func (args Arguments) Convert() (otelcomponent.Config, error) {
return &loggingexporter.Config{
Verbosity: args.Verbosity,
SamplingInitial: args.SamplingInitial,
SamplingThereafter: args.SamplingInitial,
}, nil
}
// Extensions implements exporter.Arguments.
func (args Arguments) Extensions() map[otelcomponent.ID]otelextension.Extension {
return nil
}
// Exporters implements exporter.Arguments.
func (args Arguments) Exporters() map[otelcomponent.DataType]map[otelcomponent.ID]otelcomponent.Component {
return nil
}
// DebugMetricsConfig implements receiver.Arguments.
func (args Arguments) DebugMetricsConfig() otelcol.DebugMetricsArguments {
return args.DebugMetrics
}