Skip to content

Commit

Permalink
Fix the factory name for the limit function
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikołaj Świątek committed May 15, 2023
1 parent d67cbca commit 1ee3ab3
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 1 deletion.
16 changes: 16 additions & 0 deletions .chloggen/fix_ottl_limit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: bug_fix

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: pkg/ottl

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Fix the factory name for the limit function

# One or more tracking issues related to the change
issues: [21920]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:
2 changes: 1 addition & 1 deletion pkg/ottl/ottlfuncs/func_limit.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type LimitArguments[K any] struct {
}

func NewLimitFactory[K any]() ottl.Factory[K] {
return ottl.NewFactory("Limit", &LimitArguments[K]{}, createLimitFunction[K])
return ottl.NewFactory("limit", &LimitArguments[K]{}, createLimitFunction[K])
}

func createLimitFunction[K any](_ ottl.FunctionContext, oArgs ottl.Arguments) (ottl.ExprFunc[K], error) {
Expand Down
6 changes: 6 additions & 0 deletions processor/transformprocessor/internal/logs/processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,12 @@ func Test_ProcessLogs_LogContext(t *testing.T) {
td.ResourceLogs().At(0).ScopeLogs().At(0).LogRecords().At(0).Attributes().PutStr("json_test", "pass")
},
},
{
statement: `limit(attributes, 0, []) where body == "operationA"`,
want: func(td plog.Logs) {
td.ResourceLogs().At(0).ScopeLogs().At(0).LogRecords().At(0).Attributes().RemoveIf(func(s string, v pcommon.Value) bool { return true })
},
},
}

for _, tt := range tests {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,13 @@ func Test_ProcessMetrics_DataPointContext(t *testing.T) {
td.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(0).Sum().DataPoints().At(1).Attributes().PutStr("json_test", "pass")
},
},
{
statements: []string{`limit(attributes, 0, []) where metric.name == "operationA"`},
want: func(td pmetric.Metrics) {
td.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(0).Sum().DataPoints().At(0).Attributes().RemoveIf(func(s string, v pcommon.Value) bool { return true })
td.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(0).Sum().DataPoints().At(1).Attributes().RemoveIf(func(s string, v pcommon.Value) bool { return true })
},
},
}

for _, tt := range tests {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,12 @@ func Test_ProcessTraces_TraceContext(t *testing.T) {
td.ResourceSpans().At(0).ScopeSpans().At(0).Spans().At(0).Attributes().PutStr("json_test", "pass")
},
},
{
statement: `limit(attributes, 0, []) where name == "operationA"`,
want: func(td ptrace.Traces) {
td.ResourceSpans().At(0).ScopeSpans().At(0).Spans().At(0).Attributes().RemoveIf(func(s string, v pcommon.Value) bool { return true })
},
},
}

for _, tt := range tests {
Expand Down

0 comments on commit 1ee3ab3

Please sign in to comment.