Documentation ¶
Overview ¶
Package expr provides utilities for evaluating expressions against otel data structures.
Index ¶
- Constants
- func NewOTTLDatapointStatement(statementStr string, set component.TelemetrySettings) (*ottl.Statement[ottldatapoint.TransformContext], error)
- func NewOTTLLogRecordStatement(statementStr string, set component.TelemetrySettings) (*ottl.Statement[ottllog.TransformContext], error)
- func NewOTTLMetricStatement(statementStr string, set component.TelemetrySettings) (*ottl.Statement[ottlmetric.TransformContext], error)
- func NewOTTLSpanStatement(statementStr string, set component.TelemetrySettings) (*ottl.Statement[ottlspan.TransformContext], error)
- type Datapoint
- type DatapointResourceGroup
- type Expression
- func (e *Expression) Evaluate(env map[string]any) (any, error)
- func (e *Expression) ExtractFloat(record Record) (float64, error)
- func (e *Expression) ExtractInt(record Record) (int64, error)
- func (e *Expression) Match(env map[string]any) (bool, error)
- func (e *Expression) MatchRecord(record Record) bool
- type ExpressionMap
- type OTTLAttributeMap
- type OTTLCondition
- func NewOTTLDatapointCondition(condition string, set component.TelemetrySettings) (*OTTLCondition[ottldatapoint.TransformContext], error)
- func NewOTTLLogRecordCondition(condition string, set component.TelemetrySettings) (*OTTLCondition[ottllog.TransformContext], error)
- func NewOTTLMetricCondition(condition string, set component.TelemetrySettings) (*OTTLCondition[ottlmetric.TransformContext], error)
- func NewOTTLSpanCondition(condition string, set component.TelemetrySettings) (*OTTLCondition[ottlspan.TransformContext], error)
- type OTTLExpression
- func NewOTTLDatapointExpression(expression string, set component.TelemetrySettings) (*OTTLExpression[ottldatapoint.TransformContext], error)
- func NewOTTLLogRecordExpression(expression string, set component.TelemetrySettings) (*OTTLExpression[ottllog.TransformContext], error)
- func NewOTTLMetricExpression(expression string, set component.TelemetrySettings) (*OTTLExpression[ottlmetric.TransformContext], error)
- func NewOTTLSpanExpression(expression string, set component.TelemetrySettings) (*OTTLExpression[ottlspan.TransformContext], error)
- type Record
- type ResourceGroup
- type Span
- type SpanResourceGroup
Constants ¶
const ( MetricNameField = "metric_name" DatapointValueField = "datapoint_value" )
Metric specific fields for use in expressions
const ( // BodyField is the name of the field containing the log body. BodyField = "body" // ResourceField is the name of the field containing the resource attributes. ResourceField = "resource" // AttributesField is the name of the field containing the log attributes. AttributesField = "attributes" // SeverityEnumField is the name of the field containing the log severity enum. SeverityEnumField = "severity_enum" // SeverityNumberField is the name of the field containing the log severity number. SeverityNumberField = "severity_number" // TimestampField is the name of the field containing the log timestamp. TimestampField = "timestamp" )
const ( SpanKindField = "trace_kind" SpanStatusCodeField = "trace_status_code" SpanStatusMessageField = "trace_status_message" SpanDurationField = "span_duration_ms" )
Span specific fields for use in expressions
Variables ¶
This section is empty.
Functions ¶
func NewOTTLDatapointStatement ¶
func NewOTTLDatapointStatement(statementStr string, set component.TelemetrySettings) (*ottl.Statement[ottldatapoint.TransformContext], error)
NewOTTLDatapointStatement parses the given statement into an ottl.Statement for a datapoint transform context.
func NewOTTLLogRecordStatement ¶
func NewOTTLLogRecordStatement(statementStr string, set component.TelemetrySettings) (*ottl.Statement[ottllog.TransformContext], error)
NewOTTLLogRecordStatement parses the given statement into an ottl.Statement for a log transform context.
func NewOTTLMetricStatement ¶
func NewOTTLMetricStatement(statementStr string, set component.TelemetrySettings) (*ottl.Statement[ottlmetric.TransformContext], error)
NewOTTLMetricStatement parses the given statement into an ottl.Statement for a metric transform context.
func NewOTTLSpanStatement ¶
func NewOTTLSpanStatement(statementStr string, set component.TelemetrySettings) (*ottl.Statement[ottlspan.TransformContext], error)
NewOTTLSpanStatement parses the given statement into an ottl.Statement for a span transform context.
Types ¶
type DatapointResourceGroup ¶
DatapointResourceGroup represents a pmetric.ResourceMetrics as native go types
func ConvertToDatapointResourceGroup ¶
func ConvertToDatapointResourceGroup(metrics pmetric.Metrics) []DatapointResourceGroup
ConvertToDatapointResourceGroup converts a pmetric.Metrics into a slice of DatapointResourceGroup
type Expression ¶
Expression is an Expression used to evaluate values.
func CreateBoolExpression ¶
func CreateBoolExpression(str string) (*Expression, error)
CreateBoolExpression creates an expression from a string that returns a boolean.
func CreateExpression ¶
func CreateExpression(str string, opts ...expr.Option) (*Expression, error)
CreateExpression creates an expression from a string.
func CreateValueExpression ¶
func CreateValueExpression(str string) (*Expression, error)
CreateValueExpression creates an expression from a string that returns a value.
func (*Expression) Evaluate ¶
func (e *Expression) Evaluate(env map[string]any) (any, error)
Evaluate evaluates an expression against the supplied environment.
func (*Expression) ExtractFloat ¶
func (e *Expression) ExtractFloat(record Record) (float64, error)
ExtractFloat extracts a float from the record.
func (*Expression) ExtractInt ¶
func (e *Expression) ExtractInt(record Record) (int64, error)
ExtractInt extracts an integer from the record.
func (*Expression) Match ¶
func (e *Expression) Match(env map[string]any) (bool, error)
Match checks if an expression matches the supplied environment.
func (*Expression) MatchRecord ¶
func (e *Expression) MatchRecord(record Record) bool
MatchRecord checks if an expression matches the supplied record.
type ExpressionMap ¶
type ExpressionMap struct {
// contains filtered or unexported fields
}
ExpressionMap is a map of expressions.
func CreateExpressionMap ¶
func CreateExpressionMap(strMap map[string]string) (*ExpressionMap, error)
CreateExpressionMap creates an expression map from a string map.
type OTTLAttributeMap ¶
type OTTLAttributeMap[T any] struct { // contains filtered or unexported fields }
OTTLAttributeMap extracts attributes from telemetry using OTTL expressions. T is an ottl transform context.
func MakeOTTLAttributeMap ¶
func MakeOTTLAttributeMap[T any](m map[string]string, set component.TelemetrySettings, createFunc func(string, component.TelemetrySettings) (*OTTLExpression[T], error)) (*OTTLAttributeMap[T], error)
MakeOTTLAttributeMap compiles the expressions in the given map of attribute keys to ottl expression strings into an OTTLAttributeMap. createFunc is the function for creating the expression, see the NewOTTLxxxExpression functions in this package for functions that may be used here.
func (OTTLAttributeMap[T]) ExtractAttributes ¶
func (t OTTLAttributeMap[T]) ExtractAttributes(ctx context.Context, tCtx T) map[string]any
ExtractAttributes extracts the attributes using the passed in transform context.
type OTTLCondition ¶
type OTTLCondition[T any] struct { // contains filtered or unexported fields }
OTTLCondition evaluates an OTTL expression as a boolean value.
func NewOTTLDatapointCondition ¶
func NewOTTLDatapointCondition(condition string, set component.TelemetrySettings) (*OTTLCondition[ottldatapoint.TransformContext], error)
NewOTTLDatapointCondition creates a new OTTLCondition for a datapoint with the given condition.
func NewOTTLLogRecordCondition ¶
func NewOTTLLogRecordCondition(condition string, set component.TelemetrySettings) (*OTTLCondition[ottllog.TransformContext], error)
NewOTTLLogRecordCondition creates a new OTTLCondition for a log record with the given condition.
func NewOTTLMetricCondition ¶
func NewOTTLMetricCondition(condition string, set component.TelemetrySettings) (*OTTLCondition[ottlmetric.TransformContext], error)
NewOTTLMetricCondition creates a new OTTLCondition for a metric with the given condition.
func NewOTTLSpanCondition ¶
func NewOTTLSpanCondition(condition string, set component.TelemetrySettings) (*OTTLCondition[ottlspan.TransformContext], error)
NewOTTLSpanCondition creates a new OTTLCondition for a span with the given condition.
type OTTLExpression ¶
type OTTLExpression[T any] struct { // contains filtered or unexported fields }
OTTLExpression evaluates an OTTL expression, returning a resultant value.
func NewOTTLDatapointExpression ¶
func NewOTTLDatapointExpression(expression string, set component.TelemetrySettings) (*OTTLExpression[ottldatapoint.TransformContext], error)
NewOTTLDatapointExpression creates a new expression for datapoints. The expression is wrapped in an editor function, so only Converter functions and target expressions can be used.
func NewOTTLLogRecordExpression ¶
func NewOTTLLogRecordExpression(expression string, set component.TelemetrySettings) (*OTTLExpression[ottllog.TransformContext], error)
NewOTTLLogRecordExpression creates a new expression for log records. The expression is wrapped in an editor function, so only Converter functions and target expressions can be used.
func NewOTTLMetricExpression ¶
func NewOTTLMetricExpression(expression string, set component.TelemetrySettings) (*OTTLExpression[ottlmetric.TransformContext], error)
NewOTTLMetricExpression creates a new expression for metrics. The expression is wrapped in an editor function, so only Converter functions and target expressions can be used.
func NewOTTLSpanExpression ¶
func NewOTTLSpanExpression(expression string, set component.TelemetrySettings) (*OTTLExpression[ottlspan.TransformContext], error)
NewOTTLSpanExpression creates a new expression for spans. The expression is wrapped in an editor function, so only Converter functions and target expressions can be used.
type Record ¶
Record is the simplified representation of a log record.
func ConvertToRecord ¶
ConvertToRecord converts a log record to a simplified representation.
func ConvertToRecords ¶
ConvertToRecords converts plog.Logs to a slice of records.
type ResourceGroup ¶
ResourceGroup is a group of records with the same resource attributes.
func ConvertToResourceGroups ¶
func ConvertToResourceGroups(logs plog.Logs) []ResourceGroup
ConvertToResourceGroups converts plog.Logs to a slice of resource groups.
type SpanResourceGroup ¶
SpanResourceGroup represents a ptrace.ResourceSpans as native go types
func ConvertToSpanResourceGroups ¶
func ConvertToSpanResourceGroups(traces ptrace.Traces) []SpanResourceGroup
ConvertToSpanResourceGroups converts a ptrace.Traces into a slice of SpanResourceGroup