tracing-better-stack 0.1.0

A tracing-subscriber layer for Better Stack (Logtail) logging
Documentation
// Common test utilities that work with both JSON and MessagePack formats

use std::sync::Arc;
use wiremock::{Match, MockServer, Request};

/// HTTP status code that Better Stack returns on successful log ingestion
/// According to Better Stack documentation, the API returns 202 (Accepted)
pub const BETTER_STACK_ACCEPTED_STATUS: u16 = 202;

/// A matcher that captures request bodies for inspection
pub struct BodyCaptureMatcher {
    pub captured: Arc<tokio::sync::Mutex<Vec<Vec<u8>>>>,
}

impl Match for BodyCaptureMatcher {
    fn matches(&self, request: &Request) -> bool {
        let body = request.body.clone();
        let captured = self.captured.clone();
        tokio::spawn(async move {
            captured.lock().await.push(body);
        });
        true
    }
}

/// Helper to extract host from mock server URI
pub fn mock_host(mock_server: &MockServer) -> String {
    mock_server.uri().replace("http://", "")
}