Interface IMetricsCollector
Collector interface for capturing and recording mutation metrics.
Namespace: ModularityKit.Mutator.Abstractions.Metrics
Assembly: ModularityKit.Mutator.dll
Syntax
public interface IMetricsCollector
Remarks
IMetricsCollector defines the contract for recording, scoping, and aggregating metrics produced during mutation execution. Implementations may store metrics in memory, database, or telemetry systems, allowing analysis of performance, policy evaluation, and state changes.
Typical usage:
- Begin a scoped collection for a mutation using BeginScope(string).
- Record metrics using RecordAsync(string, MutationMetrics, CancellationToken).
- Retrieve aggregated metrics over a time period using GetAggregatedAsync(DateTimeOffset, DateTimeOffset, CancellationToken).
Methods
| Edit this page View SourceBeginScope(string)
Begins a metrics collection scope for a given mutation execution.
Declaration
IMetricsScope BeginScope(string executionId)
Parameters
| Type | Name | Description |
|---|---|---|
| string | executionId | Unique identifier of the mutation execution. |
Returns
| Type | Description |
|---|---|
| IMetricsScope | An IMetricsScope which should be disposed when metrics collection ends. |
GetAggregatedAsync(DateTimeOffset, DateTimeOffset, CancellationToken)
Retrieves aggregated metrics over a specified time range.
Declaration
Task<AggregatedMetrics> GetAggregatedAsync(DateTimeOffset from, DateTimeOffset to, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| DateTimeOffset | from | Start of the aggregation period. |
| DateTimeOffset | to | End of the aggregation period. |
| CancellationToken | cancellationToken | Optional cancellation token. |
Returns
| Type | Description |
|---|---|
| Task<AggregatedMetrics> | An AggregatedMetrics object containing aggregated results. |
RecordAsync(string, MutationMetrics, CancellationToken)
Records metrics for a specific mutation execution.
Declaration
Task RecordAsync(string executionId, MutationMetrics metrics, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | executionId | Unique identifier of the mutation execution. |
| MutationMetrics | metrics | Metrics to record. |
| CancellationToken | cancellationToken | Optional cancellation token. |
Returns
| Type | Description |
|---|---|
| Task |