TsgcWSCircuitBreakerEvents › OnFailureRecorded

OnFailureRecorded Event

Fired every time a failure is recorded against a circuit, after Classification has accepted it.

Syntax

property OnFailureRecorded: TsgcCircuitBreakerOnFailureRecorded;
// TsgcCircuitBreakerOnFailureRecorded = procedure(Sender: TObject; const aKey, aException: string) of object

Default Value

Remarks

Fires after RecordFailure / RecordMessageError (or the HTTP API client integration) records a failure and Classification has confirmed it should count. The aKey parameter identifies the circuit and aException carries the ClassName: Message text passed to RecordFailure — useful to correlate with upstream incident tracking, emit structured logs or forward to a sink such as Seq / Sentry / Application Insights. The event does not fire for failures that Classification chose to ignore, and it fires before EvaluateTransition decides whether to open the circuit — for the state change itself use OnStateChange. Runs synchronously on the recording thread.

Example

procedure TForm1.CircuitFailureRecorded(Sender: TObject;
  const aKey, aException: string);
begin
  Log(Format('Failure on %s: %s', [aKey, aException]));
  // Stream to structured logger / incident tracker
  SeqLogger.Error('circuit.failure',
    ['key', aKey, 'exception', aException]);
end;

Back to Events