Table of Contents

Interface IMetricWriter

Namespace
Typhon.Engine
Assembly
Typhon.Engine.dll

Writer interface for zero-allocation metric collection during snapshot operations.

public interface IMetricWriter

Remarks

Implementations buffer values internally in pre-allocated structures. The resource graph provides a writer instance during snapshot collection, and metric sources write their current values to it.

The writer pattern avoids allocations by having sources write to a buffer rather than returning metric objects. This keeps the snapshot path allocation-free.

For methods that can be called multiple times (WriteThroughput, WriteDuration), each call appends to an internal list. For fixed methods (WriteMemory, WriteCapacity, etc.), the last call wins if called multiple times.

Methods

WriteCapacity(long, long)

Reports capacity utilization metrics for this node.

void WriteCapacity(long current, long maximum)

Parameters

current long

Slots/entries currently used.

maximum long

Total slots available (capacity).

Remarks

Utilization (current / maximum) is computed by the snapshot builder, not by the writer. This keeps ReadMetrics fast (no division).

WriteDiskIO(long, long, long, long)

Reports disk I/O metrics for this node.

void WriteDiskIO(long readOps, long writeOps, long readBytes, long writeBytes)

Parameters

readOps long

Number of read operations (counter).

writeOps long

Number of write operations (counter).

readBytes long

Total bytes read (counter).

writeBytes long

Total bytes written (counter).

WriteDuration(string, long, long, long)

Reports a named duration metric.

void WriteDuration(string name, long lastUs, long avgUs, long maxUs)

Parameters

name string

Operation name (e.g., "Checkpoint", "GroupCommit"). Must be a static string.

lastUs long

Duration of the most recent operation in microseconds.

avgUs long

Exponential moving average in microseconds.

maxUs long

Longest operation observed (high-water mark).

Remarks

Call multiple times for multiple duration types. Use static strings only to maintain zero-allocation — avoid string interpolation.

WriteMemory(long, long)

Reports memory allocation metrics for this node.

void WriteMemory(long allocatedBytes, long peakBytes)

Parameters

allocatedBytes long

Current live allocation in bytes.

peakBytes long

Maximum allocation ever observed (high-water mark).

WriteThroughput(string, long)

Reports a named throughput counter.

void WriteThroughput(string name, long count)

Parameters

name string

Counter name (e.g., "CacheHits", "Commits"). Must be a static string.

count long

Total operations since startup (monotonically increasing).

Remarks

Call multiple times for multiple counters (e.g., "Lookups", "Inserts"). Use static strings only to maintain zero-allocation — avoid string interpolation.