Some checks failed
Docs CI / lint-and-preview (push) Has been cancelled
AOC Guard CI / aoc-guard (push) Has been cancelled
AOC Guard CI / aoc-verify (push) Has been cancelled
Concelier Attestation Tests / attestation-tests (push) Has been cancelled
Export Center CI / export-ci (push) Has been cancelled
Notify Smoke Test / Notify Unit Tests (push) Has been cancelled
Notify Smoke Test / Notifier Service Tests (push) Has been cancelled
Notify Smoke Test / Notification Smoke Test (push) Has been cancelled
Policy Lint & Smoke / policy-lint (push) Has been cancelled
Scanner Analyzers / Discover Analyzers (push) Has been cancelled
Scanner Analyzers / Build Analyzers (push) Has been cancelled
Scanner Analyzers / Test Language Analyzers (push) Has been cancelled
Scanner Analyzers / Validate Test Fixtures (push) Has been cancelled
Scanner Analyzers / Verify Deterministic Output (push) Has been cancelled
Signals CI & Image / signals-ci (push) Has been cancelled
Signals Reachability Scoring & Events / reachability-smoke (push) Has been cancelled
Signals Reachability Scoring & Events / sign-and-upload (push) Has been cancelled
44 lines
2.2 KiB
C#
44 lines
2.2 KiB
C#
using System.Diagnostics.Metrics;
|
|
|
|
namespace StellaOps.Scanner.Cache;
|
|
|
|
public static class ScannerCacheMetrics
|
|
{
|
|
public const string MeterName = "StellaOps.Scanner.Cache";
|
|
|
|
private static readonly Meter Meter = new(MeterName, "1.0.0");
|
|
|
|
private static readonly Counter<long> LayerHits = Meter.CreateCounter<long>("scanner.layer_cache_hits_total");
|
|
private static readonly Counter<long> LayerMisses = Meter.CreateCounter<long>("scanner.layer_cache_misses_total");
|
|
private static readonly Counter<long> LayerEvictions = Meter.CreateCounter<long>("scanner.layer_cache_evictions_total");
|
|
private static readonly Histogram<long> LayerBytes = Meter.CreateHistogram<long>("scanner.layer_cache_bytes");
|
|
private static readonly Counter<long> FileCasHits = Meter.CreateCounter<long>("scanner.file_cas_hits_total");
|
|
private static readonly Counter<long> FileCasMisses = Meter.CreateCounter<long>("scanner.file_cas_misses_total");
|
|
private static readonly Counter<long> FileCasEvictions = Meter.CreateCounter<long>("scanner.file_cas_evictions_total");
|
|
private static readonly Histogram<long> FileCasBytes = Meter.CreateHistogram<long>("scanner.file_cas_bytes");
|
|
|
|
public static void RecordLayerHit(string layerDigest)
|
|
=> LayerHits.Add(1, new KeyValuePair<string, object?>("layer", layerDigest));
|
|
|
|
public static void RecordLayerMiss(string layerDigest)
|
|
=> LayerMisses.Add(1, new KeyValuePair<string, object?>("layer", layerDigest));
|
|
|
|
public static void RecordLayerEviction(string layerDigest)
|
|
=> LayerEvictions.Add(1, new KeyValuePair<string, object?>("layer", layerDigest));
|
|
|
|
public static void RecordLayerBytes(long bytes)
|
|
=> LayerBytes.Record(bytes);
|
|
|
|
public static void RecordFileCasHit(string sha256)
|
|
=> FileCasHits.Add(1, new KeyValuePair<string, object?>("sha256", sha256));
|
|
|
|
public static void RecordFileCasMiss(string sha256)
|
|
=> FileCasMisses.Add(1, new KeyValuePair<string, object?>("sha256", sha256));
|
|
|
|
public static void RecordFileCasEviction(string sha256)
|
|
=> FileCasEvictions.Add(1, new KeyValuePair<string, object?>("sha256", sha256));
|
|
|
|
public static void RecordFileCasBytes(long bytes)
|
|
=> FileCasBytes.Record(bytes);
|
|
}
|