Skip to content

Commit

Permalink
Fix nil pointer exception in kubeletstats receiver (#404)
Browse files Browse the repository at this point in the history
For the pods that are just created, some stats can be absent. And it causes crashing the otel agent with nil pointer exception.
  • Loading branch information
dmitryax authored Jul 7, 2020
1 parent 4e6b676 commit 3d8fc69
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion receiver/kubeletstatsreceiver/kubelet/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

0 comments on commit 3d8fc69

Please sign in to comment.