From 3d8fc69b22cf6d872434ba4fb7f275ff5c7aa6bc Mon Sep 17 00:00:00 2001 From: Dmitrii Anoshin Date: Tue, 7 Jul 2020 10:27:56 -0700 Subject: [PATCH] Fix nil pointer exception in kubeletstats receiver (#404) For the pods that are just created, some stats can be absent. And it causes crashing the otel agent with nil pointer exception. --- receiver/kubeletstatsreceiver/kubelet/utils.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/receiver/kubeletstatsreceiver/kubelet/utils.go b/receiver/kubeletstatsreceiver/kubelet/utils.go index 414336b58a5b..5cc7bee6b57c 100644 --- a/receiver/kubeletstatsreceiver/kubelet/utils.go +++ b/receiver/kubeletstatsreceiver/kubelet/utils.go @@ -59,5 +59,7 @@ func labels(labels map[string]string, descriptions map[string]string) ( } func applyLabels(metric *metricspb.Metric, attrs map[string]string) { - metric.MetricDescriptor.LabelKeys, metric.Timeseries[0].LabelValues = labels(attrs, nil) + if metric != nil { + metric.MetricDescriptor.LabelKeys, metric.Timeseries[0].LabelValues = labels(attrs, nil) + } }