save progress
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
// Description: Prometheus gauges for Bitwise, Semantic, and Policy fidelity metrics
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.Metrics;
|
||||
|
||||
namespace StellaOps.Telemetry.Core;
|
||||
@@ -43,27 +44,27 @@ public sealed class FidelityMetricsTelemetry : IDisposable
|
||||
var opts = options ?? new FidelityTelemetryOptions();
|
||||
_meter = new Meter(MeterName, opts.Version);
|
||||
|
||||
_bitwiseFidelityGauge = _meter.CreateObservableGauge(
|
||||
_bitwiseFidelityGauge = _meter.CreateObservableGauge<double>(
|
||||
name: "fidelity_bitwise_ratio",
|
||||
observeValue: () => ObserveMetric(s => s.BitwiseFidelity),
|
||||
observeValues: () => ObserveMetric(s => s.BitwiseFidelity),
|
||||
unit: "{ratio}",
|
||||
description: "Bitwise fidelity ratio (identical_outputs / total_replays).");
|
||||
|
||||
_semanticFidelityGauge = _meter.CreateObservableGauge(
|
||||
_semanticFidelityGauge = _meter.CreateObservableGauge<double>(
|
||||
name: "fidelity_semantic_ratio",
|
||||
observeValue: () => ObserveMetric(s => s.SemanticFidelity),
|
||||
observeValues: () => ObserveMetric(s => s.SemanticFidelity),
|
||||
unit: "{ratio}",
|
||||
description: "Semantic fidelity ratio (semantically equivalent outputs / total).");
|
||||
|
||||
_policyFidelityGauge = _meter.CreateObservableGauge(
|
||||
_policyFidelityGauge = _meter.CreateObservableGauge<double>(
|
||||
name: "fidelity_policy_ratio",
|
||||
observeValue: () => ObserveMetric(s => s.PolicyFidelity),
|
||||
observeValues: () => ObserveMetric(s => s.PolicyFidelity),
|
||||
unit: "{ratio}",
|
||||
description: "Policy fidelity ratio (matching policy decisions / total).");
|
||||
|
||||
_totalReplaysGauge = _meter.CreateObservableGauge(
|
||||
_totalReplaysGauge = _meter.CreateObservableGauge<int>(
|
||||
name: "fidelity_total_replays",
|
||||
observeValue: () => ObserveMetric(s => s.TotalReplays),
|
||||
observeValues: () => ObserveMetric(s => s.TotalReplays),
|
||||
unit: "{replays}",
|
||||
description: "Total number of replay runs measured.");
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ public sealed class TimeToEvidenceMetrics : IDisposable
|
||||
private bool _disposed;
|
||||
|
||||
private readonly Histogram<double> _phaseLatencyHistogram;
|
||||
private readonly Histogram<double> _scanDurationHistogram;
|
||||
private readonly Counter<long> _phaseCompletedCounter;
|
||||
private readonly Counter<long> _phaseFailedCounter;
|
||||
private readonly Counter<long> _sloBreachCounter;
|
||||
@@ -38,6 +39,11 @@ public sealed class TimeToEvidenceMetrics : IDisposable
|
||||
unit: "s",
|
||||
description: "Latency of TTE phases in seconds.");
|
||||
|
||||
_scanDurationHistogram = _meter.CreateHistogram<double>(
|
||||
name: "tte_scan_duration_seconds",
|
||||
unit: "s",
|
||||
description: "Total scan duration in seconds.");
|
||||
|
||||
_phaseCompletedCounter = _meter.CreateCounter<long>(
|
||||
name: "tte_phase_completed_total",
|
||||
unit: "{phase}",
|
||||
@@ -119,6 +125,18 @@ public sealed class TimeToEvidenceMetrics : IDisposable
|
||||
_decisionMadeCounter.Add(1, tags);
|
||||
}
|
||||
|
||||
public void RecordScanDuration(string tenantId, string surfaceId, int durationMs, int findingCount)
|
||||
{
|
||||
var tags = new TagList
|
||||
{
|
||||
{ "tenant_id", string.IsNullOrWhiteSpace(tenantId) ? "unknown" : tenantId },
|
||||
{ "surface", string.IsNullOrWhiteSpace(surfaceId) ? "unknown" : surfaceId },
|
||||
{ "finding_bucket", BucketFindingCount(findingCount) },
|
||||
};
|
||||
|
||||
_scanDurationHistogram.Record(Math.Max(0, durationMs) / 1000.0, tags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Records an SLO breach directly.
|
||||
/// </summary>
|
||||
@@ -173,6 +191,18 @@ public sealed class TimeToEvidenceMetrics : IDisposable
|
||||
_meter.Dispose();
|
||||
}
|
||||
|
||||
private static string BucketFindingCount(int findingCount)
|
||||
{
|
||||
return findingCount switch
|
||||
{
|
||||
<= 0 => "0",
|
||||
<= 10 => "1_10",
|
||||
<= 100 => "11_100",
|
||||
<= 1000 => "101_1000",
|
||||
_ => "1001_plus"
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Measurement scope for TTE phases.
|
||||
/// </summary>
|
||||
|
||||
@@ -46,27 +46,27 @@ public sealed class TtePercentileExporter : IDisposable
|
||||
|
||||
_meter = new Meter(MeterName, opts.Version);
|
||||
|
||||
_p50Gauge = _meter.CreateObservableGauge(
|
||||
_p50Gauge = _meter.CreateObservableGauge<double>(
|
||||
name: "tte_latency_p50_seconds",
|
||||
observeValue: () => ObservePercentile(0.50),
|
||||
observeValues: () => ObservePercentile(0.50),
|
||||
unit: "s",
|
||||
description: "50th percentile (median) TTE latency in seconds.");
|
||||
|
||||
_p90Gauge = _meter.CreateObservableGauge(
|
||||
_p90Gauge = _meter.CreateObservableGauge<double>(
|
||||
name: "tte_latency_p90_seconds",
|
||||
observeValue: () => ObservePercentile(0.90),
|
||||
observeValues: () => ObservePercentile(0.90),
|
||||
unit: "s",
|
||||
description: "90th percentile TTE latency in seconds.");
|
||||
|
||||
_p99Gauge = _meter.CreateObservableGauge(
|
||||
_p99Gauge = _meter.CreateObservableGauge<double>(
|
||||
name: "tte_latency_p99_seconds",
|
||||
observeValue: () => ObservePercentile(0.99),
|
||||
observeValues: () => ObservePercentile(0.99),
|
||||
unit: "s",
|
||||
description: "99th percentile TTE latency in seconds.");
|
||||
|
||||
_maxGauge = _meter.CreateObservableGauge(
|
||||
_maxGauge = _meter.CreateObservableGauge<double>(
|
||||
name: "tte_latency_max_seconds",
|
||||
observeValue: () => ObservePercentile(1.0),
|
||||
observeValues: () => ObservePercentile(1.0),
|
||||
unit: "s",
|
||||
description: "Maximum TTE latency in seconds.");
|
||||
}
|
||||
|
||||
@@ -6,4 +6,5 @@ This file mirrors sprint work for the Telemetry Core module.
|
||||
| --- | --- | --- | --- |
|
||||
| `DET-3401-005` | `docs/implplan/SPRINT_3401_0001_0001_determinism_scoring_foundations.md` | DONE (2025-12-14) | Added `ProofCoverageMetrics` (`System.Diagnostics.Metrics`) in `src/Telemetry/StellaOps.Telemetry.Core/StellaOps.Telemetry.Core/ProofCoverageMetrics.cs` and tests in `src/Telemetry/StellaOps.Telemetry.Core/StellaOps.Telemetry.Core.Tests/ProofCoverageMetricsTests.cs`. |
|
||||
| `TTFS-0338-001` | `docs/implplan/SPRINT_0338_0001_0001_ttfs_foundation.md` | DONE (2025-12-15) | Added `TimeToFirstSignalMetrics`/`TimeToFirstSignalOptions`, DI extension `AddTimeToFirstSignalMetrics`, and unit tests `TimeToFirstSignalMetricsTests`. |
|
||||
| `TTFS-0341-001` | `docs/implplan/SPRINT_0341_0001_0001_ttfs_enhancements.md` | DONE (2025-12-18) | Fixed metrics compilation (`Gauge<>` generics / parameter naming) and added missing `RecordScanDuration(...)` + `tte_scan_duration_seconds` histogram for TTFS telemetry. |
|
||||
|
||||
|
||||
Reference in New Issue
Block a user