Interface IMetricsScope
Represents a scoped metrics collection for a single mutation execution.
Inherited Members
Namespace: ModularityKit.Mutator.Abstractions.Metrics
Assembly: ModularityKit.Mutator.dll
Syntax
public interface IMetricsScope : IDisposable
Remarks
IMetricsScope is used to track metrics related to a specific mutation, such as execution time, validation time, policy evaluation time, state size, and memory usage. It also allows recording custom metrics and building a final MutationMetrics object.
A typical workflow:
- Obtain a scope from BeginScope(string).
- Record individual metrics during mutation execution using the provided methods.
- Call Build() to get the MutationMetrics object representing the collected data.
- Dispose the scope after recording is complete.
Properties
| Edit this page View SourceExecutionId
Unique identifier for the mutation execution associated with this scope.
Declaration
string ExecutionId { get; }
Property Value
| Type | Description |
|---|---|
| string |
Methods
| Edit this page View SourceAddCustomMetric(string, object)
Adds a custom metric with a key and value to the scope.
Declaration
void AddCustomMetric(string key, object value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | key | Metric key/name. |
| object | value | Metric value. |
Build()
Builds the MutationMetrics object representing all collected metrics in this scope.
Declaration
MutationMetrics Build()
Returns
| Type | Description |
|---|---|
| MutationMetrics | A MutationMetrics instance. |
RecordMemoryUsage(long)
Records memory usage during mutation execution (in bytes).
Declaration
void RecordMemoryUsage(long bytes)
Parameters
| Type | Name | Description |
|---|---|---|
| long | bytes | Memory used in bytes. |
RecordPolicyEvaluationTime(TimeSpan)
Records the time spent evaluating policies for the mutation.
Declaration
void RecordPolicyEvaluationTime(TimeSpan time)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan | time | Duration of policy evaluation. |
RecordStateSize(long)
Records the size of the state before or after mutation (in bytes).
Declaration
void RecordStateSize(long bytes)
Parameters
| Type | Name | Description |
|---|---|---|
| long | bytes | State size in bytes. |
RecordValidationTime(TimeSpan)
Records the time spent validating the mutation.
Declaration
void RecordValidationTime(TimeSpan time)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan | time | Duration of validation. |