]> Cypherpunks.ru repositories - gostls13.git/commit
runtime/metrics: fix panic in readingAllMetric example
authorChangkun Ou <hi@changkun.de>
Sun, 7 Feb 2021 16:31:12 +0000 (17:31 +0100)
committerMichael Knyszek <mknyszek@google.com>
Mon, 8 Feb 2021 16:09:01 +0000 (16:09 +0000)
commit1901853098bbe25a1bbedc0ee53c6658d754151e
tree6d65563dc96a326d84add9d27855c932fa2dbcdf
parented3e4afa12d655a0c5606bcf3dd4e1cdadcb1476
runtime/metrics: fix panic in readingAllMetric example

medianBucket can return if the total is greater than thresh.
However, if a histogram has no counts, total and thresh
will both be zero and cause panic.

Adding an equal sign to prevent the potential panic.

Fixes #44148

Change-Id: Ifb8a781990f490d142ae7c035b4e01d6a07ae04d
Reviewed-on: https://go-review.googlesource.com/c/go/+/290171
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
src/runtime/metrics/example_test.go