domain
Domain layer for observability core - Pure business logic
This module contains ONLY pure business logic with no external dependencies. No WASM, HTTP, or framework-specific code should be here.
Type Aliases
Section titled “Type Aliases”TraceContext
Section titled “TraceContext”type TraceContext = TraceCorrelation;Backwards-compatible alias.
Traits
Section titled “Traits”LogProcessor
Section titled “LogProcessor”Core processor interface - transforms log entries
Required / Provided Methods
fn process(&self, entry: LogEntry) -> ObservabilityResult<LogEntry>Process and transform a log entry
fn name(&self) -> &''static strGet processor name for debugging
Structs
Section titled “Structs”LogEntry
Section titled “LogEntry”Core log entry - pure data structure
Fields
| Field | Type | Description |
|---|---|---|
timestamp | chrono::DateTime<chrono::Utc> | |
level | LogLevel | |
message | String | |
fields | serde_json::Value | |
trace_context | Option<TraceContext> | |
source | LogSource |
LogSource
Section titled “LogSource”Source of the log entry
Fields
| Field | Type | Description |
|---|---|---|
module | Option<String> | |
file | Option<String> | |
line | Option<u32> | |
target | Option<String> |
TraceCorrelation
Section titled “TraceCorrelation”Serializable trace identifiers for log/metric correlation.
Distinct from [crate::context::TraceContext] which is the runtime
tracing context with sampling decisions and W3C conversion methods.
Fields
| Field | Type | Description |
|---|---|---|
trace_id | String | |
span_id | String | |
parent_span_id | Option<String> |
ProcessorChain
Section titled “ProcessorChain”Processor chain pattern (inspired by structlog)
Methods
fn new() -> SelfCreate a new empty processor chain
add_processor
Section titled “add_processor”fn add_processor(self, processor: Box<dyn LogProcessor>) -> SelfAdd a processor to the chain
process
Section titled “process”fn process(&self, entry: LogEntry) -> ObservabilityResult<LogEntry>Process an entry through the entire chain
fn len(&self) -> usizeGet number of processors in the chain
is_empty
Section titled “is_empty”fn is_empty(&self) -> boolCheck if chain is empty
TimestampProcessor
Section titled “TimestampProcessor”Processor that adds timestamps
ContextEnricher
Section titled “ContextEnricher”Processor that enriches with context
Methods
fn new() -> Selfwith_field
Section titled “with_field”fn with_field<impl Into<String>, impl Into<serde_json::Value>>(self, key: impl Into, value: impl Into) -> SelfStructuredFieldsProcessor
Section titled “StructuredFieldsProcessor”Processor that structures fields
LevelFilter
Section titled “LevelFilter”Filter processor that filters out logs below certain level
Methods
fn new(min_level: LogLevel) -> SelfLogKvExtractor
Section titled “LogKvExtractor”Processor that extracts structured fields from log::kv
This processor supports the log::info!(“msg”; “key” => value) syntax by extracting key-value pairs from log::Record and adding them to LogEntry fields
Methods
fn new() -> Selfextract_kv_from_record
Section titled “extract_kv_from_record”fn extract_kv_from_record(record: &log::Record<'_>) -> serde_json::ValueExtract key-value pairs from log::Record
This function would be called by StandardLogAdapter when processing log::Record but we’ll implement the interface here for the processor chain
EnhancedContextEnricher
Section titled “EnhancedContextEnricher”Enhanced processor that combines context enrichment with kv extraction
Methods
fn new() -> Selfwith_field
Section titled “with_field”fn with_field<impl Into<String>, impl Into<serde_json::Value>>(self, key: impl Into, value: impl Into) -> Selfwith_kv_extraction
Section titled “with_kv_extraction”fn with_kv_extraction(self, extract_kv: bool) -> SelfMetricsEntry
Section titled “MetricsEntry”Basic metric entry for correlation with logs
Fields
| Field | Type | Description |
|---|---|---|
name | String | |
value | f64 | |
metric_type | BasicMetricType | |
timestamp | chrono::DateTime<chrono::Utc> | |
trace_context | Option<TraceContext> | |
source | MetricsSource |
Methods
fn new<impl Into<String>>(name: impl Into, value: f64, metric_type: BasicMetricType) -> SelfCreate a new metrics entry
with_trace_context
Section titled “with_trace_context”fn with_trace_context(self, trace_context: TraceContext) -> SelfAdd trace context for correlation
with_source
Section titled “with_source”fn with_source(self, module: Option<String>, component: Option<String>, operation: Option<String>) -> SelfAdd source information
to_json
Section titled “to_json”fn to_json(&self) -> serde_json::ValueConvert to JSON for transport
MetricsSource
Section titled “MetricsSource”Source of the metric
Fields
| Field | Type | Description |
|---|---|---|
module | Option<String> | |
component | Option<String> | |
operation | Option<String> |
BasicMetricType
Section titled “BasicMetricType”Simple metric types supported by core
Variants
| Variant | Description |
|---|---|
Counter | Counter metric (monotonically increasing) |
Histogram | Histogram/timing metric (distribution of values) |
Gauge | Gauge metric (current value) |
Functions
Section titled “Functions”build_default_processor_chain
Section titled “build_default_processor_chain”fn build_default_processor_chain() -> ProcessorChainBuild a default processor chain with common processors
build_enhanced_processor_chain
Section titled “build_enhanced_processor_chain”fn build_enhanced_processor_chain() -> ProcessorChainBuild an enhanced processor chain with additional features
create_log_entry
Section titled “create_log_entry”fn create_log_entry<impl Into<String>>(level: LogLevel, message: impl Into, fields: serde_json::Value) -> LogEntryCreate a log entry from basic components
create_counter_metric
Section titled “create_counter_metric”fn create_counter_metric<impl Into<String>>(name: impl Into, value: f64) -> MetricsEntryConvenience function to create a counter metric
create_histogram_metric
Section titled “create_histogram_metric”fn create_histogram_metric<impl Into<String>>(name: impl Into, value: f64) -> MetricsEntryConvenience function to create a histogram metric
create_gauge_metric
Section titled “create_gauge_metric”fn create_gauge_metric<impl Into<String>>(name: impl Into, value: f64) -> MetricsEntryConvenience function to create a gauge metric