// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 package udplogreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/udplogreceiver" import ( "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/receiver" "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/adapter" "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator" "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/input/udp" "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/udplogreceiver/internal/metadata" ) // NewFactory creates a factory for udp receiver func NewFactory() receiver.Factory { return adapter.NewFactory(ReceiverType{}, metadata.LogsStability) } // ReceiverType implements adapter.LogReceiverType // to create a udp receiver type ReceiverType struct{} // Type is the receiver type func (f ReceiverType) Type() component.Type { return metadata.Type } // CreateDefaultConfig creates a config with type and version func (f ReceiverType) CreateDefaultConfig() component.Config { return &UDPLogConfig{ BaseConfig: adapter.BaseConfig{ Operators: []operator.Config{}, }, InputConfig: *udp.NewConfig(), } } // BaseConfig gets the base config from config, for now func (f ReceiverType) BaseConfig(cfg component.Config) adapter.BaseConfig { return cfg.(*UDPLogConfig).BaseConfig } // UDPLogConfig defines configuration for the udp receiver type UDPLogConfig struct { InputConfig udp.Config `mapstructure:",squash"` adapter.BaseConfig `mapstructure:",squash"` } // InputConfig unmarshals the input operator func (f ReceiverType) InputConfig(cfg component.Config) operator.Config { return operator.NewConfig(&cfg.(*UDPLogConfig).InputConfig) }