Comments (19)
@LukeMathWalker happy to accept a PR for any of those as long as they are a working replacement for the sync behavior. The specific http client is an implementation detail that we can iterate on so seems more important to get a working exporter first 👍
from opentelemetry-rust.
Oh sure, I was just suggesting a temporary workaround to avoid blocking the core thread to ship traces 😁
from opentelemetry-rust.
@glademiller it looks like your spawn_blocking
closure creates a future (the async block) that is never awaited, so task
is never polled
from opentelemetry-rust.
Resolved in #232
from opentelemetry-rust.
@samschlegel did you have any preliminary thoughts on what you'd like to see in this interface?
from opentelemetry-rust.
Something I've been thinking about is how a lot of the same abstractions we have in tower
would be nice for building exporters. I'm not sure that you'd want to add a tower
dep though, but I rather like that interface. Would make batching and buffering and retries really easy. Right now my work on Rust tracing has been put on hold for a bit, but I was planning on writing a ServiceExporter
that would basically do that.
from opentelemetry-rust.
I'd be happy to help here as well - from a quick look I am not a 100% sure of how extensive the changes would have to be though. Am I mistaken in believing that it might be necessary to touch the thrift crate?
from opentelemetry-rust.
@LukeMathWalker Seems like there are really two changes here:
- Finding an alternative sync http client to replace reqwest so it does not panic when used in async apps.
SpanExporter
trait would ideally have a method that returns a future (orPin<Box<dyn Future>>
), then the jaeger/zipkin exporters could use that to avoid using blocking APIs entirely.
from opentelemetry-rust.
For 1., we could look into
A good starting point could be this analysis.
from opentelemetry-rust.
I haven't actually tested this code but it is pretty straightforward if someone wants to run it an make sure everything is in order. It compiles all right #116
from opentelemetry-rust.
@jtescher quick question that I haven't been able to answer quickly myself by looking at the code. Using ureq shouldn't interfere directly with the tokio event loop or runtime but where is the collector code being called? Can I put it on its own thread or is it on its own thread already so it won't interfere with my event loop? Or is this something that I will have to wait for an async exporter to have? Thanks for all your help.
from opentelemetry-rust.
@glademiller So currently you pass in a function pointer basicaly fn(Future) -> T
to however you want the batch span processor to be run, e.g. https://github.com/open-telemetry/opentelemetry-rust/blob/master/examples/async/src/main.rs#L65 passes tokio::spawn
so the batch span processor work is spawned on the current executor.
You could pass a pointer to a function that would spin up a new thread and do the work there if you wanted to customize this behavior beyond what tokio or async_std do by default.
Possibly something along the lines of:
fn spawn<T>(task: T) -> JoinHandle where
T: Future + Send + 'static,
{
thread::spawn(|| {
// do other setup work and spawn task
})
}
from opentelemetry-rust.
@glademiller the async exporter interface would likely add a similar trait as https://github.com/open-telemetry/opentelemetry-rust/blob/master/src/exporter/trace/mod.rs#L34-L57, but allow the result to be a future, which would let async http clients not have to block to accommodate the current sync methods.
from opentelemetry-rust.
Would passing tokio::spawn_blocking
there solve the issue?
from opentelemetry-rust.
@LukeMathWalker Well this issue specifically is allowing the exporters to be entirely async (updated issue description to reflect #121 being merged)
from opentelemetry-rust.
@LukeMathWalker yeah good point, haven't tried it but that may be a good workaround for now 👍
from opentelemetry-rust.
@LukeMathWalker @jtescher I was attempting to use the work around described but it appears something about it causes traces to never get sent. This is how I have defined my spawn function as follows
fn spawn<T>(task: T) -> tokio::task::JoinHandle<impl futures::Future> where T: futures::Future + Send + 'static {
tokio::task::spawn_blocking(|| async {
task.await
})
}
This might not be the best place to discuss a workaround but I'm hoping to move forward with something that works in the near term.
Any thoughts as to why traces would not be sent with my implementation of spawn?
from opentelemetry-rust.
Pretty obvious in hindsight. Thank you @hawkw
from opentelemetry-rust.
In case someone is looking for the workaround this is what I landed on
fn spawn<T>(task: T) -> std::thread::JoinHandle<()> where T: futures::Future + Send + 'static {
std::thread::spawn(|| {
futures::executor::block_on(async { task.await });
})
}
from opentelemetry-rust.
Related Issues (20)
- Metrics SDK multi-threaded testing
- [Bug]: the Meter::i64_histogram() api removed HOT 2
- [Bug]: Context::current().with_remote_span_context() not working HOT 3
- [Bug]: Error sending data to New Relic OTEL service HOT 1
- Replace TestExporter with InMemoryExporter
- [Bug]: opentelemetry-otlp inconsistency between http and grpc export endpoint for traces HOT 1
- [OTEL 0.22] shutdown SdkMeterProvider when built from opentelemetry-otlp? HOT 1
- [Bug]: TracerProvider can be dropped unknowingly HOT 4
- Remove `dropped_attributes_count` from SpanLinks and SpanEvents API
- [Feature]: Upgrade http to 1.1.0 HOT 1
- Metrics data cleanup on MeterProvider shutdown
- [Bug]: Simple exporter missing tokio runtime HOT 3
- Cost of Key, Value abstractions HOT 2
- Investigate Potential to bypass LogRecord cloning when emitting LogRecord to LogProcessor(s) HOT 3
- [Bug]: Flacky test for default Span's batch HOT 1
- [Bug]: actions-rs/toolchain is archived
- [Bug]: CI tests are failing during grpc-build HOT 1
- [Bug]: unclear how to setup http(hyper) without agent pipeline HOT 1
- [Bug]: OpenTelemetry log error occurred. cannot send message to batch processor as the channel is closed HOT 1
- [Bug]: Global metrics provider gets shutdown when local provider is dropped HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from opentelemetry-rust.