Skip to content

Commit a85f7ac

Browse files
committed
zero check
1 parent f1cd323 commit a85f7ac

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

metrics/go_metrics.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,9 @@ func (me *Metrics) RecordRequest(labels Labels) {
614614
}
615615

616616
// Request size by endpoint
617-
me.RequestSizeByEndpoint[GetEndpointFromRequestType(labels.RType)].Update(int64(labels.RequestSize))
617+
if labels.RequestSize > 0 {
618+
me.RequestSizeByEndpoint[GetEndpointFromRequestType(labels.RType)].Update(int64(labels.RequestSize))
619+
}
618620

619621
// Handle the account metrics now.
620622
am := me.getAccountMetrics(labels.PubID)

metrics/prometheus/prometheus.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -675,10 +675,12 @@ func (m *Metrics) RecordRequest(labels metrics.Labels) {
675675
requestStatusLabel: string(labels.RequestStatus),
676676
}).Inc()
677677

678-
endpoint := metrics.GetEndpointFromRequestType(labels.RType)
679-
m.requestsSize.With(prometheus.Labels{
680-
requestEndpointLabel: string(endpoint),
681-
}).Observe(float64(labels.RequestSize))
678+
if labels.RequestSize > 0 {
679+
endpoint := metrics.GetEndpointFromRequestType(labels.RType)
680+
m.requestsSize.With(prometheus.Labels{
681+
requestEndpointLabel: string(endpoint),
682+
}).Observe(float64(labels.RequestSize))
683+
}
682684

683685
if labels.CookieFlag == metrics.CookieFlagNo {
684686
m.requestsWithoutCookie.With(prometheus.Labels{

0 commit comments

Comments
 (0)