From 1b56b5c49715c6399e7e4e17a2a9cde53e78e955 Mon Sep 17 00:00:00 2001 From: beorn7 Date: Tue, 29 May 2018 17:51:55 +0200 Subject: [PATCH] Be more robust about nil pointers in protobuf While not strictly correct, it can easily happen that proto messages are created that use nil pointers instead of pointers in empty strings to denote an empty string. Signed-off-by: beorn7 --- prometheus/registry.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/prometheus/registry.go b/prometheus/registry.go index 1f9adb8..94b7b4b 100644 --- a/prometheus/registry.go +++ b/prometheus/registry.go @@ -727,8 +727,8 @@ func checkMetricConsistency( } for _, labelPair := range dtoMetric.GetLabel() { - if !utf8.ValidString(*labelPair.Value) { - return fmt.Errorf("collected metric's label %s is not utf8: %#v", *labelPair.Name, *labelPair.Value) + if !utf8.ValidString(labelPair.GetValue()) { + return fmt.Errorf("collected metric's label %s is not utf8: %#v", labelPair.GetName(), labelPair.GetValue()) } }