Skip to content

Commit

Permalink
add check for nil
Browse files Browse the repository at this point in the history
  • Loading branch information
huyan0 committed Aug 27, 2020
1 parent 2fb133f commit 57d2e1f
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions exporter/prometheusremotewriteexporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,19 @@ func (prwe *prwExporter) pushMetrics(ctx context.Context, md pdata.Metrics) (int
errs := []string{}

resourceMetrics := data.MetricDataToOtlp(pdatautil.MetricsToInternalMetrics(md))
for _, r := range resourceMetrics {
for _, instMetrics := range r.InstrumentationLibraryMetrics {
for _, resourceMetric := range resourceMetrics {
if resourceMetric == nil {
continue
}
for _, instMetrics := range resourceMetric.InstrumentationLibraryMetrics {
if instMetrics == nil {
continue
}
// TODO: decide if instrumentation library information should be exported as labels
for _, metric := range instMetrics.Metrics {
if metric == nil {
continue
}
// check for valid type and temporality combination
if ok := validateMetrics(metric.MetricDescriptor); !ok {
dropped++
Expand Down

0 comments on commit 57d2e1f

Please sign in to comment.