common

package
v1.300047.0 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AgentKey                           = "agent"
	DebugKey                           = "debug"
	MetricsKey                         = "metrics"
	LogsKey                            = "logs"
	TracesKey                          = "traces"
	MetricsCollectedKey                = "metrics_collected"
	LogsCollectedKey                   = "logs_collected"
	TracesCollectedKey                 = "traces_collected"
	ECSKey                             = "ecs"
	KubernetesKey                      = "kubernetes"
	PrometheusKey                      = "prometheus"
	EMFProcessorKey                    = "emf_processor"
	DisableMetricExtraction            = "disable_metric_extraction"
	XrayKey                            = "xray"
	OtlpKey                            = "otlp"
	JmxKey                             = "jmx"
	TLSKey                             = "tls"
	Endpoint                           = "endpoint"
	EndpointOverrideKey                = "endpoint_override"
	RegionOverrideKey                  = "region_override"
	ProxyOverrideKey                   = "proxy_override"
	InsecureKey                        = "insecure"
	LocalModeKey                       = "local_mode"
	CredentialsKey                     = "credentials"
	RoleARNKey                         = "role_arn"
	MetricsCollectionIntervalKey       = "metrics_collection_interval"
	MeasurementKey                     = "measurement"
	DropOriginalMetricsKey             = "drop_original_metrics"
	ForceFlushIntervalKey              = "force_flush_interval"
	ContainerInsightsMetricGranularity = "metric_granularity" // replaced with enhanced_container_insights
	EnhancedContainerInsights          = "enhanced_container_insights"
	PreferFullPodName                  = "prefer_full_pod_name"
	EnableAcceleratedComputeMetric     = "accelerated_compute_metrics"
	AppendDimensionsKey                = "append_dimensions"
	Console                            = "console"
	DiskKey                            = "disk"
	DiskIOKey                          = "diskio"
	NetKey                             = "net"
	Emf                                = "emf"
	StructuredLog                      = "structuredlog"
	ServiceAddress                     = "service_address"
	Udp                                = "udp"
	Tcp                                = "tcp"
	Region                             = "region"
	LogGroupName                       = "log_group_name"
	LogStreamName                      = "log_stream_name"
	NameKey                            = "name"
	RenameKey                          = "rename"
	UnitKey                            = "unit"
)
View Source
const (
	PipelineNameHost             = "host"
	PipelineNameHostDeltaMetrics = "hostDeltaMetrics"
	PipelineNameJmx              = "jmx"
	PipelineNameEmfLogs          = "emf_logs"
	AppSignals                   = "application_signals"
	AppSignalsFallback           = "app_signals"
	AppSignalsRules              = "rules"
)
View Source
const KubernetesEnvVar = "K8S_NAMESPACE"

Variables

View Source
var (
	AppSignalsTraces          = ConfigKey(TracesKey, TracesCollectedKey, AppSignals)
	AppSignalsMetrics         = ConfigKey(LogsKey, MetricsCollectedKey, AppSignals)
	AppSignalsTracesFallback  = ConfigKey(TracesKey, TracesCollectedKey, AppSignalsFallback)
	AppSignalsMetricsFallback = ConfigKey(LogsKey, MetricsCollectedKey, AppSignalsFallback)

	AppSignalsConfigKeys = map[component.DataType][]string{
		component.DataTypeTraces:  {AppSignalsTraces, AppSignalsTracesFallback},
		component.DataTypeMetrics: {AppSignalsMetrics, AppSignalsMetricsFallback},
	}
	JmxConfigKey = ConfigKey(MetricsKey, MetricsCollectedKey, JmxKey)
	JmxTargets   = []string{"activemq", "cassandra", "hbase", "hadoop", "jetty", "jvm", "kafka", "kafka-consumer", "kafka-producer", "solr", "tomcat", "wildfly"}

	AgentDebugConfigKey = ConfigKey(AgentKey, DebugKey)
)

Functions

func ConfigKey

func ConfigKey(keys ...string) string

ConfigKey joins the keys separated by confmap.KeyDelimiter. This helps translators navigate the confmap.Conf that the JSON config is loaded into.

func GetArray

func GetArray[C any](conf *confmap.Conf, key string) []C

GetArray gets the array value for the key. If the key is missing, the return value will be nil

func GetBool

func GetBool(conf *confmap.Conf, key string) (value bool, ok bool)

GetBool gets the bool value for the key. If the key is missing or the value is not a bool type, then ok will be false.

func GetDuration

func GetDuration(conf *confmap.Conf, key string) (time.Duration, bool)

