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

Use sync.Pools for ResourceLogs in otelloghttp transforms #5268

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hiroyaonoe
Copy link

@hiroyaonoe hiroyaonoe commented Apr 26, 2024

I used sync.Pools to pool the slice []*lpb.ResourceLogs. The function free, which ResourceLogs returns, puts the slice into the pools.
Also, I updated the test TestResourceLogs for the data integrity.

I referred to https://github.com/open-telemetry/opentelemetry-go-contrib/blob/59ebbee5c207bb6034462a75da61b79668fe9232/bridges/otelslog/handler.go#L346

Copy link

codecov bot commented Apr 26, 2024

Codecov Report

Attention: Patch coverage is 81.81818% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 84.4%. Comparing base (fe3de70) to head (646a771).
Report is 33 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff           @@
##            main   #5268    +/-   ##
======================================
  Coverage   84.3%   84.4%            
======================================
  Files        258     265     +7     
  Lines      17042   17483   +441     
======================================
+ Hits       14382   14759   +377     
- Misses      2361    2413    +52     
- Partials     299     311    +12     
Files Coverage Δ
exporters/otlp/otlplog/otlploghttp/exporter.go 92.0% <50.0%> (+8.6%) ⬆️
...otlp/otlplog/otlploghttp/internal/transform/log.go 95.3% <88.8%> (+<0.1%) ⬆️

... and 17 files with indirect coverage changes

@MrAlias
Copy link
Contributor

MrAlias commented Apr 26, 2024

fixes #5196

This does not fix #5196. The use of maps in the transforms was the main target of a sync pool for that issue.

@MrAlias
Copy link
Contributor

MrAlias commented Apr 26, 2024

Please show how the performance is improved with this change with benchmarks.

LogRecords: pbLogRecords[2:],
}},
}}
out, free = ResourceLogs(records[2:])
Copy link
Contributor

Choose a reason for hiding this comment

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

free is never called here.

@@ -18,18 +19,26 @@ import (
"go.opentelemetry.io/otel/sdk/log"
)

// ResourceLogs returns an slice of OTLP ResourceLogs generated from records.
func ResourceLogs(records []log.Record) []*lpb.ResourceLogs {
var resourceLogsPool = sync.Pool{
Copy link
Contributor

Choose a reason for hiding this comment

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

These pool values escape this package. It is likely a better design to have pooled values passed to ResourceLogs instead so leaks are not incurred.

@MrAlias MrAlias added area:logs Part of OpenTelemetry logs pkg:exporter:otlp Related to the OTLP exporter package Skip Changelog PRs that do not require a CHANGELOG.md entry labels Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:logs Part of OpenTelemetry logs pkg:exporter:otlp Related to the OTLP exporter package Skip Changelog PRs that do not require a CHANGELOG.md entry
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

None yet

2 participants