config

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2023 License: MPL-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package config manages helpers to generate opentelemetry-collector configuration.

Currently the Config struct is the overarching configuration that is generated and marshaled to a confmap to be used by the providers in the otel/collector package.

type Config struct {
    Receivers  telemetryComponents `mapstructure:"receivers"`
    Exporters  telemetryComponents `mapstructure:"exporters"`
    Processors telemetryComponents `mapstructure:"processors"`
    Connectors telemetryComponents `mapstructure:"connectors"`
    Extensions telemetryComponents `mapstructure:"extensions"`
    Service    service.Config      `mapstructure:"service"`
 }

First off we setup our extensions. Then we define our pipelines and from those definitions we can build pipeline configuration. The service config below shows how the Pipelines are defined in map of id -> pipeline. Each pipeline is just a list of receivers, exporters and processors that are dynamically built from that list.

   Ex: "hcpPipeline"->pipelineConfig of receivers, exporters, processors.
	/*
	// Service Configuration
	type Config struct {
		Telemetry telemetry.Config `mapstructure:"telemetry"`
		Extensions []component.ID `mapstructure:"extensions"`
		Pipelines map[component.ID]*PipelineConfig `mapstructure:"pipelines"`
	}

	type PipelineConfig struct {
		Receivers  []component.ID `mapstructure:"receivers"`
		Processors []component.ID `mapstructure:"processors"`
		Exporters  []component.ID `mapstructure:"exporters"`
	}
	*/

All of this is marshaled to a configuration that the otel collector sdk will run. The goal of this package is to help build a configuration that the marshaller will run with our defaults. We setup specific IDs for each pipeline

/*
     receivers:
		otlp:
			protocols:
				http: {}

	processors:
		memory_limiter:
			check_interval: 1s
			limit_percentage: 50
			spike_limit_percentage: 30
		batch:

		exporters:
			logging: {}

		service:
			pipelines:
				traces:
					receivers: [otlp]
					exporters: [logging]
*/

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtensionBuilder

func ExtensionBuilder(opts ...Opts) []component.ID

ExtensionBuilder builds a list of extension IDs. Optionally we can include more ids with variadic opts.

func PipelineConfigBuilder

func PipelineConfigBuilder(p *Params) pipelines.PipelineConfig

PipelineConfigBuilder defines a basic list of pipeline component IDs for a service.PipelineConfig.

func ProcessorBuilder

func ProcessorBuilder(opts ...Opts) []component.ID

ProcessorBuilder returns a list of processor IDs. The provided IDs inserted between the memory limiter and batch processor.

func Telemetry

func Telemetry(metricsPort int) telemetry.Config

Telemetry returns our basic telemetry configuration.

func WithExtOauthClientID

func WithExtOauthClientID(ext []component.ID) []component.ID

WithExtOauthClientID is an Opt function to add the oauthclient id to the list of extensions NOTE: this extension will require.

func WithFilterProcessor

func WithFilterProcessor(procesors []component.ID) []component.ID

WithFilterProcessor is an Opt function to add the filter processor to a list of processors.

func WithResourceProcessor

func WithResourceProcessor(prcs []component.ID) []component.ID

WithResourceProcessor adds the resource processor to a list of processors. It should go after the filter processor to ensure that we do not operate on signals that we won't forward.

Types

type Config

type Config struct {
	Receivers  componentMap   `mapstructure:"receivers"`
	Exporters  componentMap   `mapstructure:"exporters"`
	Processors componentMap   `mapstructure:"processors"`
	Connectors componentMap   `mapstructure:"connectors"`
	Extensions componentMap   `mapstructure:"extensions"`
	Service    service.Config `mapstructure:"service"`
}

Config is a helper type to create a new opentelemetry server configuration. It implements a map[string]interface{} representation of the opentelemetry-collector configuration. More information can be found here: https://opentelemetry.io/docs/collector/configuration/

func NewConfig

func NewConfig() *Config

NewConfig creates a new config object with all types initialized.

func (*Config) EnrichWithExtensions

func (c *Config) EnrichWithExtensions(
	extensions []component.ID,
	p *Params,
) error

EnrichWithExtensions adds the specific configurations for a given list of extension IDs. The parameters are sometimes required to build an extension so they should be passed through.

func (*Config) EnrichWithPipelineCfg

func (c *Config) EnrichWithPipelineCfg(
	pCfg pipelines.PipelineConfig,
	p *Params,
	pipelineID component.ID,
) error

EnrichWithPipelineCfg enrichs a Config by taking the IDs specified in a pipeline config and builds the corresponding configuration for each component ID. Some of these components require a set of params.

type ExporterConfig added in v0.1.0

type ExporterConfig struct {
	ID       component.ID
	Exporter *exporters.ExporterConfig
}

ExporterConfig holds a dynamic exporter configuration and corresponding component.ID

type Opts

type Opts func([]component.ID) []component.ID

Opts is a variadic type passed in as a way of manipulating a list of components.

type Params

type Params struct {
	ExporterConfig    *ExporterConfig
	Client            hcp.TelemetryClient
	ClientID          string
	ClientSecret      string
	ResourceID        string
	BatchTimeout      time.Duration
	MetricsPort       int
	EnvoyListenerPort int
}

Params are the inputs to the configuration building process. Only some config requires these inputs.

Directories

Path Synopsis
helpers
exporters
Package exporters holds the type of exporters that consul telemetery supports
Package exporters holds the type of exporters that consul telemetery supports
extensions
Package extensions holds the type of extensions that consul telemetery supports
Package extensions holds the type of extensions that consul telemetery supports
processors
Package processors holds the type of processors that consul telemetery supports
Package processors holds the type of processors that consul telemetery supports
receivers
Package receivers holds the type of receivers that consul telemetery supports
Package receivers holds the type of receivers that consul telemetery supports
types
Package types is a place to store reused types amongst the helpers
Package types is a place to store reused types amongst the helpers

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL