ottl

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2025 License: Apache-2.0 Imports: 34 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FingerprintTags

func FingerprintTags(tags map[string]string) uint64

func GetServiceName

func GetServiceName(resource pcommon.Resource) string

func MergeWith

func MergeWith(this *transformations, other *transformations) *transformations

func NewRPSSampler

func NewRPSSampler(ops ...Option) *rpsSampler

func NewTransformations

func NewTransformations() *transformations

func ParseTransformations

func ParseTransformations(logger *zap.Logger, statements []ContextStatement) (*transformations, error)

func SplitTag

func SplitTag(tag string) (scope string, name string)

func ToFactory

func ToFactory[T any]() map[string]ottl.Factory[T]

Types

type Aggregation

type Aggregation interface {
	Add(name string, values []float64) error
	Value() []float64
	Count() uint64
	Tags() map[string]string
	Buckets() []float64
}

type AggregationImpl

type AggregationImpl[T int64 | float64] struct {
	// contains filtered or unexported fields
}

func NewAggregationImpl

func NewAggregationImpl[T int64 | float64](name string, buckets []T, aggregationType AggregationType, tags map[string]string) *AggregationImpl[T]

func (*AggregationImpl[T]) Add

func (a *AggregationImpl[T]) Add(name string, values []T) error

func (*AggregationImpl[T]) AggregationType

func (a *AggregationImpl[T]) AggregationType() AggregationType

func (*AggregationImpl[T]) Buckets

func (a *AggregationImpl[T]) Buckets() []T

func (*AggregationImpl[T]) Count

func (a *AggregationImpl[T]) Count() uint64

func (*AggregationImpl[T]) Name

func (a *AggregationImpl[T]) Name() string

func (*AggregationImpl[T]) Tags

func (a *AggregationImpl[T]) Tags() map[string]string

func (*AggregationImpl[T]) Value

func (a *AggregationImpl[T]) Value() []T

type AggregationSet

type AggregationSet[T int64 | float64] struct {
	Aggregations map[uint64]*AggregationImpl[T]
	StartTime    int64
	Interval     int64
}

func NewAggregationSet

func NewAggregationSet[T int64 | float64](starttime int64, interval int64) *AggregationSet[T]

func (*AggregationSet[T]) Add

func (a *AggregationSet[T]) Add(logger *zap.Logger, name string, buckets []T, values []T, aggregationType AggregationType, tags map[string]string) error

func (*AggregationSet[T]) GetAggregations

func (a *AggregationSet[T]) GetAggregations() map[uint64]*AggregationImpl[T]

type AggregationType

type AggregationType int
const (
	AggregationTypeSum AggregationType = iota
	AggregationTypeAvg
)

func (AggregationType) String

func (a AggregationType) String() string

type ConfigManager

type ConfigManager interface {
	RegisterCallback(name string, callback ConfigUpdateCallbackFunc) int
	UnregisterCallback(id int)
	Run()
	Stop()
}

type ConfigManagerImpl

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

func NewConfigManagerImpl

func NewConfigManagerImpl(logger *zap.Logger, CheckInterval time.Duration, fr filereader.FileReader) *ConfigManagerImpl

func (*ConfigManagerImpl) RegisterCallback

func (c *ConfigManagerImpl) RegisterCallback(name string, callback ConfigUpdateCallbackFunc) int

func (*ConfigManagerImpl) Run

func (c *ConfigManagerImpl) Run()

func (*ConfigManagerImpl) Stop

func (c *ConfigManagerImpl) Stop()

func (*ConfigManagerImpl) UnregisterCallback

func (c *ConfigManagerImpl) UnregisterCallback(id int)

type ConfigUpdateCallbackFunc

type ConfigUpdateCallbackFunc func(config ControlPlaneConfig)

type ContextID

type ContextID string

type ContextStatement

type ContextStatement struct {
	Context        ContextID      `json:"context,omitempty" yaml:"context,omitempty"`
	RuleId         RuleID         `json:"rule_id,omitempty" yaml:"rule_id,omitempty"`
	Priority       int            `json:"priority,omitempty" yaml:"priority,omitempty"`
	Conditions     []string       `json:"conditions,omitempty" yaml:"conditions,omitempty"`
	Statements     []string       `json:"statements,omitempty" yaml:"statements,omitempty"`
	SamplingConfig SamplingConfig `json:"sampling_config,omitempty" yaml:"sampling_config,omitempty"`
	Version        int            `json:"version,omitempty" yaml:"version,omitempty"`
}

type ControlPlaneConfig

type ControlPlaneConfig struct {
	// Processor targets
	Pitbulls          map[string]*PitbullProcessorConfig        `json:"pitbulls,omitempty" yaml:"pitbulls,omitempty"`
	Stats             map[string]*StatsProcessorConfig          `json:"stats,omitempty" yaml:"stats,omitempty"`
	ExtractMetrics    map[string]*ExtractMetricsProcessorConfig `json:"extract_metrics,omitempty" yaml:"extract_metrics,omitempty"`
	FingerprintConfig FingerprintConfig                         `json:"fingerprint_config,omitempty" yaml:"fingerprint_config,omitempty"`
	// contains filtered or unexported fields
}

type EventSamplingRuleType

type EventSamplingRuleType int
const (
	EventSamplingRuleTypeUnknown EventSamplingRuleType = iota
	EventSamplingRuleTypeRandom
	EventSamplingRuleTypeRPS
)

type ExtractMetricsProcessorConfig

type ExtractMetricsProcessorConfig struct {
	LogMetricExtractors  []MetricExtractorConfig `json:"log_metric_extractors,omitempty" yaml:"log_metric_extractors,omitempty"`
	SpanMetricExtractors []MetricExtractorConfig `json:"span_metric_extractors,omitempty" yaml:"span_metric_extractors,omitempty"`
}

type FingerprintConfig added in v0.7.0

type FingerprintConfig struct {
	LogMappings []FingerprintMapping `json:"log_mappings,omitempty" yaml:"log_mappings,omitempty"`
}

type FingerprintMapping added in v0.7.0

type FingerprintMapping struct {
	Primary int64   `json:"primary,omitempty" yaml:"primary,omitempty"`
	Aliases []int64 `json:"aliases,omitempty" yaml:"aliases,omitempty"`
}

type Instruction

type Instruction struct {
	Statements []ContextStatement `json:"statements,omitempty" yaml:"statements,omitempty"`
}

type LogExtractor

type LogExtractor struct {
	Conditions  []*ottl.Condition[ottllog.TransformContext]
	Dimensions  map[string]*ottl.Statement[ottllog.TransformContext]
	MetricName  string
	RuleID      string
	MetricUnit  string
	MetricType  string
	MetricValue *ottl.Statement[ottllog.TransformContext]
}

func ParseLogExtractorConfigs

func ParseLogExtractorConfigs(extractorConfigs []MetricExtractorConfig, logger *zap.Logger) ([]*LogExtractor, error)

func (LogExtractor) EvalLogConditions

func (l LogExtractor) EvalLogConditions(ctx context.Context, transformCtx ottllog.TransformContext) (bool, error)

func (LogExtractor) ExtractAttributes

func (l LogExtractor) ExtractAttributes(ctx context.Context, tCtx ottllog.TransformContext) map[string]any

type LookupConfig

type LookupConfig struct {
	TableName   string        `json:"table_name,omitempty" yaml:"table_name,omitempty"`
	LookupTable LookupTable   `json:"lookup_table,omitempty" yaml:"lookup_table,omitempty"`
	LogRules    []*LookupRule `json:"log_rules,omitempty" yaml:"log_rules,omitempty"`
	SpanRules   []*LookupRule `json:"span_rules,omitempty" yaml:"span_rules,omitempty"`
	MetricRules []*LookupRule `json:"metric_rules,omitempty" yaml:"metric_rules,omitempty"`
}

func (*LookupConfig) ExecuteLogsRules

func (lc *LookupConfig) ExecuteLogsRules(ctx context.Context, tCtx ottllog.TransformContext, record plog.LogRecord)

ExecuteLogsRules executes the log rules for the given record

func (*LookupConfig) ExecuteMetricsRules

func (lc *LookupConfig) ExecuteMetricsRules(ctx context.Context, tCtx ottldatapoint.TransformContext, handlerFunc func(tagToSet string, targetValue string))

ExecuteMetricsRules executes the metrics rules for the given record

func (*LookupConfig) ExecuteSpansRules

func (lc *LookupConfig) ExecuteSpansRules(ctx context.Context, tCtx ottlspan.TransformContext, record ptrace.Span)

ExecuteSpansRules executes the span rules for the given record

func (*LookupConfig) Init

func (lc *LookupConfig) Init(logger *zap.Logger)

type LookupKey

type LookupKey struct {
	ColumnName string `json:"column_name,omitempty" yaml:"column_name,omitempty"`
	Expression string `json:"expression,omitempty" yaml:"expression,omitempty"`
	// contains filtered or unexported fields
}

LookupKey represents a condition to be matched in the lookup table. So for example, go get the value of ColumnName = serviceName (derived by executing the OTTLExpression say: resource.attributes["service.name"]) = service1 Now find the record in the lookup table where serviceName = service1.

type LookupRule

type LookupRule struct {
	FieldNamesToSet []string     `json:"field_names_to_set,omitempty" yaml:"field_names_to_set,omitempty"`
	Keys            []*LookupKey `json:"keys,omitempty" yaml:"keys,omitempty"`
	// contains filtered or unexported fields
}

type LookupTable

type LookupTable []map[string]string

func (LookupTable) Transpose

func (lt LookupTable) Transpose(conditionColumns []string) *transposedLookupTable

Transpose dynamically converts a regular LookupTable into a TransposedLookupTable using the provided condition columns

type MetricAggregator

type MetricAggregator[T int64 | float64] interface {
	Emit(now time.Time) map[int64]*AggregationSet[T]
	MatchAndAdd(logger *zap.Logger, t *time.Time, buckets []T, value []T, aggregationType AggregationType, name string, metadata map[string]string, rattr pcommon.Map, iattr pcommon.Map, mattr pcommon.Map) (bool, error)
}

type MetricAggregatorImpl

type MetricAggregatorImpl[T int64 | float64] struct {
	// contains filtered or unexported fields
}

func NewMetricAggregatorImpl

func NewMetricAggregatorImpl[T int64 | float64](interval int64) *MetricAggregatorImpl[T]

func (*MetricAggregatorImpl[T]) Emit

func (m *MetricAggregatorImpl[T]) Emit(now time.Time) map[int64]*AggregationSet[T]

func (*MetricAggregatorImpl[T]) MatchAndAdd

func (m *MetricAggregatorImpl[T]) MatchAndAdd(logger *zap.Logger, t *time.Time, buckets []T, values []T, aggregationType AggregationType, name string, metadata map[string]string, rattr pcommon.Map, iattr pcommon.Map, mattr pcommon.Map) (bool, error)

type MetricExtractorConfig

type MetricExtractorConfig struct {
	RuleId      string            `json:"rule_id,omitempty" yaml:"rule_id,omitempty"`
	Conditions  []string          `json:"conditions,omitempty" yaml:"conditions,omitempty"`
	Dimensions  map[string]string `json:"dimensions,omitempty" yaml:"dimensions,omitempty"`
	MetricName  string            `json:"metric_name,omitempty" yaml:"metric_name,omitempty"`
	MetricUnit  string            `json:"metric_unit,omitempty" yaml:"metric_unit,omitempty"`
	MetricType  string            `json:"metric_type,omitempty" yaml:"metric_type,omitempty"`
	MetricValue string            `json:"metric_value,omitempty" yaml:"metric_value,omitempty"`
	Version     int               `json:"version,omitempty" yaml:"version,omitempty"`
}

type Option

type Option func(*rpsSampler)

func WithClearFrequencyDuration

