Skip to content

Commit 449bfda

Browse files
authored
[chore][pkg/ottl] run make modernize (open-telemetry#44621)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description Run the `make modernize` tool. https://pkg.go.dev/golang.org/x/tools/gopls/internal/analysis/modernize This is part of the process to enable the [modernize](open-telemetry#44199) linter in CI. There are no changes in the component behaviour. Signed-off-by: Paulo Dias <[email protected]>
1 parent 781c48c commit 449bfda

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

pkg/ottl/ottlfuncs/func_parse_severity.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"context"
88
"errors"
99
"fmt"
10+
"slices"
1011

1112
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl"
1213
)
@@ -145,10 +146,8 @@ type valueRange struct {
145146
func (c *criteria) evaluate(value any) (bool, error) {
146147
switch v := value.(type) {
147148
case string:
148-
for _, eq := range c.Equals {
149-
if v == eq {
150-
return true, nil
151-
}
149+
if slices.Contains(c.Equals, v) {
150+
return true, nil
152151
}
153152
return false, nil
154153
case int64:

pkg/ottl/performance_bench_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ func BenchmarkConditionSequenceEvalMetrics(b *testing.B) {
328328

329329
func buildMetricStatements(count int) []string {
330330
result := make([]string, 0, count)
331-
for i := 0; i < count; i++ {
331+
for i := range count {
332332
switch i % 5 {
333333
case 0:
334334
result = append(result, fmt.Sprintf(`set(metric.metadata["copy_source_%[1]d"], metric.metadata["source_%[1]d"])`, i))
@@ -347,7 +347,7 @@ func buildMetricStatements(count int) []string {
347347

348348
func buildMetricConditions(count int) []string {
349349
result := make([]string, 0, count)
350-
for i := 0; i < count; i++ {
350+
for i := range count {
351351
switch i % 5 {
352352
case 0:
353353
result = append(result, "metric.type == METRIC_DATA_TYPE_SUM")
@@ -400,7 +400,7 @@ func newBenchmarkMetricContext(attributeCount int) ottlmetric.TransformContext {
400400
dp.Attributes().PutStr("method", "GET")
401401
dp.SetIntValue(4200)
402402

403-
for i := 0; i < attributeCount; i++ {
403+
for i := range attributeCount {
404404
metric.Metadata().PutStr(fmt.Sprintf("source_%d", i), fmt.Sprintf("value_%d", i))
405405
dp.Attributes().PutStr(fmt.Sprintf("label_%d", i), fmt.Sprintf("value_%d", i))
406406
}
@@ -410,7 +410,7 @@ func newBenchmarkMetricContext(attributeCount int) ottlmetric.TransformContext {
410410

411411
func buildLogStatements(count int) []string {
412412
result := make([]string, 0, count)
413-
for i := 0; i < count; i++ {
413+
for i := range count {
414414
switch i % 5 {
415415
case 0:
416416
result = append(result, fmt.Sprintf(`set(log.attributes["conditional_copy_%[1]d"], log.attributes["source_%[1]d"]) where log.attributes["severity_text"] == "error"`, i))
@@ -429,7 +429,7 @@ func buildLogStatements(count int) []string {
429429

430430
func buildSpanStatements(count int) []string {
431431
result := make([]string, 0, count)
432-
for i := 0; i < count; i++ {
432+
for i := range count {
433433
switch i % 4 {
434434
case 0:
435435
result = append(result, fmt.Sprintf(`set(span.attributes["span_copy_%[1]d"], span.attributes["source_%[1]d"]) where span.kind.string == "SPAN_KIND_CLIENT"`, i))
@@ -446,7 +446,7 @@ func buildSpanStatements(count int) []string {
446446

447447
func buildLogConditions(count int) []string {
448448
result := make([]string, 0, count)
449-
for i := 0; i < count; i++ {
449+
for i := range count {
450450
switch i % 3 {
451451
case 0:
452452
result = append(result, fmt.Sprintf(`log.attributes["source_%[1]d"] != nil`, i))
@@ -481,7 +481,7 @@ func newBenchmarkLogContext(attributeCount int) ottllog.TransformContext {
481481
tags.AppendEmpty().SetStr("prod")
482482
tags.AppendEmpty().SetStr("critical")
483483

484-
for i := 0; i < attributeCount; i++ {
484+
for i := range attributeCount {
485485
logRecord.Attributes().PutStr(fmt.Sprintf("source_%d", i), fmt.Sprintf("value_%d", i))
486486
}
487487

@@ -513,7 +513,7 @@ func newBenchmarkSpanContext(attributeCount int) ottlspan.TransformContext {
513513
span.Status().SetCode(ptrace.StatusCodeOk)
514514
span.Status().SetMessage("ok")
515515

516-
for i := 0; i < attributeCount; i++ {
516+
for i := range attributeCount {
517517
span.Attributes().PutStr(fmt.Sprintf("source_%d", i), fmt.Sprintf("span_value_%d", i))
518518
}
519519

@@ -619,7 +619,7 @@ func newSliceContextWithPrimitiveArr(arrSize int) ottllog.TransformContext {
619619

620620
arr := lr.Attributes().PutEmptySlice("arr")
621621
arr.EnsureCapacity(arrSize)
622-
for i := 0; i < arrSize; i++ {
622+
for i := range arrSize {
623623
arr.AppendEmpty().SetStr("v_" + strconv.Itoa(i))
624624
}
625625

@@ -637,7 +637,7 @@ func newSliceContextWithMapArr(arrSize int) ottllog.TransformContext {
637637

638638
arr := lr.Attributes().PutEmptySlice("arr")
639639
arr.EnsureCapacity(arrSize)
640-
for i := 0; i < arrSize; i++ {
640+
for i := range arrSize {
641641
elem := arr.AppendEmpty()
642642
m := elem.SetEmptyMap()
643643
m.PutStr("id", "item_"+strconv.Itoa(i))

0 commit comments

Comments
 (0)