diff options
| author | Mohamed Hegazy <mhegazy@anthropic.com> | 2026-10-22 00:12:11 +0000 |
|---|---|---|
| committer | Claude <noreply@anthropic.com> | 2026-10-22 00:12:11 +0000 |
| commit | de9e075c828f2c4438d26571dc6046472381a085 (patch) | |
| tree | c3183dd3a3dbd529c517c18500a0dd95c533760c /plugins/security-guidance/hooks/_base.py | |
| parent | 437cb57a9d19329a8e6ef3ed79e19adb45e83d50 (diff) | |
| parent | af59ee3a1051a29dda4a2e7a2af221aa457ae08b (diff) | |
Merge branch 'main' into mhegazy/sg-diff-seen-countmhegazy/sg-diff-seen-count
Keeps both sides in emit_metrics: diff_seen stays after the other review
tail keys, and the launcher probe keys stay after everything else.
Diffstat (limited to 'plugins/security-guidance/hooks/_base.py')
| -rw-r--r-- | plugins/security-guidance/hooks/_base.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/plugins/security-guidance/hooks/_base.py b/plugins/security-guidance/hooks/_base.py index 59e8e569..e5959e68 100644 --- a/plugins/security-guidance/hooks/_base.py +++ b/plugins/security-guidance/hooks/_base.py @@ -330,6 +330,26 @@ def _log_usage(usage): ) +def launcher_probe_metrics(): + """How long sg-python.sh waited for interpreters to answer its probe. + + Only when this launch's probes took a second or more together, so ordinary + rows carry no extra keys: `launcher_probe_ms` is all of them, + `launcher_probe_max_ms` the slowest one. Both are capped at an hour (the + launcher reads the wall clock, which can jump). Read once: the variables + are removed so child processes do not report this launch as their own. + """ + try: + slowest = int(os.environ.pop("SG_LAUNCHER_PROBE_MAX_MS", "")) + total = int(os.environ.pop("SG_LAUNCHER_PROBE_MS", "")) + except ValueError: + return {} + if total < 1000 or slowest > total: + return {} + cap = 3_600_000 + return {"launcher_probe_ms": min(total, cap), "launcher_probe_max_ms": min(slowest, cap)} + + def _usage_metrics(): """Snapshot the accumulator as metric keys. Returns {} when no API calls AND no HTTP errors were made so skip-path emits don't burn key budget. |
