From d42ad90aadc6ebeed608a87725a26f5694ec6bb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karolis=20Gudi=C5=A1kis?= Date: Thu, 20 Jul 2023 15:05:12 +0300 Subject: [PATCH] feat: Register errors from error manager in jaeger (#1753) --- dozer-cli/src/main.rs | 12 +++++++++--- dozer-core/src/error_manager.rs | 3 +++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/dozer-cli/src/main.rs b/dozer-cli/src/main.rs index e26587e612..dc98c72899 100644 --- a/dozer-cli/src/main.rs +++ b/dozer-cli/src/main.rs @@ -130,9 +130,15 @@ fn run() -> Result<(), OrchestrationError> { set_ctrl_handler(shutdown_sender); // Now we have access to telemetry configuration. Telemetry must be initialized in tokio runtime. - let _telemetry = dozer.runtime.block_on(async { - Telemetry::new(Some(&dozer.config.app_name), dozer.config.telemetry.clone()) - }); + let app_name = dozer.config.app_name.clone(); + let app_id = dozer + .config + .cloud + .as_ref() + .map(|cloud| cloud.app_id.clone().unwrap_or(app_name)); + let _telemetry = dozer + .runtime + .block_on(async { Telemetry::new(app_id.as_deref(), dozer.config.telemetry.clone()) }); if let Some(cmd) = cli.cmd { // run individual servers diff --git a/dozer-core/src/error_manager.rs b/dozer-core/src/error_manager.rs index 9f65c9777d..01f88d8533 100644 --- a/dozer-core/src/error_manager.rs +++ b/dozer-core/src/error_manager.rs @@ -1,5 +1,6 @@ use std::sync::atomic::AtomicU32; +use dozer_types::tracing::error_span; use dozer_types::{errors::internal::BoxedError, log::error}; /// `ErrorManager` records and counts the number of errors happened. @@ -27,7 +28,9 @@ impl ErrorManager { } pub fn report(&self, error: BoxedError) { + error_span!("reported error", error = true, e = error); error!("{}", error); + let count = self.count.fetch_add(1, std::sync::atomic::Ordering::SeqCst); if let Some(threshold) = self.threshold { if count >= threshold {