Skip to content

warnings: indication that there are tasks on the runtime but the runtime itself is not running #229

Open
@nagisa

Description

@nagisa

In the past I have encountered an issue in an otherwise mostly synchronous codebase where I wanted to use opentelemetry exporter. I would write code as such (mostly from memory, does not necessarily compile):

let runtime = tokio::Runtime::builder().single_threaded().build();
let tracer = runtime.block_on(async { 
    opentelemetry_otlp::new_pipeline().install_simple(opentelemetry::runtime::Tokio);
});
// register the otel collector with tracing...
loop {
    // main loop...
}

This would result in a memory leak and I didn't see any traces being delivered. At first I was thinking that perhaps the otel collector was setup incorrectly or something along those lines, but in reality the underlying reason was much less straightforward. What would happen is that all tracing events would end up in some sort of channel (I think). The install_simple method had registered a task to pull from this channel, but since the runtime is single threaded and nothing within the main loop calls block_on on this runtime again, this task is never polled in the first place.

It would be great if console warning system had a warning for this kind of situation, if it doesn't yet ^^

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-warningsArea: warningsC-consoleCrate: console.C-subscriberCrate: console-subscriber.E-mediumEffort: medium.S-featureSeverity: feature. This is adding a new feature.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions