Processor
provide.foundation.profiling.processor
¶
TODO: Add module docstring.
Classes¶
ProfilingProcessor
¶
Structlog processor that collects performance metrics via sampling.
This processor integrates into Foundation's existing structlog pipeline to collect metrics about message processing performance, emoji overhead, and throughput with configurable sampling to minimize performance impact.
Example
processor = ProfilingProcessor(sample_rate=0.01) # 1% sampling
Add to structlog processor chain¶
processors.append(processor)
Later, get metrics¶
metrics = processor.get_metrics() print(f"Processing {metrics.messages_per_second:.0f} msg/sec")
Initialize profiling processor with sampling configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sample_rate
|
float
|
Fraction of messages to sample (0.0 to 1.0) 0.01 = 1% sampling for minimal overhead |
DEFAULT_PROFILING_SAMPLE_RATE
|
Source code in provide/foundation/profiling/processor.py
Functions¶
__call__
¶
Process log event and optionally collect metrics.
This is the main entry point called by structlog for each log message. Uses sampling to minimize performance overhead.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
logger
|
Any
|
The logger instance (unused) |
required |
method_name
|
str
|
The logging method name (unused) |
required |
event_dict
|
EventDict
|
The event dictionary to process |
required |
Returns:
| Type | Description |
|---|---|
EventDict
|
The event_dict unchanged (pass-through processor) |