TsgcWSCircuitBreaker › Properties › Metrics
Read-only aggregate counters exposed for dashboards, logging and alerting.
property Metrics: TsgcCircuitBreakerMetrics read FMetrics;
—
Atomic counters updated internally as calls flow through the breaker, aggregated across all keys / hostnames. Sub-properties: TotalCalls (Int64 — total calls processed), TotalFailures (Int64 — failures recorded), TotalSuccesses (Int64 — successful calls recorded), TotalRejected (Int64 — calls rejected because the circuit was Open), CurrentOpenBreakers (Integer — number of keys currently in the Open state; refreshed after every state transition) and AverageLatencyMs (Double — running average latency in ms measured around Execute / ExecuteWithResult calls). Poll from a TTimer to paint live gauges for operators, or emit to Prometheus / StatsD for alerting. Metrics is read-only; use ResetAll to zero every counter.
// Poll Metrics from a TTimer to update a dashboard
procedure TForm1.MetricsTimer(Sender: TObject);
begin
LabelCalls.Caption := Format('Calls: %d (ok %d / fail %d / rejected %d)',
[sgcWSCircuitBreaker1.Metrics.TotalCalls,
sgcWSCircuitBreaker1.Metrics.TotalSuccesses,
sgcWSCircuitBreaker1.Metrics.TotalFailures,
sgcWSCircuitBreaker1.Metrics.TotalRejected]);
LabelOpen.Caption := Format('Open breakers: %d',
[sgcWSCircuitBreaker1.Metrics.CurrentOpenBreakers]);
LabelLatency.Caption := Format('Avg latency: %.1f ms',
[sgcWSCircuitBreaker1.Metrics.AverageLatencyMs]);
end;