rs-zero 0.2.3

Rust-first microservice framework inspired by go-zero engineering practices
Documentation
#![cfg(feature = "profiling")]

use std::{collections::BTreeMap, time::Duration};

use rs_zero::profiling::{PyroscopeConfig, start_pyroscope};

#[test]
#[ignore = "requires external Pyroscope from examples/production-adapters/docker-compose.external.yml"]
fn pyroscope_external_agent_starts_and_shutdowns() {
    let endpoint = std::env::var("RS_ZERO_PYROSCOPE_ENDPOINT")
        .unwrap_or_else(|_| "http://127.0.0.1:14040".to_string());
    let mut tags = BTreeMap::new();
    tags.insert("env".to_string(), "external-ci".to_string());

    let handle = start_pyroscope(PyroscopeConfig {
        endpoint,
        service_name: "rs-zero-pyroscope-external".to_string(),
        sample_rate: 100,
        tags,
        shutdown_timeout: Duration::from_secs(30),
    })
    .expect("start pyroscope agent");

    let mut checksum = 0_u64;
    for value in 0..50_000 {
        checksum = checksum.wrapping_add(value);
    }
    assert!(checksum > 0);
    assert!(handle.is_running());
    handle.shutdown().expect("shutdown pyroscope agent");
}