-
Notifications
You must be signed in to change notification settings - Fork 487
/
opencensus.go
77 lines (63 loc) · 2.18 KB
/
opencensus.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
// Package opencensus provides an otelcol.receiver.opencensus component.
package opencensus
import (
"github.com/alecthomas/units"
"github.com/grafana/agent/component"
"github.com/grafana/agent/component/otelcol"
"github.com/grafana/agent/component/otelcol/receiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/opencensusreceiver"
otelcomponent "go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/extension"
)
func init() {
component.Register(component.Registration{
Name: "otelcol.receiver.opencensus",
Args: Arguments{},
Build: func(opts component.Options, args component.Arguments) (component.Component, error) {
fact := opencensusreceiver.NewFactory()
return receiver.New(opts, fact, args.(Arguments))
},
})
}
// Arguments configures the otelcol.receiver.opencensus component.
type Arguments struct {
CorsAllowedOrigins []string `river:"cors_allowed_origins,attr,optional"`
GRPC otelcol.GRPCServerArguments `river:",squash"`
// Output configures where to send received data. Required.
Output *otelcol.ConsumerArguments `river:"output,block"`
}
var (
_ receiver.Arguments = Arguments{}
)
// Default server settings.
var DefaultArguments = Arguments{
GRPC: otelcol.GRPCServerArguments{
Endpoint: "0.0.0.0:4317",
Transport: "tcp",
ReadBufferSize: 512 * units.Kibibyte,
// We almost write 0 bytes, so no need to tune WriteBufferSize.
},
}
// SetToDefault implements river.Defaulter.
func (args *Arguments) SetToDefault() {
*args = DefaultArguments
}
// Convert implements receiver.Arguments.
func (args Arguments) Convert() (otelcomponent.Config, error) {
return &opencensusreceiver.Config{
CorsOrigins: args.CorsAllowedOrigins,
GRPCServerSettings: *args.GRPC.Convert(),
}, nil
}
// Extensions implements receiver.Arguments.
func (args Arguments) Extensions() map[otelcomponent.ID]extension.Extension {
return nil
}
// Exporters implements receiver.Arguments.
func (args Arguments) Exporters() map[otelcomponent.DataType]map[otelcomponent.ID]otelcomponent.Component {
return nil
}
// NextConsumers implements receiver.Arguments.
func (args Arguments) NextConsumers() *otelcol.ConsumerArguments {
return args.Output
}