Skip to content

Commit 2ae281d

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 3905d55 commit 2ae281d

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
@@ -44,6 +44,10 @@ var (
4444
keyReason, _ = tag.NewKey("reason")
4545
)
4646

47+
type unrecoverableError struct {
48+
error
49+
}
50+
4751
func init() {
4852
if err := view.Register(&view.View{
4953
Name: "prometheus_sidecar/dropped_series",
@@ -422,14 +426,14 @@ func (c *seriesCache) refresh(ctx context.Context, ref uint64) error {
422426
ts.MetricKind = metric_pb.MetricDescriptor_GAUGE
423427
ts.ValueType = metric_pb.MetricDescriptor_DOUBLE
424428
default:
425-
return errors.Errorf("unexpected metric name suffix %q", suffix)
429+
return unrecoverableError{errors.Errorf("unexpected metric name suffix %q", suffix)}
426430
}
427431
case textparse.MetricTypeHistogram:
428432
ts.Metric.Type = c.getMetricType(c.metricsPrefix, baseMetricName)
429433
ts.MetricKind = metric_pb.MetricDescriptor_CUMULATIVE
430434
ts.ValueType = metric_pb.MetricDescriptor_DISTRIBUTION
431435
default:
432-
return errors.Errorf("unexpected metric type %s", metadata.Type)
436+
return unrecoverableError{errors.Errorf("unexpected metric type %s", metadata.Type)}
433437
}
434438

435439
entry.proto = ts

retrieval/transform.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ func (b *sampleBuilder) getSeriesWithRetry(ctx context.Context, sample tsdb.RefS
135135
if err == nil {
136136
break
137137
}
138+
if _, ok := err.(unrecoverableError); ok {
139+
return nil, false, err
140+
}
138141
level.Warn(b.logger).Log("msg", "failed to get seriesCacheEntry", "err", err)
139142
backoff = exponential(backoff)
140143
if backoff > 0 {

0 commit comments

Comments
 (0)