fix: only write metrics if there is a useragent
Some checks failed
test / test (push) Waiting to run
release / release (push) Has been cancelled

This commit is contained in:
Marvin Preuss 2024-09-23 12:48:35 +02:00
parent 757d47fc41
commit 7c5c1d6406

View File

@ -39,6 +39,7 @@ func parseFunc(t *tail.Tail) {
continue
}
if len(l.Request.Headers.UserAgent) != 0 {
metrics.GetOrCreateCounter(
fmt.Sprintf(
`%s_http_request_total{host="%s", proto="%s", method="%s", status="%d", user_agent="%s"}`,
@ -61,5 +62,8 @@ func parseFunc(t *tail.Tail) {
l.Status,
),
).Update(l.Duration)
} else {
slog.Warn("got empty user agent", "headers", l.Request.Headers)
}
}
}