observability-kit 0.3.0

Configuration and other common entities related to observability
Documentation
#![allow(clippy::expect_used)]

use std::time::Duration;

use observability_kit::otlp_tracing;
use tracing::{instrument, Level};

#[tokio::test]
async fn otlp_tracing_with_jaeger() {
    otlp_tracing::try_init("TEST_SERVICE").expect("tracing initialization should succeed");
    for i in 0..10024 {
        let _unused_result = test_instrumented_function(i);
        tokio::time::sleep(Duration::from_millis(10)).await;
    }
}

#[instrument(
    fields(test_instrumented_field = 47_u64),
    ret(level = Level::DEBUG),
    err(level = Level::WARN),
)]
fn test_instrumented_function(input_argument: u64) -> Result<u64, u64> {
    input_argument
        .is_power_of_two()
        .then_some(input_argument)
        .ok_or(input_argument)
}