Skip to content

Commit de023f9

Browse files
author
Yen-Cheng Chou
committed
Do not retry on unrecoverable errors.
For error caused by unexpected metric name suffix or by unexpected metric type, it should return as unrecoverable error because retrying doesn't help the situation.
1 parent 17adc08 commit de023f9

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

retrieval/series_cache.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ var (
4343
keyReason, _ = tag.NewKey("reason")
4444
)
4545

46+
type unrecoverableError struct {
47+
error
48+
}
49+
4650
func init() {
4751
if err := view.Register(&view.View{
4852
Name: "prometheus_sidecar/dropped_series",
@@ -447,14 +451,14 @@ func (c *seriesCache) refresh(ctx context.Context, ref uint64) error {
447451
ts.MetricKind = metric_pb.MetricDescriptor_GAUGE
448452
ts.ValueType = metric_pb.MetricDescriptor_DOUBLE
449453
default:
450-
return errors.Errorf("unexpected metric name suffix %q", suffix)
454+
return unrecoverableError{errors.Errorf("unexpected metric name suffix %q", suffix)}
451455
}
452456
case textparse.MetricTypeHistogram:
453457
ts.Metric.Type = c.getMetricType(c.metricsPrefix, baseMetricName)
454458
ts.MetricKind = metric_pb.MetricDescriptor_CUMULATIVE
455459
ts.ValueType = metric_pb.MetricDescriptor_DISTRIBUTION
456460
default:
457-
return errors.Errorf("unexpected metric type %s", metadata.Type)
461+
return unrecoverableError{errors.Errorf("unexpected metric type %s", metadata.Type)}
458462
}
459463

460464
entry.proto = ts

retrieval/transform.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@ func (b *sampleBuilder) getSeriesWithRetry(ctx context.Context, sample tsdb.RefS
143143
if err == nil {
144144
break
145145
}
146+
if _, ok := err.(unrecoverableError); ok {
147+
return nil, false, err
148+
}
146149
level.Warn(b.logger).Log("msg", "failed to get seriesCacheEntry", "err", err)
147150
backoff = exponential(backoff)
148151
if backoff > 0 {

0 commit comments

Comments
 (0)