From fa7ed39bf480fd50c488ce54daad7322ced73aab Mon Sep 17 00:00:00 2001 From: Simon Hauser Date: Mon, 10 Jun 2024 17:49:45 +0200 Subject: feat(tvix/tracing): correctly close otlp on exit Provide a new interface for forcing a flush of otlp traces and use this interface to shutdown otlp prior to exiting tvix-store, either if the tool was stopped with a SIGTERM or ended regularly. This also fixes an issue where traces were not even exported if for example we just imported 10 paths and never even emitted more than 256 traces. The implementation uses a mpsc channel so a flush can be done without having to wait for it to complete. If you want to wait for a flush to complete you can provide a oneshot channel which will receive a message once flushing is complete. Because of a otlp bug `force_flush` as well as `shutdown_tracer_provider` need to be executed using `spawn_blocking` otherwise the function will deadlock. See https://github.com/open-telemetry/opentelemetry-rust/issues/1395#issuecomment-1953280335 Change-Id: I0a828391adfb1f72dc8305f62ced8cba0515847c Reviewed-on: https://cl.tvl.fyi/c/depot/+/11803 Reviewed-by: flokli Tested-by: BuildkiteCI Autosubmit: Simon Hauser --- tvix/tracing/Cargo.toml | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tvix/tracing/Cargo.toml') diff --git a/tvix/tracing/Cargo.toml b/tvix/tracing/Cargo.toml index f65c9eba6cab..41654d00c02f 100644 --- a/tvix/tracing/Cargo.toml +++ b/tvix/tracing/Cargo.toml @@ -9,6 +9,8 @@ tracing = { version = "0.1.40", features = ["max_level_trace", "release_max_leve tracing-subscriber = { version = "0.3.18", features = ["env-filter"] } indicatif = "0.17.8" tracing-indicatif = "0.3.6" +tokio = { version = "1.32.0" , features = ["sync", "rt"] } +thiserror = "1.0.38" tracing-opentelemetry = { version = "0.23.0", optional = true } opentelemetry = { version = "0.22.0", optional = true } -- cgit 1.4.1