Documentation ¶
Overview ¶
Package otelcol handles the command-line, configuration, and runs the OpenTelemetry Collector. It contains the main Collector struct and its constructor NewCollector. Collector.Run starts the Collector and then blocks until it shuts down.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewCommand ¶
func NewCommand(set CollectorSettings) *cobra.Command
NewCommand constructs a new cobra.Command using the given CollectorSettings. Any URIs specified in CollectorSettings.ConfigProviderSettings.ResolverSettings.URIs are considered defaults and will be overwritten by config flags passed as command-line arguments to the executable. At least one Provider must be set.
Types ¶
type Collector ¶
type Collector struct {
// contains filtered or unexported fields
}
Collector represents a server providing the OpenTelemetry Collector service.
func NewCollector ¶
func NewCollector(set CollectorSettings) (*Collector, error)
NewCollector creates and returns a new instance of Collector.
type CollectorSettings ¶
type CollectorSettings struct { // Factories service factories. Factories func() (Factories, error) // BuildInfo provides collector start information. BuildInfo component.BuildInfo // DisableGracefulShutdown disables the automatic graceful shutdown // of the collector on SIGINT or SIGTERM. // Users who want to handle signals themselves can disable this behavior // and manually handle the signals to shutdown the collector. DisableGracefulShutdown bool // ConfigProviderSettings allows configuring the way the Collector retrieves its configuration // The Collector will reload based on configuration changes from the ConfigProvider if any // confmap.Providers watch for configuration changes. ConfigProviderSettings ConfigProviderSettings // LoggingOptions provides a way to change behavior of zap logging. LoggingOptions []zap.Option // SkipSettingGRPCLogger avoids setting the grpc logger SkipSettingGRPCLogger bool }
CollectorSettings holds configuration for creating a new Collector.
type Config ¶
type Config struct { // Receivers is a map of ComponentID to Receivers. Receivers map[component.ID]component.Config `mapstructure:"receivers"` // Exporters is a map of ComponentID to Exporters. Exporters map[component.ID]component.Config `mapstructure:"exporters"` // Processors is a map of ComponentID to Processors. Processors map[component.ID]component.Config `mapstructure:"processors"` // Connectors is a map of ComponentID to connectors. Connectors map[component.ID]component.Config `mapstructure:"connectors"` // Extensions is a map of ComponentID to extensions. Extensions map[component.ID]component.Config `mapstructure:"extensions"` Service service.Config `mapstructure:"service"` }
Config defines the configuration for the various elements of collector or agent.
func (*Config) Validate ¶
Validate returns an error if the config is invalid.
This function performs basic validation of configuration. There may be more subtle invalid cases that we currently don't check for but which we may want to add in the future (e.g. disallowing receiving and exporting on the same endpoint).
type ConfigProvider ¶
type ConfigProvider interface { // Get returns the service configuration, or error otherwise. // // Should never be called concurrently with itself, Watch or Shutdown. Get(ctx context.Context, factories Factories) (*Config, error) // Watch blocks until any configuration change was detected or an unrecoverable error // happened during monitoring the configuration changes. // // Error is nil if the configuration is changed and needs to be re-fetched. Any non-nil // error indicates that there was a problem with watching the config changes. // // Should never be called concurrently with itself or Get. Watch() <-chan error // Shutdown signals that the provider is no longer in use and the that should close // and release any resources that it may have created. // // This function must terminate the Watch channel. // // Should never be called concurrently with itself or Get. Shutdown(ctx context.Context) error }
ConfigProvider provides the service configuration.
The typical usage is the following:
cfgProvider.Get(...) cfgProvider.Watch() // wait for an event. cfgProvider.Get(...) cfgProvider.Watch() // wait for an event. // repeat Get/Watch cycle until it is time to shut down the Collector process. cfgProvider.Shutdown()
func NewConfigProvider ¶
func NewConfigProvider(set ConfigProviderSettings) (ConfigProvider, error)
NewConfigProvider returns a new ConfigProvider that provides the service configuration: * Initially it resolves the "configuration map":
- Retrieve the confmap.Conf by merging all retrieved maps from the given `locations` in order.
- Then applies all the confmap.Converter in the given order.
* Then unmarshalls the confmap.Conf into the service Config.
type ConfigProviderSettings ¶
type ConfigProviderSettings struct { // ResolverSettings are the settings to configure the behavior of the confmap.Resolver. ResolverSettings confmap.ResolverSettings }
ConfigProviderSettings are the settings to configure the behavior of the ConfigProvider.
type Factories ¶
type Factories struct { // Receivers maps receiver type names in the config to the respective factory. Receivers map[component.Type]receiver.Factory // Processors maps processor type names in the config to the respective factory. Processors map[component.Type]processor.Factory // Exporters maps exporter type names in the config to the respective factory. Exporters map[component.Type]exporter.Factory // Extensions maps extension type names in the config to the respective factory. Extensions map[component.Type]extension.Factory // Connectors maps connector type names in the config to the respective factory. Connectors map[component.Type]connector.Factory // ReceiverModules maps receiver types to their respective go modules. ReceiverModules map[component.Type]string // ProcessorModules maps processor types to their respective go modules. ProcessorModules map[component.Type]string // ExporterModules maps exporter types to their respective go modules. ExporterModules map[component.Type]string // ExtensionModules maps extension types to their respective go modules. ExtensionModules map[component.Type]string // ConnectorModules maps connector types to their respective go modules. ConnectorModules map[component.Type]string }
Factories struct holds in a single type all component factories that can be handled by the Config.