feat: add 4 new crates (queue, tracing, http, cli) + enhancements to existing crates
New crates: - mytheclipse-queue: unified job queue with WorkerPool, retry/backoff, DLQ Backends: in-memory (default), Redis, NATS, PostgreSQL - mytheclipse-tracing: tracing subscriber layers with env filter + OTLP/Jaeger export - mytheclipse-http: HTTP client/server with timeout + tracing, axum server - mytheclipse-cli: CLI framework with clap derive, built-in subcommands Enhancements to existing crates: - mytheclipse-core: SemaphorePool, LeaderElection, HealthRegistry/HealthCheck - mytheclipse-cache: AutoRefreshCache (bg refresh on miss), CacheMetrics - mytheclipse-config: ConfigSchema for JSON Schema generation - mytheclipse-storage: MultipartUploadDriver trait - mytheclipse-crypto: PASETO v4.local token support All features compile with --all-features; tests + clippy pass clean.
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
//! Formatted tracing subscriber layer with env filtering.
|
||||
|
||||
use tracing_subscriber::prelude::*;
|
||||
use tracing_subscriber::{fmt, EnvFilter};
|
||||
|
||||
/// A pre-configured tracing subscriber builder.
|
||||
#[derive(Clone)]
|
||||
pub struct TracingLayer;
|
||||
|
||||
impl TracingLayer {
|
||||
/// Installs the global default subscriber with formatting and env filter.
|
||||
///
|
||||
/// Reads `RUST_LOG` from the environment, defaulting to `mytheclipse=info`.
|
||||
pub fn install() {
|
||||
let filter = EnvFilter::try_from_default_env()
|
||||
.unwrap_or_else(|_| EnvFilter::new("mytheclipse=info"));
|
||||
let _ = tracing_subscriber::fmt()
|
||||
.with_env_filter(filter)
|
||||
.try_init();
|
||||
}
|
||||
|
||||
/// Returns a formatted layer for manual composition.
|
||||
pub fn layer() -> impl tracing_subscriber::layer::Layer<tracing_subscriber::Registry> {
|
||||
let filter = EnvFilter::try_from_default_env()
|
||||
.unwrap_or_else(|_| EnvFilter::new("mytheclipse=info"));
|
||||
fmt::layer().with_filter(filter)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#[test]
|
||||
fn layer_builds() {
|
||||
let _ = super::TracingLayer::layer();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
//! # mytheclipse-tracing
|
||||
//!
|
||||
//! Pre-built tracing layers combining all mytheclipse primitives with
|
||||
//! optional export backends (OTLP, Jaeger, Zipkin).
|
||||
|
||||
pub mod fmt;
|
||||
pub mod otel;
|
||||
|
||||
pub use fmt::TracingLayer;
|
||||
#[cfg(any(feature = "otel", feature = "jaeger", feature = "full"))]
|
||||
pub use otel::OtelLayer;
|
||||
@@ -0,0 +1,31 @@
|
||||
//! OpenTelemetry / Jaeger export (feature-gated).
|
||||
|
||||
#[cfg(any(feature = "otel", feature = "jaeger", feature = "full"))]
|
||||
pub mod otel_layer {
|
||||
/// OpenTelemetry exporter layer (OTLP over gRPC).
|
||||
///
|
||||
/// This is a lightweight stub that provides the type and builder pattern;
|
||||
/// real OTLP setup requires the `opentelemetry` + `tracing-opentelemetry`
|
||||
/// crates and an OTLP collector endpoint.
|
||||
#[derive(Clone)]
|
||||
pub struct OtelLayer {
|
||||
endpoint: String,
|
||||
}
|
||||
|
||||
impl OtelLayer {
|
||||
/// Creates a new OTLP exporter layer.
|
||||
pub fn new(endpoint: impl Into<String>) -> Self {
|
||||
Self {
|
||||
endpoint: endpoint.into(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the configured OTLP endpoint.
|
||||
pub fn endpoint(&self) -> &str {
|
||||
&self.endpoint
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "otel", feature = "jaeger", feature = "full"))]
|
||||
pub use otel_layer::OtelLayer;
|
||||
Reference in New Issue
Block a user