GetDuration gets the value for the key and calls ParseDuration on it. If the key is missing, it is unable to parse the duration, or the duration is set to 0, then the returned bool will be false.

func GetIndexedMap added in v1.300041.0

func GetIndexedMap(conf *confmap.Conf, configKey string, index int) map[string]any

GetIndexedMap gets the sub map based on the config key and index. If the config value is an array, then the value at the index is returned. If it is a map, then the index is ignored and the map is returned directly.

func GetMeasurements added in v1.300041.0

func GetMeasurements(m map[string]any) []string

GetMeasurements gets the string values in the measurements section of the provided map. If there are metric decoration elements, includes the value associated with the "name" key.

func GetNumber

func GetNumber(conf *confmap.Conf, key string) (float64, bool)

GetNumber gets the number value for the key. The switch works through all reasonable number types (the default is typically float64)

func GetOrDefaultBool

func GetOrDefaultBool(conf *confmap.Conf, key string, defaultVal bool) bool

GetOrDefaultBool gets the bool value for the key. If the key is missing or the value is not a bool type, then the defaultVal is returned.

func GetOrDefaultDuration

func GetOrDefaultDuration(conf *confmap.Conf, keychain []string, defaultDuration time.Duration) time.Duration

GetOrDefaultDuration from the first section in the keychain with a parsable duration. If none are found, returns the defaultDuration.

func GetOrDefaultNumber

func GetOrDefaultNumber(conf *confmap.Conf, key string, defaultVal float64) float64

GetOrDefaultNumber gets the number value for the key. If the key is missing or the value is not a number type, then the defaultVal is returned.

func GetString

func GetString(conf *confmap.Conf, key string) (string, bool)

GetString gets the string value for the key. If the key is missing, ok will be false.

func GetYamlFileToYamlConfig added in v1.300031.0

func GetYamlFileToYamlConfig(cfg interface{}, yamlFile string) (interface{}, error)

func IsAnySet added in v1.300043.0

func IsAnySet(conf *confmap.Conf, keys []string) bool

IsAnySet checks if any of the provided keys are present in the configuration.

func IsAppSignalsKubernetes added in v1.300031.0

func IsAppSignalsKubernetes() bool

func ParseDuration

func ParseDuration(v interface{}) (time.Duration, error)

ParseDuration attempts to parse the input into a duration. Returns a zero duration and an error if invalid.

Types

type ComponentTranslators

type ComponentTranslators struct {
	Receivers  TranslatorMap[component.Config]
	Processors TranslatorMap[component.Config]
	Exporters  TranslatorMap[component.Config]
	Extensions TranslatorMap[component.Config]
}

ComponentTranslators is a component ID and respective service pipeline.

type MissingKeyError

type MissingKeyError struct {
	ID      component.ID
	JsonKey string
}

A MissingKeyError occurs when a translator is used for a JSON config that does not have a required key. This typically means that the pipeline was configured incorrectly.

func (*MissingKeyError) Error

func (e *MissingKeyError) Error() string

type NameProvider added in v1.300043.0

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

func (*NameProvider) Name added in v1.300043.0

func (p *NameProvider) Name() string

func (*NameProvider) SetName added in v1.300043.0

func (p *NameProvider) SetName(name string)

type NameSetter added in v1.300043.0

type NameSetter interface {
	SetName(string)
}

type Translator

type Translator[C any] interface {
	Translate(*confmap.Conf) (C, error)
	ID() component.ID
}

Translator is used to translate the JSON config into an OTEL config.

type TranslatorMap

type TranslatorMap[C any] interface {
	// Set a translator to the map. If the ID is already present, replaces the translator.
	// Otherwise, adds it to the end of the list.
	Set(Translator[C])
	// Get the translator for the component.ID.
	Get(component.ID) (Translator[C], bool)
	// Merge another translator map in.
	Merge(TranslatorMap[C])
	// Keys is the ordered component.IDs.
	Keys() []component.ID
	// Range iterates over each translator in order and calls the callback function on each.
	Range(func(Translator[C]))
	// Len is the number of translators in the map.
	Len() int
}

TranslatorMap is a set of translators by their types.

func NewTranslatorMap

func NewTranslatorMap[C any](translators ...Translator[C]) TranslatorMap[C]

NewTranslatorMap creates a TranslatorMap from the translators.

type TranslatorOption added in v1.300043.0

type TranslatorOption func(any)

func WithName added in v1.300043.0

func WithName(name string) TranslatorOption

Jump to

Keyboard shortcuts

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