Table of Contents

Class ContextFlowMetrics

Namespace
Excalibur.Dispatch.Observability.Context
Assembly
Excalibur.Dispatch.Observability.dll

Metrics collection component for context flow observability, tracking context field preservation rate, mutation frequency, size metrics, and cross-boundary success rate.

public sealed class ContextFlowMetrics : IContextFlowMetrics, IContextFlowCounterMetrics, IContextFlowHistogramMetrics, IContextFlowGaugeMetrics, IDisposable
Inheritance
ContextFlowMetrics
Implements
Inherited Members
Extension Methods

Constructors

ContextFlowMetrics(IOptions<ContextObservabilityOptions>)

Initializes a new instance of the ContextFlowMetrics class.

public ContextFlowMetrics(IOptions<ContextObservabilityOptions> options)

Parameters

options IOptions<ContextObservabilityOptions>

Configuration options for context observability.

ContextFlowMetrics(IMeterFactory, IOptions<ContextObservabilityOptions>)

Initializes a new instance of the ContextFlowMetrics class using an IMeterFactory.

public ContextFlowMetrics(IMeterFactory meterFactory, IOptions<ContextObservabilityOptions> options)

Parameters

meterFactory IMeterFactory

The meter factory for DI-managed meter lifecycle.

options IOptions<ContextObservabilityOptions>

Configuration options for context observability.

Methods

Dispose()

Disposes the metrics resources.

public void Dispose()

GetMetricsSummary()

Gets current metrics summary.

public ContextMetricsSummary GetMetricsSummary()

Returns

ContextMetricsSummary

A summary of current metrics.

RecordContextError(string, string)

Records a context error event.

public void RecordContextError(string errorType, string stage)

Parameters

errorType string

Type of error that occurred.

stage string

Pipeline stage where the error occurred.

RecordContextMutation(ContextChangeType, string, string)

Records a context mutation event.

public void RecordContextMutation(ContextChangeType changeType, string fieldName, string stage)

Parameters

changeType ContextChangeType

Type of change detected.

fieldName string

Name of the field that changed.

stage string

Pipeline stage where the mutation occurred.

RecordContextPreservationSuccess(string)

Records successful context preservation.

public void RecordContextPreservationSuccess(string stage)

Parameters

stage string

The pipeline stage.

RecordContextSize(string, int)

Records context size metrics.

public void RecordContextSize(string stage, int sizeBytes)

Parameters

stage string

The pipeline stage.

sizeBytes int

Size in bytes.

RecordContextSizeThresholdExceeded(string, int)

Records when context size exceeds threshold.

public void RecordContextSizeThresholdExceeded(string stage, int sizeBytes)

Parameters

stage string

The pipeline stage.

sizeBytes int

The actual size in bytes.

RecordContextSnapshot(string, int, int)

Records a context snapshot event.

public void RecordContextSnapshot(string stage, int fieldCount, int sizeBytes)

Parameters

stage string

The pipeline stage where the snapshot was taken.

fieldCount int

Number of fields in the context.

sizeBytes int

Size of the context in bytes.

RecordContextValidationFailure(string)

Records a context validation failure.

public void RecordContextValidationFailure(string failureReason)

Parameters

failureReason string

Reason for the validation failure.

RecordCrossBoundaryTransition(string, bool)

Records a cross-boundary transition event.

public void RecordCrossBoundaryTransition(string serviceBoundary, bool contextPreserved)

Parameters

serviceBoundary string

The service boundary identifier.

contextPreserved bool

Whether context was preserved across the boundary.

RecordDeserializationLatency(string, long)

Records context deserialization latency.

public void RecordDeserializationLatency(string operationType, long latencyMs)

Parameters

operationType string

Type of deserialization operation.

latencyMs long

Latency in milliseconds.

RecordPipelineStageLatency(string, long)

Records pipeline stage latency.

public void RecordPipelineStageLatency(string stage, long latencyMs)

Parameters

stage string

The pipeline stage.

latencyMs long

Latency in milliseconds.

RecordSerializationLatency(string, long)

Records context serialization latency.

public void RecordSerializationLatency(string operationType, long latencyMs)

Parameters

operationType string

Type of serialization operation.

latencyMs long

Latency in milliseconds.

UpdateActiveContextCount(int)

Updates the count of active contexts.

public void UpdateActiveContextCount(int delta)

Parameters

delta int

Change in active context count (positive or negative).

UpdateLineageDepth(int)

Updates the maximum observed lineage depth.

public void UpdateLineageDepth(int depth)

Parameters

depth int

The observed lineage depth.