Path: blob/main/component/otelcol/receiver/opencensus/opencensus.go
4096 views
// Package opencensus provides an otelcol.receiver.opencensus component.1package opencensus23import (4"github.com/alecthomas/units"5"github.com/grafana/agent/component"6"github.com/grafana/agent/component/otelcol"7"github.com/grafana/agent/component/otelcol/receiver"8"github.com/grafana/agent/pkg/river"9"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/opencensusreceiver"10otelcomponent "go.opentelemetry.io/collector/component"11otelconfig "go.opentelemetry.io/collector/config"12)1314func init() {15component.Register(component.Registration{16Name: "otelcol.receiver.opencensus",17Args: Arguments{},1819Build: func(opts component.Options, args component.Arguments) (component.Component, error) {20fact := opencensusreceiver.NewFactory()21return receiver.New(opts, fact, args.(Arguments))22},23})24}2526// Arguments configures the otelcol.receiver.opencensus component.27type Arguments struct {28CorsAllowedOrigins []string `river:"cors_allowed_origins,attr,optional"`2930GRPC otelcol.GRPCServerArguments `river:",squash"`3132// Output configures where to send received data. Required.33Output *otelcol.ConsumerArguments `river:"output,block"`34}3536var (37_ receiver.Arguments = Arguments{}38_ river.Unmarshaler = (*Arguments)(nil)39)4041// Default server settings.42var DefaultArguments = Arguments{43GRPC: otelcol.GRPCServerArguments{44Endpoint: "0.0.0.0:4317",45Transport: "tcp",4647ReadBufferSize: 512 * units.Kibibyte,48// We almost write 0 bytes, so no need to tune WriteBufferSize.49},50}5152// UnmarshalRiver implements river.Unmarshaler and supplies defaults.53func (args *Arguments) UnmarshalRiver(f func(interface{}) error) error {54*args = DefaultArguments5556type arguments Arguments57return f((*arguments)(args))58}5960// Convert implements receiver.Arguments.61func (args Arguments) Convert() (otelconfig.Receiver, error) {62return &opencensusreceiver.Config{63ReceiverSettings: otelconfig.NewReceiverSettings(otelconfig.NewComponentID("opencensus")),6465CorsOrigins: args.CorsAllowedOrigins,66GRPCServerSettings: *args.GRPC.Convert(),67}, nil68}6970// Extensions implements receiver.Arguments.71func (args Arguments) Extensions() map[otelconfig.ComponentID]otelcomponent.Extension {72return nil73}7475// Exporters implements receiver.Arguments.76func (args Arguments) Exporters() map[otelconfig.DataType]map[otelconfig.ComponentID]otelcomponent.Exporter {77return nil78}7980// NextConsumers implements receiver.Arguments.81func (args Arguments) NextConsumers() *otelcol.ConsumerArguments {82return args.Output83}848586