From 24f4db3d2084d80da5f3f0fba6bb58d5c193062d Mon Sep 17 00:00:00 2001 From: Yang Hu Date: Thu, 27 Aug 2020 11:44:57 -0500 Subject: [PATCH] add check for nil --- exporter/prometheusremotewriteexporter/exporter.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/exporter/prometheusremotewriteexporter/exporter.go b/exporter/prometheusremotewriteexporter/exporter.go index 62904ef5f98..9c6c128de53 100644 --- a/exporter/prometheusremotewriteexporter/exporter.go +++ b/exporter/prometheusremotewriteexporter/exporter.go @@ -91,10 +91,19 @@ func (prwe *prwExporter) pushMetrics(ctx context.Context, md pdata.Metrics) (int resourceMetrics := data.MetricDataToOtlp(pdatautil.MetricsToInternalMetrics(md)) for _, resourceMetric := range resourceMetrics { + if resourceMetric == nil { + continue + } // TODO: add resource attributes as labels, probably in next PR for _, instrumentationMetrics := range resourceMetric.InstrumentationLibraryMetrics { + if instrumentationMetrics == nil { + continue + } // TODO: decide if instrumentation library information should be exported as labels for _, metric := range instrumentationMetrics.Metrics { + if metric == nil { + continue + } // check for valid type and temporality combination if ok := validateMetrics(metric.MetricDescriptor); !ok { dropped++