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

Simplify LogExporter::Export interface #2041

Merged
merged 5 commits into from
Aug 21, 2024

Conversation

lalitb
Copy link
Member

@lalitb lalitb commented Aug 21, 2024

Changes

  1. The Exporter::export interface is modified to accept the vector of pair/tuple of reference to LogRecord and InstrumentationLib, instead of Cow of LogData.

Before:

async fn export<'a>(&mut self, batch: Vec<Cow<'a, LogData>>) -> LogResult<()>;

After:

async fn export( &mut self, batch: Vec<(&LogRecord, &InstrumentationLibrary)>) -> LogResult<()>;

This simplifies the processing for exporters, as they don't need to check whether the object is borrowed, or owned. Exporter needs to ensure to create the copy of LogRecord and/or InstrumentationLib whenever needed.

  1. The LogData structure is not part of the export interface. So it has been moved from opentelemetry_sdk::export::logs to opentelemetry_sdk::logs:: namespace.

Merge requirement checklist

  • CONTRIBUTING guidelines followed
  • Unit tests added/updated (if applicable)
  • Appropriate CHANGELOG.md files updated for non-trivial, user-facing changes
  • Changes in public API reviewed (if applicable)

@lalitb lalitb requested a review from a team August 21, 2024 11:11
Copy link

codecov bot commented Aug 21, 2024

Codecov Report

Attention: Patch coverage is 54.21687% with 38 lines in your changes missing coverage. Please review.

Project coverage is 77.1%. Comparing base (056d2ae) to head (8c22d38).
Report is 1 commits behind head on main.

Files Patch % Lines
opentelemetry-stdout/src/logs/transform.rs 0.0% 21 Missing ⚠️
opentelemetry-proto/src/transform/logs.rs 78.3% 8 Missing ⚠️
opentelemetry-otlp/src/exporter/http/logs.rs 0.0% 2 Missing ⚠️
opentelemetry-otlp/src/exporter/tonic/logs.rs 0.0% 2 Missing ⚠️
opentelemetry-stdout/src/logs/exporter.rs 0.0% 2 Missing ⚠️
opentelemetry-otlp/src/exporter/http/mod.rs 0.0% 1 Missing ⚠️
opentelemetry-otlp/src/logs.rs 0.0% 1 Missing ⚠️
opentelemetry-sdk/src/logs/log_processor.rs 90.0% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main   #2041     +/-   ##
=======================================
+ Coverage   77.0%   77.1%   +0.1%     
=======================================
  Files        123     123             
  Lines      21111   21104      -7     
=======================================
+ Hits       16260   16276     +16     
+ Misses      4851    4828     -23     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

let export_batch = batch
.iter()
.map(|log_data| (&log_data.record, &log_data.instrumentation))
.collect();
Copy link
Member

Choose a reason for hiding this comment

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

BatchProcessor is now doing an extra cloning - 1st one occurs when it receives the &mut LogData, so it can save it to channel. And its drained to a Vec! later, which was passed as-is to Exporter previously. Now another Vec! needs to be created to pass on to exporter.
Something we can revisit and address in the future.

Copy link
Member Author

Choose a reason for hiding this comment

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

This operation is only creating references and collecting them, no cloning of data is happening.

Copy link
Member

Choose a reason for hiding this comment

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

Isn't the collect making a new Vec! ?

Copy link
Member Author

@lalitb lalitb Aug 22, 2024

Choose a reason for hiding this comment

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

Oh yes, I was talking specifically about cloning. Need to revisit vector later.

@cijothomas cijothomas merged commit 3193320 into open-telemetry:main Aug 21, 2024
24 of 25 checks passed
cijothomas added a commit to cijothomas/opentelemetry-rust that referenced this pull request Aug 22, 2024
Co-authored-by: Cijo Thomas <cijo.thomas@gmail.com>
cijothomas added a commit to cijothomas/opentelemetry-rust that referenced this pull request Aug 22, 2024
Co-authored-by: Cijo Thomas <cijo.thomas@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants