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

[DRAFT] Add Custom Thread-Based Runtime for OpenTelemetry batch Processing #2390

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

lalitb
Copy link
Member

@lalitb lalitb commented Dec 6, 2024

Disclaimer - Not for review or merge. If this seems useful, we can keep this PR open - for someone to take it further to production ready in future (post 1.0 era :) )

Changes

This draft PR introduces a custom thread-based runtime for asynchronous task handling in the OpenTelemetry Rust SDK. It provides an alternative for users which don't want to take dependency on external frameworks like Tokio or Async-Std for batch processing, featuring a simple thread-based worker pool with interval and delay scheduling. Additionally, unit tests are included to demonstrate integration with common transport libraries - hyper, reqwest/reqwest-blocking. The implementation uses futures_executor::block_on and async-compat to marshal tasks into the required runtime. The latter is smaller crate, and relevant code can be incorporated inside the otel to remove the dependency. And also added an example for using this runtime impl within batch processor for logs.

The purpose of this draft is to demonstrate the concept and implementation of a thread-based runtime tailored for OpenTelemetry logging. It is not intended for immediate approval or merging but can serve as a foundation for future enhancements.

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 as a code owner December 6, 2024 17:52
@lalitb lalitb changed the title [DRAFT] Add Custom Thread-Based Runtime for OpenTelemetry Logs Processing [DRAFT] Add Custom Thread-Based Runtime for OpenTelemetry batch Processing Dec 6, 2024
Copy link

codecov bot commented Dec 6, 2024

Codecov Report

Attention: Patch coverage is 86.86869% with 39 lines in your changes missing coverage. Please review.

Project coverage is 79.4%. Comparing base (1a4e931) to head (9da2a65).

Files with missing lines Patch % Lines
opentelemetry-sdk/src/thread_runtime.rs 86.8% 39 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main   #2390     +/-   ##
=======================================
+ Coverage   79.3%   79.4%   +0.1%     
=======================================
  Files        122     123      +1     
  Lines      21511   21808    +297     
=======================================
+ Hits       17060   17318    +258     
- Misses      4451    4490     +39     

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

@@ -28,6 +28,7 @@ tokio = { workspace = true, features = ["rt", "time"], optional = true }
tokio-stream = { workspace = true, optional = true }
http = { workspace = true, optional = true }
tracing = {workspace = true, optional = true}
async-compat = { version = "0.2"}
Copy link
Member Author

@lalitb lalitb Dec 6, 2024

Choose a reason for hiding this comment

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

This package is for marshalling async events from futures runtime to tokio /async-std. Its dependency can be eliminated by integrating the necessary code from this package, as it appears to be relatively small.

@lalitb lalitb marked this pull request as draft December 6, 2024 17:58
Copy link
Member

@cijothomas cijothomas left a comment

Choose a reason for hiding this comment

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

I think this is the right long term direction - we expose the required methods in runtime traits, and provide implementations using std::thread (like this), tokio etc, and default to std::thread.

Hoping to make this the case after 1.0, once we get good confidence in all the trait methods we need.

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.

2 participants