Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 23 additions & 12 deletions opentelemetry-otlp/tests/integration_test/tests/logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ fn init_logs(is_simple: bool) -> Result<sdklogs::LoggerProvider> {
Ok(logger_provider)
}

async fn logs_tokio_helper(is_simple: bool, log_send_outside_rt: bool) -> Result<()> {
async fn logs_tokio_helper(
is_simple: bool,
log_send_outside_rt: bool,
current_thread: bool,
) -> Result<()> {
use crate::{assert_logs_results_contains, init_logs};
test_utils::start_collector_container().await?;

Expand Down Expand Up @@ -76,7 +80,14 @@ async fn logs_tokio_helper(is_simple: bool, log_send_outside_rt: bool) -> Result
info!(target: "my-target", uuid = expected_uuid.as_str(), "hello from {}. My price is {}.", "banana", 2.99);
}
}
let _ = logger_provider.shutdown();
if current_thread {
let _res = tokio::runtime::Handle::current()
.spawn_blocking(move || logger_provider.shutdown())
.await
.unwrap();
} else {
let _ = logger_provider.shutdown();
}
tokio::time::sleep(Duration::from_secs(5)).await;
assert_logs_results_contains(test_utils::LOGS_FILE, expected_uuid.as_str())?;
Ok(())
Expand Down Expand Up @@ -175,7 +186,7 @@ mod logtests {
#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
#[cfg(any(feature = "tonic-client", feature = "reqwest-blocking-client"))]
pub async fn logs_batch_tokio_multi_thread() -> Result<()> {
logs_tokio_helper(false, false).await
logs_tokio_helper(false, false, false).await
}

// logger initialization - Inside RT
Expand All @@ -185,7 +196,7 @@ mod logtests {
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
#[cfg(any(feature = "tonic-client", feature = "reqwest-blocking-client"))]
pub async fn logs_batch_tokio_multi_with_one_worker() -> Result<()> {
logs_tokio_helper(false, false).await
logs_tokio_helper(false, false, false).await
}

// logger initialization - Inside RT
Expand All @@ -195,7 +206,7 @@ mod logtests {
#[tokio::test(flavor = "current_thread")]
#[cfg(any(feature = "tonic-client", feature = "reqwest-blocking-client"))]
pub async fn logs_batch_tokio_current() -> Result<()> {
logs_tokio_helper(false, false).await
logs_tokio_helper(false, false, true).await
}

// logger initialization - Inside RT
Expand All @@ -205,7 +216,7 @@ mod logtests {
#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
#[cfg(any(feature = "tonic-client", feature = "reqwest-blocking-client"))]
pub async fn logs_batch_tokio_log_outside_rt_multi_thread() -> Result<()> {
logs_tokio_helper(false, true).await
logs_tokio_helper(false, true, false).await
}

// logger initialization - Inside RT
Expand All @@ -215,7 +226,7 @@ mod logtests {
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
#[cfg(any(feature = "tonic-client", feature = "reqwest-blocking-client"))]
pub async fn logs_batch_tokio_log_outside_rt_multi_with_one_worker() -> Result<()> {
logs_tokio_helper(false, true).await
logs_tokio_helper(false, true, false).await
}

// logger initialization - Inside RT
Expand All @@ -225,7 +236,7 @@ mod logtests {
#[tokio::test(flavor = "current_thread")]
#[cfg(any(feature = "tonic-client", feature = "reqwest-blocking-client"))]
pub async fn logs_batch_tokio_log_outside_rt_current_thread() -> Result<()> {
logs_tokio_helper(false, true).await
logs_tokio_helper(false, true, true).await
}

// logger initialization - Inside RT
Expand Down Expand Up @@ -310,7 +321,7 @@ mod logtests {
#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
#[cfg(feature = "reqwest-blocking-client")]
pub async fn logs_simple_tokio_multi_thread() -> Result<()> {
logs_tokio_helper(true, false).await
logs_tokio_helper(true, false, false).await
}

// logger initialization - Inside RT
Expand All @@ -324,7 +335,7 @@ mod logtests {
feature = "hyper-client"
))]
pub async fn logs_simple_tokio_multi_thread() -> Result<()> {
logs_tokio_helper(true, false).await
logs_tokio_helper(true, false, false).await
}

// logger initialization - Inside RT
Expand All @@ -338,7 +349,7 @@ mod logtests {
feature = "hyper-client"
))]
pub async fn logs_simple_tokio_multi_with_one_worker() -> Result<()> {
logs_tokio_helper(true, false).await
logs_tokio_helper(true, false, false).await
}

// logger initialization - Inside RT
Expand All @@ -353,7 +364,7 @@ mod logtests {
feature = "hyper-client"
))]
pub async fn logs_simple_tokio_current() -> Result<()> {
logs_tokio_helper(true, false).await
logs_tokio_helper(true, false, false).await
}
}
///
Expand Down