Component
provide.foundation.profiling.component
¶
TODO: Add module docstring.
Classes¶
ProfilingComponent
¶
Hub component for managing Foundation performance profiling.
Integrates profiling functionality into Foundation's Hub architecture, providing centralized configuration and lifecycle management for performance monitoring.
Example
from provide.foundation.hub import Hub from provide.foundation.profiling import register_profiling
hub = Hub() register_profiling(hub) profiler = hub.get_component("profiler") profiler.enable()
Metrics are automatically collected¶
metrics = profiler.get_metrics() print(f"Throughput: {metrics.messages_per_second:.0f} msg/sec")
Initialize profiling component.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sample_rate
|
float
|
Fraction of messages to sample for metrics |
DEFAULT_PROFILING_SAMPLE_RATE
|
Source code in provide/foundation/profiling/component.py
Functions¶
__repr__
¶
String representation for debugging.
Source code in provide/foundation/profiling/component.py
disable
¶
Disable profiling metrics collection.
Source code in provide/foundation/profiling/component.py
enable
¶
Enable profiling metrics collection.
This method is safe to call multiple times - it will not re-enable if already enabled.
Source code in provide/foundation/profiling/component.py
get_metrics
¶
Get current profiling metrics.
Returns:
| Type | Description |
|---|---|
ProfileMetrics
|
Current ProfileMetrics instance with collected data |
reset
¶
Reset profiling metrics to initial values.
Useful for testing and periodic metric collection.
Source code in provide/foundation/profiling/component.py
Functions¶
register_profiling
¶
Register profiling component with Hub and add CLI command.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hub
|
Hub
|
The Hub instance to register with |
required |
sample_rate
|
float
|
Sampling rate for metrics collection |
DEFAULT_PROFILING_SAMPLE_RATE
|
Example
from provide.foundation.hub import Hub from provide.foundation.profiling.component import register_profiling
hub = Hub() register_profiling(hub)