InMemoryTraceStore
AgentPrism.Core.dllA store that keeps spans in process memory.
public sealed class InMemoryTraceStore : ITraceStoreInheritance
Section titled “Inheritance”Implements
Section titled “Implements”Inherited Members
Section titled “Inherited Members”object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Remarks
Section titled “Remarks”Limits: process lifetime, one node, and limited capacity.
When InMemoryTraceStore.MaxTraces is exceeded, it removes the oldest trace.
Use AgentPrism.PostgreSql in production.
Reads are limited to the current tenant. Writes take the tenant from the batch, while reads take it from ITenantContext. This is the same rule as the SQL implementation.
Constructors
Section titled “Constructors”InMemoryTraceStore(ITenantContext?)
Section titled “ InMemoryTraceStore(ITenantContext?)”Initializes a new in-memory span store.
public InMemoryTraceStore(ITenantContext? tenantContext = null)Parameters
Section titled “Parameters”tenantContext ITenantContext?
The current tenant context. If omitted, the store behaves as single tenant.
Properties
Section titled “Properties”MaxTraces
Section titled “ MaxTraces”The maximum number of traces to keep in memory.
public int MaxTraces { get; init; }Property Value
Section titled “Property Value”Methods
Section titled “Methods”GetTraceByRunAsync(Guid, CancellationToken)
Section titled “ GetTraceByRunAsync(Guid, CancellationToken)”Fetches a run’s span tree.
public ValueTask<RunTrace?> GetTraceByRunAsync(Guid runId, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”runId Guid
The run identifier.
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”The trace; null if no record exists.
WriteSpansAsync(TraceSpanBatch, CancellationToken)
Section titled “ WriteSpansAsync(TraceSpanBatch, CancellationToken)”Writes a trace’s spans. Can be called multiple times for the same trace; spans are merged by identifier.
public ValueTask WriteSpansAsync(TraceSpanBatch batch, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”batch TraceSpanBatch
The span set to write.
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”The completion task.