-
Notifications
You must be signed in to change notification settings - Fork 437
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
[Logs SDK] Send resource once to processor and exporter, and not for every event. #1636
[Logs SDK] Send resource once to processor and exporter, and not for every event. #1636
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1636 +/- ##
=======================================
- Coverage 69.3% 69.2% -0.1%
=======================================
Files 136 136
Lines 19637 19561 -76
=======================================
- Hits 13610 13544 -66
+ Misses 6027 6017 -10 ☔ View full report in Codecov by Sentry. |
@lalitb any noticeable change in performance, out of curiosity! |
Looks good overall! Thank you. |
Yes, there is a visible improvement with stress-test in the hot path as we don't clone and add resources in the LogData during emit. There should be improvement in memory usage too, but we don't have a direct way of measuring it. with PR $ cargo run --bin logs --all-features --release
Compiling opentelemetry_sdk v0.22.1 (/home/labhas/otel/rust/lalit/set-resource/opentelemetry-rust/opentelemetry-sdk)
Compiling stress v0.1.0 (/home/labhas/otel/rust/lalit/set-resource/opentelemetry-rust/stress)
Finished `release` profile [optimized] target(s) in 4.21s
Running `target/release/logs`
Number of threads: 8
Number of threads: 8
Throughput: 19,301,400 iterations/sec
Throughput: 19,789,000 iterations/sec
Throughput: 20,133,600 iterations/sec
Throughput: 19,763,000 iterations/sec main branch $ cargo run --bin logs --all-features --release
Compiling opentelemetry_sdk v0.22.1 (/home/labhas/otel/rust/lalit/set-resource/opentelemetry-rust/opentelemetry-sdk)
Compiling opentelemetry-appender-tracing v0.3.0 (/home/labhas/otel/rust/lalit/set-resource/opentelemetry-rust/opentelemetry-appender-tracing)
Compiling stress v0.1.0 (/home/labhas/otel/rust/lalit/set-resource/opentelemetry-rust/stress)
Finished `release` profile [optimized] target(s) in 4.22s
Running `target/release/logs`
Number of threads: 8
Throughput: 16,356,200 iterations/sec
Throughput: 15,894,400 iterations/sec
Throughput: 16,018,200 iterations/sec
Throughput: 16,344,800 iterations/sec |
Co-authored-by: Cijo Thomas <cithomas@microsoft.com>
Have update this PR to not clone |
Seems merge conflicts with #1585, fixing them now. |
should be good now. |
Please don't merge yet. OTLP http log export seems to be broken after merging changes with #1585. Looking into it |
Should be good now. Need to add integration tests for OTLP Log exporter to detect these issues. Will create a PR for this later. |
Fixes Part of #1124 (for logs)
Design discussion issue (if applicable) #
Changes
a. Add
LogExporter::set_resource(&resource)
method.b. Add
LogProcessor::set_resource(&resource)
method, which invokesset_resource
on all the exporters.c. The LogExporter would store the resource in original or serialized format, and merge it with each event during export.
d. The LoggerProvider invokes
set_resource
on all the processors during its initialization.e. Remove
resource
from theLogData
structure, which is exported to the exporters throughLogExporter::emit(logdata)
. This ensures that resource is not sent to the exporter with each event.2. Avoid cloning LogRocord during emit if single processor is configured.Will create separate PR for thiscall sequence -
LoggerProvider::build()
->LogProcessor::set_resource()
->LogExporter::set_resource()
Currently, these changes apply exclusively to Logs. Once there is consensus and these changes are merged, will extend them to traces and metrics. Additionally, changes made in #1526 can be undone after implementing this across all signals.
Benchmark:
Main branch:
PR branch: (with Resource propagation at startup )
PR branch: (with Resource propagation at startup + avoid LogRecord copy for single processor)will create separate PR for thisMerge requirement checklist
CHANGELOG.md
files updated for non-trivial, user-facing changes