Table of Contents

Interface IResourceGraph

Namespace
Typhon.Engine
Assembly
Typhon.Engine.dll

Entry point for the resource graph. Provides tree traversal and snapshot collection.

public interface IResourceGraph

Remarks

The resource graph maintains the hierarchical structure of all managed resources and provides a pull-based API for metric collection. Consumers take snapshots on demand — typically every 1-5 seconds for monitoring, or ad-hoc for debugging.

Snapshot semantics:

  • Per-node atomic: Each node's ReadMetrics() reads all fields together
  • Cross-node approximate: Different nodes may be read microseconds apart
  • No global lock: Tree traversal doesn't block other threads

The graph internally tracks the previous snapshot for rate computation. The first snapshot has Rates = null.

Properties

Root

The root of the resource tree.

IResource Root { get; }

Property Value

IResource

Methods

FindByPath(string)

Find a resource by path.

IResource FindByPath(string path)

Parameters

path string

Slash-separated path (e.g., "Storage/PageCache"). Does not include "Root" prefix.

Returns

IResource

The resource, or null if not found.

FindByType(ResourceType)

Find all resources of a specific type.

IEnumerable<IResource> FindByType(ResourceType type)

Parameters

type ResourceType

The resource type to find.

Returns

IEnumerable<IResource>

All resources of the specified type.

GetSnapshot()

Walk the entire tree, read all IMetricSource nodes, return immutable snapshot. Throughput rates are auto-computed from the previous snapshot.

ResourceSnapshot GetSnapshot()

Returns

ResourceSnapshot

Snapshot containing all metric values at approximately this instant.

Remarks

Cost: ~50ns per node × number of nodes. Typically 50-100 nodes = 2.5-5 μs.

The graph internally tracks the previous snapshot for rate computation. First snapshot has Rates = null.

GetSnapshot(IResource)

Read metrics for a single subtree only.

ResourceSnapshot GetSnapshot(IResource subtreeRoot)

Parameters

subtreeRoot IResource

The root of the subtree to snapshot.

Returns

ResourceSnapshot

Snapshot containing only nodes under subtreeRoot.

Remarks

Use when you know which subsystem to inspect. Faster than full snapshot.

Note: Rates are computed only for nodes in the subtree.

ResetAllPeaks()

Reset all peak/high-water mark values across all IMetricSource nodes.

void ResetAllPeaks()

Remarks

Walks the tree and calls ResetPeaks() on each metric source.

Use after alert acknowledgment, periodic reset, or on operator request. This is a separate operation from snapshot collection (snapshots are read-only).