otelcolconvert

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: Apache-2.0 Imports: 92 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendConfig

func AppendConfig(file *builder.File, cfg *otelcol.Config, labelPrefix string, extraConverters []ComponentConverter) diag.Diagnostics

AppendConfig converts the provided OpenTelemetry config into an equivalent Alloy config and appends the result to the provided file.

func Convert

func Convert(in []byte, extraArgs []string) ([]byte, diag.Diagnostics)

Convert implements an Opentelemetry Collector config converter.

For compatibility with other converters, the extraArgs paramater is defined but unused, and a critical error diagnostic is returned if extraArgs is non-empty.

func ConvertWithoutValidation

func ConvertWithoutValidation(in []byte, extraArgs []string) ([]byte, diag.Diagnostics)

ConvertWithoutValidation is similar to `otelcolconvert.go`'s Convert but without validating generated configs This is to help testing `sigv4authextension` converter as its Validate() method calls up external cloud service and we can't inject mock SigV4 credential provider since the attribute is set as internal in the upstream. Remove this once credentials provider is open for mocking.

func StringifyBlock

func StringifyBlock(block *builder.Block) string

func StringifyInstanceID

func StringifyInstanceID(id component.InstanceID) string

func StringifyKind

func StringifyKind(k component.Kind) string

func ToTokenizedConsumers

func ToTokenizedConsumers(components []componentID) []otelcol.Consumer

Types

type ComponentConverter

type ComponentConverter interface {
	// Factory should return the factory for the OpenTelemetry Collector
	// component.
	Factory() component.Factory

	// InputComponentName should return the name of the Alloy component where
	// other Alloy components forward OpenTelemetry data to.
	//
	// For example, a converter which emits a chain of components
	// (otelcol.receiver.prometheus -> prometheus.remote_write) should return
	// "otelcol.receiver.prometheus", which is the first component that receives
	// OpenTelemetry data in the chain.
	//
	// Converters which emit components that do not receive data from other
	// components must return an empty string.
	InputComponentName() string

	// ConvertAndAppend should convert the provided OpenTelemetry Collector
	// component configuration into Alloy configuration and append the result to
	// [state.Body]. Implementations are expected to append configuration where
	// all required arguments are set and all optional arguments are set to the
	// values from the input configuration or the Alloy default.
	//
	// ConvertAndAppend may be called more than once with the same component used
	// in different pipelines. Use [state.AlloyComponentLabel] to get a guaranteed
	// unique Alloy component label for the current state.
	ConvertAndAppend(state *State, id component.InstanceID, cfg component.Config) diag.Diagnostics
}

ComponentConverter represents a converter which converts an OpenTelemetry Collector component into an Alloy component.

type State

type State struct {
	// contains filtered or unexported fields
}

State represents the State of the conversion. The State tracks:

  • The OpenTelemetry Collector config being converted.
  • The current OpenTelemetry Collector pipelines being converted.
  • The current OpenTelemetry Collector component being converted.

func (*State) AlloyComponentLabel

func (state *State) AlloyComponentLabel() string

AlloyComponentLabel returns the unique Alloy label for the OpenTelemetry Component component being converted. It is safe to use this label to create multiple Alloy components in a chain.

func (*State) Body

func (state *State) Body() *builder.Body

Body returns the body of the file being generated. Implementations of [componentConverter] should use this to append components.

func (*State) LookupExtension

func (state *State) LookupExtension(id component.ID) componentID

func (*State) Next

func (state *State) Next(c component.InstanceID, dataType component.DataType) []componentID

Next returns the set of Alloy component IDs for a given data type that the current component being converted should forward data to.

Jump to

Keyboard shortcuts

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