func WithClearFrequencyDuration(d time.Duration) Option

func WithLogger

func WithLogger(logger *zap.Logger) Option

func WithMaxKeys

func WithMaxKeys(maxKeys int) Option

func WithMaxRPS

func WithMaxRPS(minEventsPerSec int) Option

type PitbullProcessorConfig

type PitbullProcessorConfig struct {
	LogStatements       []ContextStatement `json:"log_statements,omitempty" yaml:"log_statements,omitempty"`
	LogLookupConfigs    []LookupConfig     `json:"log_lookup_configs,omitempty" yaml:"log_lookup_configs,omitempty"`
	MetricStatements    []ContextStatement `json:"metric_statements,omitempty" yaml:"metric_statements,omitempty"`
	MetricLookupConfigs []LookupConfig     `json:"metric_lookup_configs,omitempty" yaml:"metric_lookup_configs,omitempty"`
	SpanStatements      []ContextStatement `json:"span_statements,omitempty" yaml:"span_statements,omitempty"`
	SpanLookupConfigs   []LookupConfig     `json:"span_lookup_configs,omitempty" yaml:"span_lookup_configs,omitempty"`
}

type RuleID

type RuleID string

type Sampler

type Sampler interface {
	// Start starts the sampler
	Start() error
	// Stop stops the sampler
	Stop() error
	// GetSampleRate returns the sample rate for a given key
	GetSampleRate(key string) int
	// GetSampleRateMulti returns the sample rate for a given key with a count
	GetSampleRateMulti(key string, count int) int
}

type SamplingConfig

type SamplingConfig struct {
	SampleRate float64 `json:"sample_rate,omitempty" yaml:"sample_rate,omitempty"`
	RPS        int     `json:"rps,omitempty" yaml:"rps,omitempty"`
}

type SpanExtractor

type SpanExtractor struct {
	RuleID      string
	Conditions  []*ottl.Condition[ottlspan.TransformContext]
	Dimensions  map[string]*ottl.Statement[ottlspan.TransformContext]
	MetricName  string
	MetricUnit  string
	MetricType  string
	MetricValue *ottl.Statement[ottlspan.TransformContext]
}

func ParseSpanExtractorConfigs

func ParseSpanExtractorConfigs(extractorConfigs []MetricExtractorConfig, logger *zap.Logger) ([]*SpanExtractor, error)

func (SpanExtractor) EvalSpanConditions

func (l SpanExtractor) EvalSpanConditions(ctx context.Context, transformCtx ottlspan.TransformContext) (bool, error)

func (SpanExtractor) ExtractAttributes

func (s SpanExtractor) ExtractAttributes(ctx context.Context, tCtx ottlspan.TransformContext) map[string]any

type StaticSampler

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

func NewStaticSampler

func NewStaticSampler(rate int) *StaticSampler

func (*StaticSampler) GetSampleRate

func (s *StaticSampler) GetSampleRate(_ string) int

func (*StaticSampler) GetSampleRateMulti

func (s *StaticSampler) GetSampleRateMulti(_ string, _ int) int

func (*StaticSampler) Start

func (s *StaticSampler) Start() error

func (*StaticSampler) Stop

func (s *StaticSampler) Stop() error

type StatsEnrichment

type StatsEnrichment struct {
	Context string   `json:"context,omitempty" yaml:"context,omitempty"`
	Tags    []string `json:"tags,omitempty" yaml:"tags,omitempty"`
}

type StatsProcessorConfig

type StatsProcessorConfig struct {
	LogEnrichments    []StatsEnrichment `json:"log_enrichments,omitempty" yaml:"log_enrichments,omitempty"`
	MetricEnrichments []StatsEnrichment `json:"metric_enrichments,omitempty" yaml:"metric_enrichments,omitempty"`
	SpanEnrichments   []StatsEnrichment `json:"span_enrichments,omitempty" yaml:"span_enrichments,omitempty"`
}

type Transformations

type Transformations = transformations

type Versioned added in v0.0.5

type Versioned interface {
	GetVersion() int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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