Skip to content

Conversation

gnak-yar
Copy link
Contributor

@gnak-yar gnak-yar commented Oct 8, 2025

Description

Another fix for #43044. This error is not reported in the issue.

goos: darwin
goarch: arm64
pkg: github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex
cpu: Apple M4 Max
BenchmarkParseNoCache-14                           15130             78689 ns/op
BenchmarkParseWithMemoryCache-14                   59836             19746 ns/op
BenchmarkParseWithMemoryCacheFullByOne-14          53994             20786 ns/op
BenchmarkParseWithMemoryCacheFullBy10-14           38668             30696 ns/op
BenchmarkParseWithMemoryCacheFullBy50-14           20751             57883 ns/op
BenchmarkParseWithMemoryCacheFullBy90-14           15634             75974 ns/op
BenchmarkParseWithMemoryCacheFullBy99-14           14929             79251 ns/op
BenchmarkParseNoCacheOneFile-14                   663885              1735 ns/op
BenchmarkParseWithMemoryCacheOneFile-14         91589362                13.04 ns/op
PASS
goleak: Errors on successful test run: found unexpected goroutines:
[Goroutine 26460181 in state select, with github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex.(*atomicLimiter).init.func1.1 on top of the stack:
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex.(*atomicLimiter).init.func1.1()
        /Users/ray.kang/github.com/gnak-yar/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex/cache.go:171 +0x94
created by github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex.(*atomicLimiter).init.func1 in goroutine 26461891
        /Users/ray.kang/github.com/gnak-yar/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex/cache.go:165 +0x60
 Goroutine 10525566 in state select, with github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex.(*atomicLimiter).init.func1.1 on top of the stack:
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex.(*atomicLimiter).init.func1.1()
        /Users/ray.kang/github.com/gnak-yar/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex/cache.go:171 +0x94
created by github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex.(*atomicLimiter).init.func1 in goroutine 9517088
        /Users/ray.kang/github.com/gnak-yar/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex/cache.go:165 +0x60
 Goroutine 9526274 in state select, with github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex.(*atomicLimiter).init.func1.1 on top of the stack:
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex.(*atomicLimiter).init.func1.1()
        /Users/ray.kang/github.com/gnak-yar/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex/cache.go:171 +0x94
created by github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex.(*atomicLimiter).init.func1 in goroutine 9517088
        /Users/ray.kang/github.com/gnak-yar/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex/cache.go:165 +0x60
 Goroutine 26472023 in state select, with github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex.(*atomicLimiter).init.func1.1 on top of the stack:
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex.(*atomicLimiter).init.func1.1()
        /Users/ray.kang/github.com/gnak-yar/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex/cache.go:171 +0x94
created by github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex.(*atomicLimiter).init.func1 in goroutine 26461891

...

Similarly to #43117, the goleak errors occur because regex.Parser does not stop. Stopping a parser silences the error.
Applied table-driven approach as the related benchmarks look very similar.

Link to tracking issue

Fixes
#43044

Testing

cd pkg/stanza/operator/parser/regex
go test -bench='Parser'

Copy link
Member

@andrzej-stencel andrzej-stencel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome thanks!

@songy23 songy23 merged commit b40c421 into open-telemetry:main Oct 8, 2025
185 checks passed
Copy link
Contributor

otelbot bot commented Oct 8, 2025

Thank you for your contribution @gnak-yar! 🎉 We would like to hear from you about your experience contributing to OpenTelemetry by taking a few minutes to fill out this survey. If you are getting started contributing, you can also join the CNCF Slack channel #opentelemetry-new-contributors to ask for guidance and get help.

@github-actions github-actions bot added this to the next release milestone Oct 8, 2025
mashhurs pushed a commit to mashhurs/opentelemetry-collector-contrib that referenced this pull request Oct 9, 2025
…pen-telemetry#43213)

<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
Another fix for open-telemetry#43044. This error is not reported in the issue.
```
goos: darwin
goarch: arm64
pkg: github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex
cpu: Apple M4 Max
BenchmarkParseNoCache-14                           15130             78689 ns/op
BenchmarkParseWithMemoryCache-14                   59836             19746 ns/op
BenchmarkParseWithMemoryCacheFullByOne-14          53994             20786 ns/op
BenchmarkParseWithMemoryCacheFullBy10-14           38668             30696 ns/op
BenchmarkParseWithMemoryCacheFullBy50-14           20751             57883 ns/op
BenchmarkParseWithMemoryCacheFullBy90-14           15634             75974 ns/op
BenchmarkParseWithMemoryCacheFullBy99-14           14929             79251 ns/op
BenchmarkParseNoCacheOneFile-14                   663885              1735 ns/op
BenchmarkParseWithMemoryCacheOneFile-14         91589362                13.04 ns/op
PASS
goleak: Errors on successful test run: found unexpected goroutines:
[Goroutine 26460181 in state select, with github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex.(*atomicLimiter).init.func1.1 on top of the stack:
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex.(*atomicLimiter).init.func1.1()
        /Users/ray.kang/github.com/gnak-yar/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex/cache.go:171 +0x94
created by github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex.(*atomicLimiter).init.func1 in goroutine 26461891
        /Users/ray.kang/github.com/gnak-yar/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex/cache.go:165 +0x60
 Goroutine 10525566 in state select, with github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex.(*atomicLimiter).init.func1.1 on top of the stack:
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex.(*atomicLimiter).init.func1.1()
        /Users/ray.kang/github.com/gnak-yar/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex/cache.go:171 +0x94
created by github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex.(*atomicLimiter).init.func1 in goroutine 9517088
        /Users/ray.kang/github.com/gnak-yar/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex/cache.go:165 +0x60
 Goroutine 9526274 in state select, with github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex.(*atomicLimiter).init.func1.1 on top of the stack:
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex.(*atomicLimiter).init.func1.1()
        /Users/ray.kang/github.com/gnak-yar/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex/cache.go:171 +0x94
created by github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex.(*atomicLimiter).init.func1 in goroutine 9517088
        /Users/ray.kang/github.com/gnak-yar/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex/cache.go:165 +0x60
 Goroutine 26472023 in state select, with github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex.(*atomicLimiter).init.func1.1 on top of the stack:
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex.(*atomicLimiter).init.func1.1()
        /Users/ray.kang/github.com/gnak-yar/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex/cache.go:171 +0x94
created by github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex.(*atomicLimiter).init.func1 in goroutine 26461891

...
```

Similarly to open-telemetry#43117, the goleak errors occur because `regex.Parser` does
not stop. Stopping a parser silences the error.
Applied table-driven approach as the related benchmarks look very
similar.

<!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. -->
#### Link to tracking issue
Fixes
open-telemetry#43044 

<!--Describe what testing was performed and which tests were added.-->
#### Testing
```sh
cd pkg/stanza/operator/parser/regex
go test -bench='Parser'
```

Co-authored-by: Andrzej Stencel <[email protected]>
tommyers-elastic pushed a commit to tommyers-elastic/opentelemetry-collector-contrib that referenced this pull request Oct 10, 2025
…pen-telemetry#43213)

<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
Another fix for open-telemetry#43044. This error is not reported in the issue.
```
goos: darwin
goarch: arm64
pkg: github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex
cpu: Apple M4 Max
BenchmarkParseNoCache-14                           15130             78689 ns/op
BenchmarkParseWithMemoryCache-14                   59836             19746 ns/op
BenchmarkParseWithMemoryCacheFullByOne-14          53994             20786 ns/op
BenchmarkParseWithMemoryCacheFullBy10-14           38668             30696 ns/op
BenchmarkParseWithMemoryCacheFullBy50-14           20751             57883 ns/op
BenchmarkParseWithMemoryCacheFullBy90-14           15634             75974 ns/op
BenchmarkParseWithMemoryCacheFullBy99-14           14929             79251 ns/op
BenchmarkParseNoCacheOneFile-14                   663885              1735 ns/op
BenchmarkParseWithMemoryCacheOneFile-14         91589362                13.04 ns/op
PASS
goleak: Errors on successful test run: found unexpected goroutines:
[Goroutine 26460181 in state select, with github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex.(*atomicLimiter).init.func1.1 on top of the stack:
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex.(*atomicLimiter).init.func1.1()
        /Users/ray.kang/github.com/gnak-yar/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex/cache.go:171 +0x94
created by github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex.(*atomicLimiter).init.func1 in goroutine 26461891
        /Users/ray.kang/github.com/gnak-yar/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex/cache.go:165 +0x60
 Goroutine 10525566 in state select, with github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex.(*atomicLimiter).init.func1.1 on top of the stack:
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex.(*atomicLimiter).init.func1.1()
        /Users/ray.kang/github.com/gnak-yar/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex/cache.go:171 +0x94
created by github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex.(*atomicLimiter).init.func1 in goroutine 9517088
        /Users/ray.kang/github.com/gnak-yar/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex/cache.go:165 +0x60
 Goroutine 9526274 in state select, with github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex.(*atomicLimiter).init.func1.1 on top of the stack:
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex.(*atomicLimiter).init.func1.1()
        /Users/ray.kang/github.com/gnak-yar/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex/cache.go:171 +0x94
created by github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex.(*atomicLimiter).init.func1 in goroutine 9517088
        /Users/ray.kang/github.com/gnak-yar/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex/cache.go:165 +0x60
 Goroutine 26472023 in state select, with github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex.(*atomicLimiter).init.func1.1 on top of the stack:
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex.(*atomicLimiter).init.func1.1()
        /Users/ray.kang/github.com/gnak-yar/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex/cache.go:171 +0x94
created by github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/parser/regex.(*atomicLimiter).init.func1 in goroutine 26461891

...
```

Similarly to open-telemetry#43117, the goleak errors occur because `regex.Parser` does
not stop. Stopping a parser silences the error.
Applied table-driven approach as the related benchmarks look very
similar.

<!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. -->
#### Link to tracking issue
Fixes
open-telemetry#43044 

<!--Describe what testing was performed and which tests were added.-->
#### Testing
```sh
cd pkg/stanza/operator/parser/regex
go test -bench='Parser'
```

Co-authored-by: Andrzej Stencel <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants