fraudtwin.observability#

Optional run metrics and observability sessions.

Status: Optional

Classes#

fraudtwin.observability.MetricsSession

Expose the stable M27 metric surface for one CLI invocation.

Exceptions#

fraudtwin.observability.ObservabilityDependencyError

Raised when metrics are requested without the optional dependency.

Detailed API#

Optional Prometheus metrics for short-lived FraudTwin CLI jobs.

Metrics are deliberately kept outside generated manifests and configuration hashes. The CLI starts an isolated registry only when explicitly requested, publishes run-level values, and holds the endpoint briefly so a local Prometheus instance can scrape the completed batch job.

class fraudtwin.observability.MetricsSession(host, port, hold_seconds=15.0)[source][source]

Bases: object

Expose the stable M27 metric surface for one CLI invocation.

Parameters:
  • host (str)

  • port (int)

  • hold_seconds (float)

start()[source][source]

Start the local exposition endpoint.

Return type:

None

observe_manifest(manifest, elapsed_seconds)[source][source]

Publish final generation metrics from the immutable run manifest.

Return type:

None

Parameters:
  • manifest (RunManifest)

  • elapsed_seconds (float)

record_generator_error()[source][source]

Count a failed generation invocation without hiding its exception.

Return type:

None

record_ledger_validation(run_id, failed)[source][source]

Record the result of the existing ledger validator.

Return type:

None

Parameters:
  • run_id (str)

  • failed (bool)

finish()[source][source]

Hold the endpoint for scraping, then stop its serving thread.

Return type:

None

exception fraudtwin.observability.ObservabilityDependencyError[source][source]

Bases: RuntimeError

Raised when metrics are requested without the optional dependency.