From 823b8051c95f4a49c0209ee645354568be74fcf6 Mon Sep 17 00:00:00 2001 From: Solly Ross Date: Tue, 27 Jun 2017 19:59:39 -0400 Subject: [PATCH] Continue on error when processing series Previously, if we encountered an error while trying to update our series list, we'd return an error, aborting the processing of the entire batch. This could lead to the list of available metrics being severely out of date. Instead, we simply log an error when we fail to process a metric name, and skip it. --- pkg/custom-provider/metric_namer.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pkg/custom-provider/metric_namer.go b/pkg/custom-provider/metric_namer.go index fe71d24f..f65a115e 100644 --- a/pkg/custom-provider/metric_namer.go +++ b/pkg/custom-provider/metric_namer.go @@ -86,13 +86,13 @@ func (r *basicSeriesRegistry) SetSeries(newSeries []prom.Series) error { } else if namespaceLabel, hasNamespaceLabel := series.Labels["namespace"]; hasNamespaceLabel && namespaceLabel != "" { // TODO: handle metrics describing a namespace if err := r.namer.processNamespacedSeries(series, newInfo); err != nil { - // TODO: do we want to log this and continue, or abort? - return err + glog.Errorf("Unable to process namespaced series %q: %v", series.Name, err) + continue } } else { if err := r.namer.processRootScopedSeries(series, newInfo); err != nil { - // TODO: do we want to log this and continue, or abort? - return err + glog.Errorf("Unable to process root-scoped series %q: %v", series.Name, err) + continue } } } @@ -263,6 +263,7 @@ func (n *metricNamer) processContainerSeries(series prom.Series, infos map[provi // processNamespacedSeries adds the metric info for the given generic namespaced series to // the map of metric info. func (n *metricNamer) processNamespacedSeries(series prom.Series, infos map[provider.MetricInfo]seriesInfo) error { + // NB: all errors must occur *before* we save the series info name, metricKind := n.metricNameFromSeries(series) resources, err := n.groupResourcesFromSeries(series) if err != nil { @@ -294,6 +295,7 @@ func (n *metricNamer) processNamespacedSeries(series prom.Series, infos map[prov // processesRootScopedSeries adds the metric info for the given generic namespaced series to // the map of metric info. func (n *metricNamer) processRootScopedSeries(series prom.Series, infos map[provider.MetricInfo]seriesInfo) error { + // NB: all errors must occur *before* we save the series info name, metricKind := n.metricNameFromSeries(series) resources, err := n.groupResourcesFromSeries(series) if err != nil {