Skip to content

Commit 23f0008

Browse files
committed
fix: handle abbreviated proto tags such as h2 or h3
1 parent 9e7b76c commit 23f0008

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

output.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,13 @@ func (ms *metricStore) DeriveMetrics() {
243243

244244
func() {
245245
strCode, _ := ts.tags.Get("proto")
246-
newValue, _ := strconv.ParseFloat(strings.TrimPrefix(strCode, "HTTP/"), 32)
246+
strCode = strings.ToLower(strCode)
247+
strCode = strings.TrimPrefix(strCode, "http/") // Leave bare version for "HTTP/1.1"
248+
strCode = strings.TrimPrefix(strCode, "h") // Leave bare version for "h2"
249+
newValue, err := strconv.ParseFloat(strCode, 32)
250+
if err != nil {
251+
return // Invalid protocol, skip timeseries.
252+
}
247253
httpVersionTS := timeseries{
248254
name: "http_version",
249255
metricType: metrics.Gauge,

0 commit comments

Comments
 (0)