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

Consolidate BatchConfig creation and validation via BatchConfigBuilder #1480

Merged
merged 30 commits into from
Jan 25, 2024

Conversation

CosminLazar
Copy link
Contributor

@CosminLazar CosminLazar commented Jan 18, 2024

Design discussion issue (if applicable) #1471

Changes

This PR builds on top of #1471 and aims at consolidating the BatchConfig creation for both spans and logs via a BatchConfigBuilder. The BatchConfigBuilder will be responsible for:

  • initialising using the default OTLP defaults
  • reading environment variables that override the OTLP defaults
  • providing mutating functions for user configuration
  • enforcing invariants (e.g.: max_export_batch_size must be less than or equal to max_queue_size),

This PR introduces breaking changes ❗:

  • the API of BatchLogProcessorBuilder and BatchSpanProcessorBuilder no longer supports fine grained BatchConfig configurations, only with_batch_config is left
  • BatchConfig is now a simple data holder and no loger offers mutating functions

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)

@CosminLazar CosminLazar requested a review from a team as a code owner January 18, 2024 20:21
@CosminLazar CosminLazar marked this pull request as draft January 18, 2024 20:21
Copy link

codecov bot commented Jan 18, 2024

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (27b19b6) 63.7% compared to head (6bcc496) 64.2%.

Files Patch % Lines
opentelemetry-sdk/src/trace/span_processor.rs 98.1% 3 Missing ⚠️
opentelemetry-sdk/src/logs/log_processor.rs 98.1% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main   #1480     +/-   ##
=======================================
+ Coverage   63.7%   64.2%   +0.4%     
=======================================
  Files        142     142             
  Lines      19499   19583     +84     
=======================================
+ Hits       12437   12584    +147     
+ Misses      7062    6999     -63     

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

@CosminLazar CosminLazar marked this pull request as ready for review January 18, 2024 22:16
Copy link
Member

@lalitb lalitb left a comment

Choose a reason for hiding this comment

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

Thanks for the cleanup. There is some code repetition for BatchConfigBuilder in span_processor, and log_processor (not coming from this PR), and it would be beneficial to refactor this as a shared component in a future PR.

opentelemetry-sdk/src/logs/log_processor.rs Outdated Show resolved Hide resolved
opentelemetry-sdk/src/trace/span_processor.rs Outdated Show resolved Hide resolved
CosminLazar and others added 3 commits January 23, 2024 10:01
Co-authored-by: Lalit Kumar Bhasin <lalit_fin@yahoo.com>
Co-authored-by: Lalit Kumar Bhasin <lalit_fin@yahoo.com>
impl Default for BatchConfigBuilder {
/// Create a new [`BatchConfigBuilder`] initialized with default batch config values as per the specs.
/// The values are overriden by environment variables if set.
/// For a list of supported environment variables see [Batch LogRecord Processor](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#batch-logrecord-processor).
Copy link
Member

Choose a reason for hiding this comment

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

Lets document it in this repo itself. Linking to spec is okay, but if spec adds something new and is not implemented here, it'll lead to confusion.

@cijothomas
Copy link
Member

Thanks for the cleanup. There is some code repetition for BatchConfigBuilder in span_processor, and log_processor (not coming from this PR), and it would be beneficial to refactor this as a shared component in a future PR.

@CosminLazar Do you plan to tackle this suggestion in this PR? Its totally okay to have it as a separate PR.

@CosminLazar
Copy link
Contributor Author

Thanks for the cleanup. There is some code repetition for BatchConfigBuilder in span_processor, and log_processor (not coming from this PR), and it would be beneficial to refactor this as a shared component in a future PR.

@CosminLazar Do you plan to tackle this suggestion in this PR? Its totally okay to have it as a separate PR.

Will give it a look in a new PR

@cijothomas cijothomas merged commit 2660047 into open-telemetry:main Jan 25, 2024
15 checks passed
@cijothomas
Copy link
Member

Some minor things left, better tackled in follow up PRs. merging now.

@cijothomas
Copy link
Member

Thanks for the cleanup. There is some code repetition for BatchConfigBuilder in span_processor, and log_processor (not coming from this PR), and it would be beneficial to refactor this as a shared component in a future PR.

@CosminLazar Do you plan to tackle this suggestion in this PR? Its totally okay to have it as a separate PR.

Will give it a look in a new PR

Many thanks for your contributions!

@CosminLazar
Copy link
Contributor Author

CosminLazar commented Jan 29, 2024

Thanks for the cleanup. There is some code repetition for BatchConfigBuilder in span_processor, and log_processor (not coming from this PR), and it would be beneficial to refactor this as a shared component in a future PR.

@lalitb Can you give some hints on how that refactor might look like?

Except extracting the environment variables read logic and introducing an internal configuration type to hold those values, I have a bit of a hardtime figuring out what a good abstraction might look like here with my rust skills so far :)

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.

None yet

3 participants