Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ottl] Demonstrate simpler context constructors #36188

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pkg/ottl/contexts/ottldatapoint/datapoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ func (tCtx TransformContext) MarshalLogObject(encoder zapcore.ObjectEncoder) err

type Option func(*ottl.Parser[TransformContext])

func NewTransformContextSimple(dataPoint any, metric pmetric.Metric, scopeMetrics pmetric.ScopeMetrics, resourceMetrics pmetric.ResourceMetrics) TransformContext {
return NewTransformContext(dataPoint, metric, scopeMetrics.Metrics(), scopeMetrics.Scope(), resourceMetrics.Resource(), scopeMetrics, resourceMetrics)
}

// Deprecated: Use NewTransformContextSimple instead.
func NewTransformContext(dataPoint any, metric pmetric.Metric, metrics pmetric.MetricSlice, instrumentationScope pcommon.InstrumentationScope, resource pcommon.Resource, scopeMetrics pmetric.ScopeMetrics, resourceMetrics pmetric.ResourceMetrics) TransformContext {
return TransformContext{
dataPoint: dataPoint,
Expand Down
5 changes: 5 additions & 0 deletions pkg/ottl/contexts/ottllog/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ func (tCtx TransformContext) MarshalLogObject(encoder zapcore.ObjectEncoder) err

type Option func(*ottl.Parser[TransformContext])

func NewTransformContextSimple(logRecord plog.LogRecord, scopeLogs plog.ScopeLogs, resourceLogs plog.ResourceLogs) TransformContext {
return NewTransformContext(logRecord, scopeLogs.Scope(), resourceLogs.Resource(), scopeLogs, resourceLogs)
}

// Deprecated: Use NewTransformContextSimple instead.
func NewTransformContext(logRecord plog.LogRecord, instrumentationScope pcommon.InstrumentationScope, resource pcommon.Resource, scopeLogs plog.ScopeLogs, resourceLogs plog.ResourceLogs) TransformContext {
return TransformContext{
logRecord: logRecord,
Expand Down
5 changes: 5 additions & 0 deletions pkg/ottl/contexts/ottlmetric/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ type TransformContext struct {

type Option func(*ottl.Parser[TransformContext])

func NewTransformContextSimple(metric pmetric.Metric, scopeMetrics pmetric.ScopeMetrics, resourceMetrics pmetric.ResourceMetrics) TransformContext {
return NewTransformContext(metric, scopeMetrics.Metrics(), scopeMetrics.Scope(), resourceMetrics.Resource(), scopeMetrics, resourceMetrics)
}

// Deprecated: Use NewTransformContextSimple instead.
func NewTransformContext(metric pmetric.Metric, metrics pmetric.MetricSlice, instrumentationScope pcommon.InstrumentationScope, resource pcommon.Resource, scopeMetrics pmetric.ScopeMetrics, resourceMetrics pmetric.ResourceMetrics) TransformContext {
return TransformContext{
metric: metric,
Expand Down
5 changes: 5 additions & 0 deletions pkg/ottl/contexts/ottlspan/span.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ func (tCtx TransformContext) MarshalLogObject(encoder zapcore.ObjectEncoder) err

type Option func(*ottl.Parser[TransformContext])

func NewTransformContextSimple(span ptrace.Span, scopeSpans ptrace.ScopeSpans, resourceSpans ptrace.ResourceSpans) TransformContext {
return NewTransformContext(span, scopeSpans.Scope(), resourceSpans.Resource(), scopeSpans, resourceSpans)
}

// Deprecated: Use NewTransformContextSimple instead.
func NewTransformContext(span ptrace.Span, instrumentationScope pcommon.InstrumentationScope, resource pcommon.Resource, scopeSpans ptrace.ScopeSpans, resourceSpans ptrace.ResourceSpans) TransformContext {
return TransformContext{
span: span,
Expand Down
5 changes: 5 additions & 0 deletions pkg/ottl/contexts/ottlspanevent/span_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ func (tCtx TransformContext) MarshalLogObject(encoder zapcore.ObjectEncoder) err

type Option func(*ottl.Parser[TransformContext])

func NewTransformContextSimple(spanEvent ptrace.SpanEvent, span ptrace.Span, scopeSpans ptrace.ScopeSpans, resourceSpans ptrace.ResourceSpans) TransformContext {
return NewTransformContext(spanEvent, span, scopeSpans.Scope(), resourceSpans.Resource(), scopeSpans, resourceSpans)
}

// Deprecated: Use NewTransformContextSimple instead.
func NewTransformContext(spanEvent ptrace.SpanEvent, span ptrace.Span, instrumentationScope pcommon.InstrumentationScope, resource pcommon.Resource, scopeSpans ptrace.ScopeSpans, resourceSpans ptrace.ResourceSpans) TransformContext {
return TransformContext{
spanEvent: spanEvent,
Expand Down
Loading