Class ContextFlowTracker
- Namespace
- Excalibur.Dispatch.Observability.Context
- Assembly
- Excalibur.Dispatch.Observability.dll
Main tracking component that records context state at each pipeline stage, detects changes/losses in context fields, correlates context across service boundaries, and tracks context lineage throughout the message processing lifecycle.
public sealed class ContextFlowTracker : IContextFlowTracker, IDisposable, IAsyncDisposable
- Inheritance
-
ContextFlowTracker
- Implements
- Inherited Members
- Extension Methods
Constructors
ContextFlowTracker(ILogger<ContextFlowTracker>, IOptions<ContextObservabilityOptions>, IContextFlowMetrics)
Initializes a new instance of the ContextFlowTracker class.
public ContextFlowTracker(ILogger<ContextFlowTracker> logger, IOptions<ContextObservabilityOptions> options, IContextFlowMetrics metrics)
Parameters
loggerILogger<ContextFlowTracker>Logger for diagnostic output.
optionsIOptions<ContextObservabilityOptions>Configuration options for context observability.
metricsIContextFlowMetricsMetrics collector for context flow tracking.
Methods
CorrelateAcrossBoundary(IMessageContext, string)
Correlates context across service boundaries for distributed tracing.
public void CorrelateAcrossBoundary(IMessageContext context, string serviceBoundary)
Parameters
contextIMessageContextThe message context.
serviceBoundarystringThe service boundary identifier.
DetectChanges(IMessageContext, string, string)
Detects changes or losses in context fields between pipeline stages.
public IEnumerable<ContextChange> DetectChanges(IMessageContext context, string fromStage, string toStage)
Parameters
contextIMessageContextThe current message context.
fromStagestringThe previous pipeline stage.
toStagestringThe current pipeline stage.
Returns
- IEnumerable<ContextChange>
A collection of detected changes.
Dispose()
Releases all resources used by the ContextFlowTracker.
public void Dispose()
DisposeAsync()
Asynchronously releases resources, ensuring the cleanup timer callback has completed.
public ValueTask DisposeAsync()
Returns
GetContextLineage(string)
Gets the complete context lineage for a specific correlation ID.
public ContextLineage? GetContextLineage(string correlationId)
Parameters
correlationIdstringThe correlation ID.
Returns
- ContextLineage
The context lineage or null if not found.
GetMessageSnapshots(string)
Gets all snapshots for a specific message.
public IEnumerable<ContextSnapshot> GetMessageSnapshots(string messageId)
Parameters
messageIdstringThe message ID.
Returns
- IEnumerable<ContextSnapshot>
Collection of snapshots for the message.
RecordContextState(IMessageContext, string, IReadOnlyDictionary<string, object>?)
Records the current state of a message context at a specific pipeline stage.
public void RecordContextState(IMessageContext context, string stage, IReadOnlyDictionary<string, object>? metadata = null)
Parameters
contextIMessageContextThe message context to track.
stagestringThe current pipeline stage.
metadataIReadOnlyDictionary<string, object>Additional metadata about the tracking point.
ValidateContextIntegrity(IMessageContext)
Validates that the context contains all required fields.
public bool ValidateContextIntegrity(IMessageContext context)
Parameters
contextIMessageContextThe message context to validate.
Returns
- bool
True if context is valid; otherwise false.