Melika Kheirieh commited on
Commit
1c4cb86
·
1 Parent(s): 65f2e2c

feat(metrics): add repair_attempts_total and wire into repair loop outcomes

Browse files
Files changed (2) hide show
  1. nl2sql/metrics.py +11 -0
  2. nl2sql/pipeline.py +4 -1
nl2sql/metrics.py CHANGED
@@ -49,6 +49,17 @@ verifier_failures_total = Counter(
49
  registry=REGISTRY,
50
  )
51
 
 
 
 
 
 
 
 
 
 
 
 
52
  # -----------------------------------------------------------------------------
53
  # Pipeline-level metrics
54
  # -----------------------------------------------------------------------------
 
49
  registry=REGISTRY,
50
  )
51
 
52
+ # -----------------------------------------------------------------------------
53
+ # Repair stage metrics
54
+ # -----------------------------------------------------------------------------
55
+ repair_attempts_total = Counter(
56
+ "repair_attempts_total",
57
+ "Number of repair loop attempts",
58
+ ["outcome"], # success | failed
59
+ registry=REGISTRY,
60
+ )
61
+
62
+
63
  # -----------------------------------------------------------------------------
64
  # Pipeline-level metrics
65
  # -----------------------------------------------------------------------------
nl2sql/pipeline.py CHANGED
@@ -13,7 +13,7 @@ from nl2sql.executor import Executor
13
  from nl2sql.verifier import Verifier
14
  from nl2sql.repair import Repair
15
  from nl2sql.stubs import NoOpExecutor, NoOpRepair, NoOpVerifier
16
- from nl2sql.metrics import stage_duration_ms, pipeline_runs_total
17
 
18
 
19
  @dataclass(frozen=True)
@@ -369,7 +369,10 @@ class Pipeline:
369
  if r_ver2.data and "sql" in r_ver2.data and r_ver2.data["sql"]:
370
  sql = r_ver2.data["sql"]
371
  if verified:
 
372
  break
 
 
373
 
374
  # --- 8) optional soft auto-verify (executor success, no details) ---
375
  if (verified is None or not verified) and not details:
 
13
  from nl2sql.verifier import Verifier
14
  from nl2sql.repair import Repair
15
  from nl2sql.stubs import NoOpExecutor, NoOpRepair, NoOpVerifier
16
+ from nl2sql.metrics import stage_duration_ms, pipeline_runs_total, repair_attempts_total
17
 
18
 
19
  @dataclass(frozen=True)
 
369
  if r_ver2.data and "sql" in r_ver2.data and r_ver2.data["sql"]:
370
  sql = r_ver2.data["sql"]
371
  if verified:
372
+ repair_attempts_total.labels(outcome="success").inc()
373
  break
374
+ else:
375
+ repair_attempts_total.labels(outcome="failed").inc()
376
 
377
  # --- 8) optional soft auto-verify (executor success, no details) ---
378
  if (verified is None or not verified) and not details: