Expand description
Structured logging framework for MCP servers
This crate provides comprehensive logging capabilities for MCP servers including:
- Structured logging with tracing
- Metrics collection and reporting
- Log sanitization for security
- Performance monitoring integration
§Example
ⓘ
use pulseengine_mcp_logging::{MetricsCollector, StructuredLogger};
#[tokio::main]
async fn main() {
let metrics = MetricsCollector::new();
let logger = StructuredLogger::new();
// Initialize structured logging
logger.init().expect("Failed to initialize logging");
// Log with structured context
tracing::info!(server_type = "mcp", version = "1.0", "Server started");
}Re-exports§
pub use aggregation::AggregationConfig;pub use aggregation::AggregationError;pub use aggregation::LogAggregator;pub use aggregation::LogDestination;pub use aggregation::LogEntry;pub use aggregation::RetryConfig;pub use aggregation::SyslogProtocol;pub use alerting::Alert;pub use alerting::AlertConfig;pub use alerting::AlertError;pub use alerting::AlertManager;pub use alerting::AlertRule;pub use alerting::AlertSeverity;pub use alerting::AlertState;pub use alerting::ComparisonOperator;pub use alerting::MetricType;pub use alerting::NotificationChannel;pub use correlation::CorrelationConfig;pub use correlation::CorrelationContext;pub use correlation::CorrelationError;pub use correlation::CorrelationHeaders;pub use correlation::CorrelationManager;pub use correlation::CorrelationStats;pub use correlation::RequestTraceEntry;pub use dashboard::AggregationType;pub use dashboard::ChartConfig;pub use dashboard::ChartData;pub use dashboard::ChartOptions;pub use dashboard::ChartSeries;pub use dashboard::ChartStyling;pub use dashboard::ChartType;pub use dashboard::DashboardConfig;pub use dashboard::DashboardLayout;pub use dashboard::DashboardManager;pub use dashboard::DashboardSection;pub use dashboard::DashboardTheme;pub use dashboard::DataPoint;pub use dashboard::DataSource;pub use dashboard::GridPosition;pub use dashboard::LineStyle;pub use dashboard::Threshold;pub use metrics::BusinessMetrics;pub use metrics::ErrorMetrics;pub use metrics::ErrorRecord;pub use metrics::HealthMetrics;pub use metrics::MetricsCollector;pub use metrics::MetricsSnapshot;pub use metrics::RequestMetrics;pub use metrics::get_metrics;pub use persistence::MetricsPersistence;pub use persistence::PersistedMetrics;pub use persistence::PersistenceConfig;pub use persistence::RotationInterval;pub use profiling::AsyncTaskProfile;pub use profiling::AsyncTaskState;pub use profiling::CpuProfilingConfig;pub use profiling::FlameGraphConfig;pub use profiling::FlameGraphData;pub use profiling::FlameGraphNode;pub use profiling::FunctionCall;pub use profiling::FunctionCallProfile;pub use profiling::MemoryProfilingConfig;pub use profiling::MemorySnapshot;pub use profiling::PerformanceHotspot;pub use profiling::PerformanceProfiler;pub use profiling::PerformanceThresholds;pub use profiling::ProfilingConfig;pub use profiling::ProfilingError;pub use profiling::ProfilingSession;pub use profiling::ProfilingSessionType;pub use profiling::ProfilingStats;pub use profiling::StackFrame;pub use sanitization::LogSanitizer;pub use sanitization::SanitizationConfig;pub use structured::ErrorClass;pub use structured::StructuredContext;pub use structured::StructuredLogger;pub use telemetry::BatchProcessingConfig;pub use telemetry::JaegerConfig;pub use telemetry::OtlpConfig;pub use telemetry::SamplingConfig;pub use telemetry::SamplingStrategy;pub use telemetry::TelemetryConfig;pub use telemetry::TelemetryError;pub use telemetry::TelemetryManager;pub use telemetry::ZipkinConfig;pub use telemetry::propagation;pub use telemetry::spans;
Modules§
- aggregation
- Log aggregation and centralized logging for distributed MCP servers
- alerting
- Alerting and notification system for MCP servers
- correlation
- Request correlation and distributed tracing for MCP servers
- dashboard
- Custom metrics dashboards for MCP servers
- metrics
- Metrics collection for observability and monitoring
- persistence
- Metrics persistence for historical data
- profiling
- Performance profiling and flame graph generation for MCP servers
- sanitization
- Log sanitization for production builds
- structured
- Enhanced structured logging for better observability
- telemetry
- Simplified OpenTelemetry integration for distributed tracing
Macros§
- profile_
function - Profiling macro for function timing
- sanitized_
debug - sanitized_
error - Convenient macros for different log levels
- sanitized_
info - sanitized_
log - Convenient macro for sanitized logging
- sanitized_
warn
Enums§
- Logging
Error - Logging error types
Traits§
- Error
Classification - Generic error trait for classification
Type Aliases§
- Logging
Result - Preferred result type alias that doesn’t conflict with std::result::Result
- Result
- Result type for logging operations