fix(sec): санитизация Telegram-ошибок, SSRF-guard Webhook, чистка логов test-канала, go mod tidy, histogram-бакеты

This commit is contained in:
2026-07-04 13:40:29 +07:00
parent 5a2903ca1e
commit 29f448d4b5
8 changed files with 197 additions and 6 deletions
+20
View File
@@ -27,6 +27,26 @@ func TestMetricsRecord(t *testing.T) {
}
}
func TestCheckDurationUsesNetworkCallBuckets(t *testing.T) {
m := New()
m.ObserveCheck("in_sync", 100*time.Millisecond)
rec := httptest.NewRecorder()
m.Handler().ServeHTTP(rec, httptest.NewRequest("GET", "/metrics", nil))
body := rec.Body.String()
// DefBuckets (le="0.005", ...) is tuned for sub-10ms in-process calls;
// dns_ar_check_duration_seconds is a network call to a DNS provider, so
// it must use the wider explicit buckets instead.
for _, want := range []string{`le="0.05"`, `le="1"`, `le="30"`} {
if !strings.Contains(body, `dns_ar_check_duration_seconds_bucket{`+want) {
t.Fatalf("expected bucket %s in exposed metrics:\n%s", want, body)
}
}
if strings.Contains(body, `dns_ar_check_duration_seconds_bucket{le="0.005"`) {
t.Fatalf("found default histogram bucket 0.005, expected custom buckets:\n%s", body)
}
}
func TestHandlerExposesMetrics(t *testing.T) {
m := New()
m.ObserveCheck("in_sync", time.Millisecond)