Skip to content

Commit 6a2f502

Browse files
[r353] Revert "otlp: Stick to OTLP vocabulary on invalid label value length error (#11889)" (#12265)
This reverts commit 9bf900e.
1 parent efc9ef7 commit 6a2f502

6 files changed

Lines changed: 29 additions & 106 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@
7070
* Renamed `cortex_ingest_storage_writer_produce_requests_total` to `cortex_ingest_storage_writer_produce_records_enqueued_total`
7171
* Renamed `cortex_ingest_storage_writer_produce_failures_total` to `cortex_ingest_storage_writer_produce_records_failed_total`
7272
* [CHANGE] Distributor: moved HA tracker timeout config to limits. #11774
73-
* Moved `distributor.ha_tracker.ha_tracker_update_timeout` to `limits.ha_tracker_update_timeout`.
74-
* Moved `distributor.ha_tracker.ha_tracker_update_timeout_jitter_max` to `limits.ha_tracker_update_timeout_jitter_max`.
75-
* Moved `distributor.ha_tracker.ha_tracker_failover_timeout` to `limits.ha_tracker_failover_timeout`.
73+
* Moved `distributor.ha_tracker.ha_tracker_update_timeout` to `limits.ha_tracker.ha_tracker_update_timeout`
74+
* Moved `distributor.ha_tracker.ha_tracker_update_timeout_jitter_max` to `limits.ha_tracker.ha_tracker_update_timeout_jitter_max`
75+
* Moved `distributor.ha_tracker.ha_tracker_failover_timeout` to `limits.ha_tracker.ha_tracker_failover_timeout`
7676
* [CHANGE] Distributor: `Memberlist` marked as stable as an option for backend storage for the HA tracker. #11861
7777
* [CHANGE] Distributor: `etcd` deprecated as an option for backend storage for the HA tracker. #12047
7878
* [CHANGE] Memberlist: Apply new default configuration values for MemberlistKV. This unlocks using it as backend storage for the HA Tracker. We have observed better performance with these defaults across different production loads. #11874
@@ -157,7 +157,6 @@
157157
* [ENHANCEMENT] Query-frontend: Accurate tracking of samples processed from cache. #11719
158158
* [ENHANCEMENT] Store-gateway: Change level 0 blocks to be reported as 'unknown/old_block' in metrics instead of '0' to improve clarity. Level 0 indicates blocks with metadata from before compaction level tracking was added to the bucket index. #11891
159159
* [ENHANCEMENT] Compactor, distributor, ruler, scheduler and store-gateway: Makes `-<component-ring-config>.auto-forget-unhealthy-periods` configurable for each component. Deprecates the `-store-gateway.sharding-ring.auto-forget-enabled` flag. #11923
160-
* [ENHANCEMENT] otlp: Stick to OTLP vocabulary on invalid label value length error. #11889
161160
* [ENHANCEMENT] Stagger head compaction intervals across zones to prevent compactions from aligning simultaneously, which could otherwise cause strong consistency queries to fail with experimental ingest storage is enabled. #12090
162161
* [BUGFIX] OTLP: Fix response body and Content-Type header to align with spec. #10852
163162
* [BUGFIX] Compactor: fix issue where block becomes permanently stuck when the Compactor's block cleanup job partially deletes a block. #10888

pkg/distributor/errors.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,6 @@ func (e validationError) Cause() mimirpb.ErrorCause {
120120
return mimirpb.BAD_DATA
121121
}
122122

123-
func (e validationError) Unwrap() error {
124-
return e.error
125-
}
126-
127123
// Ensure that validationError implements Error.
128124
var _ Error = validationError{}
129125

pkg/distributor/otel.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,6 @@ func OTLPHandler(
135135
writeErrorToHTTPResponseBody(r, w, statusClientClosedRequest, codes.Canceled, "push request context canceled", logger)
136136
return
137137
}
138-
if labelValueTooLongErr := (LabelValueTooLongError{}); errors.As(pushErr, &labelValueTooLongErr) {
139-
// Translate from Mimir to OTel domain terminology
140-
pushErr = newValidationError(otelAttributeValueTooLongError{labelValueTooLongErr})
141-
}
142138
var (
143139
httpCode int
144140
grpcCode codes.Code
@@ -717,14 +713,3 @@ func translateBucketsLayout(spans []prompb.BucketSpan, deltas []int64) (int32, [
717713

718714
return firstSpan.Offset - 1, buckets
719715
}
720-
721-
type otelAttributeValueTooLongError struct {
722-
LabelValueTooLongError
723-
}
724-
725-
func (e otelAttributeValueTooLongError) Error() string {
726-
return fmt.Sprintf(
727-
"received a metric whose attribute value length exceeds the limit of %d, attribute: '%s', value: '%.200s' (truncated) metric: '%.200s'. See: https://grafana.com/docs/grafana-cloud/send-data/otlp/otlp-format-considerations/#metrics-ingestion-limits",
728-
e.Limit, e.Label.Name, e.Label.Value, mimirpb.FromLabelAdaptersToString(e.Series),
729-
)
730-
}

pkg/distributor/otel_test.go

Lines changed: 13 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818

1919
"github.com/go-kit/log"
2020
"github.com/grafana/dskit/concurrency"
21-
"github.com/grafana/dskit/flagext"
2221
"github.com/grafana/dskit/httpgrpc"
2322
"github.com/grafana/dskit/middleware"
2423
"github.com/grafana/dskit/user"
@@ -34,7 +33,6 @@ import (
3433
"go.opentelemetry.io/collector/pdata/pmetric/pmetricotlp"
3534
"google.golang.org/genproto/googleapis/rpc/status"
3635
"google.golang.org/grpc/codes"
37-
grpcstatus "google.golang.org/grpc/status"
3836
"google.golang.org/protobuf/proto"
3937

4038
"github.com/grafana/mimir/pkg/mimirpb"
@@ -941,7 +939,7 @@ func TestHandlerOTLPPush(t *testing.T) {
941939
metadata []mimirpb.MetricMetadata
942940
compression string
943941
maxMsgSize int
944-
verifyFunc func(*testing.T, context.Context, *Request, testCase) error
942+
verifyFunc func(*testing.T, *Request, testCase) error
945943
requestContentType string
946944
responseCode int
947945
responseContentType string
@@ -954,7 +952,7 @@ func TestHandlerOTLPPush(t *testing.T) {
954952
resourceAttributePromotionConfig OTelResourceAttributePromotionConfig
955953
}
956954

957-
samplesVerifierFunc := func(t *testing.T, _ context.Context, pushReq *Request, tc testCase) error {
955+
samplesVerifierFunc := func(t *testing.T, pushReq *Request, tc testCase) error {
958956
t.Helper()
959957

960958
request, err := pushReq.WriteRequest()
@@ -1056,7 +1054,7 @@ func TestHandlerOTLPPush(t *testing.T) {
10561054
maxMsgSize: 30,
10571055
series: sampleSeries,
10581056
metadata: sampleMetadata,
1059-
verifyFunc: func(_ *testing.T, _ context.Context, pushReq *Request, _ testCase) error {
1057+
verifyFunc: func(_ *testing.T, pushReq *Request, _ testCase) error {
10601058
_, err := pushReq.WriteRequest()
10611059
return err
10621060
},
@@ -1072,7 +1070,7 @@ func TestHandlerOTLPPush(t *testing.T) {
10721070
maxMsgSize: 100000,
10731071
series: sampleSeries,
10741072
metadata: sampleMetadata,
1075-
verifyFunc: func(_ *testing.T, _ context.Context, pushReq *Request, _ testCase) error {
1073+
verifyFunc: func(_ *testing.T, pushReq *Request, _ testCase) error {
10761074
_, err := pushReq.WriteRequest()
10771075
return err
10781076
},
@@ -1088,7 +1086,7 @@ func TestHandlerOTLPPush(t *testing.T) {
10881086
maxMsgSize: 100000,
10891087
series: sampleSeries,
10901088
metadata: sampleMetadata,
1091-
verifyFunc: func(_ *testing.T, _ context.Context, pushReq *Request, _ testCase) error {
1089+
verifyFunc: func(_ *testing.T, pushReq *Request, _ testCase) error {
10921090
_, err := pushReq.WriteRequest()
10931091
return err
10941092
},
@@ -1105,7 +1103,7 @@ func TestHandlerOTLPPush(t *testing.T) {
11051103
maxMsgSize: 30,
11061104
series: sampleSeries,
11071105
metadata: sampleMetadata,
1108-
verifyFunc: func(_ *testing.T, _ context.Context, pushReq *Request, _ testCase) error {
1106+
verifyFunc: func(_ *testing.T, pushReq *Request, _ testCase) error {
11091107
_, err := pushReq.WriteRequest()
11101108
return err
11111109
},
@@ -1121,7 +1119,7 @@ func TestHandlerOTLPPush(t *testing.T) {
11211119
maxMsgSize: 30,
11221120
series: sampleSeries,
11231121
metadata: sampleMetadata,
1124-
verifyFunc: func(_ *testing.T, _ context.Context, pushReq *Request, _ testCase) error {
1122+
verifyFunc: func(_ *testing.T, pushReq *Request, _ testCase) error {
11251123
_, err := pushReq.WriteRequest()
11261124
return err
11271125
},
@@ -1136,7 +1134,7 @@ func TestHandlerOTLPPush(t *testing.T) {
11361134
maxMsgSize: 100000,
11371135
series: sampleSeries,
11381136
metadata: sampleMetadata,
1139-
verifyFunc: func(*testing.T, context.Context, *Request, testCase) error {
1137+
verifyFunc: func(*testing.T, *Request, testCase) error {
11401138
return httpgrpc.Errorf(http.StatusTooManyRequests, "go slower")
11411139
},
11421140
responseCode: http.StatusTooManyRequests,
@@ -1165,7 +1163,7 @@ func TestHandlerOTLPPush(t *testing.T) {
11651163
Unit: "metric_unit",
11661164
},
11671165
},
1168-
verifyFunc: func(t *testing.T, _ context.Context, pushReq *Request, _ testCase) error {
1166+
verifyFunc: func(t *testing.T, pushReq *Request, _ testCase) error {
11691167
request, err := pushReq.WriteRequest()
11701168
require.NoError(t, err)
11711169

@@ -1208,7 +1206,7 @@ func TestHandlerOTLPPush(t *testing.T) {
12081206
Unit: "metric_unit",
12091207
},
12101208
},
1211-
verifyFunc: func(t *testing.T, _ context.Context, pushReq *Request, _ testCase) error {
1209+
verifyFunc: func(t *testing.T, pushReq *Request, _ testCase) error {
12121210
request, err := pushReq.WriteRequest()
12131211
require.NoError(t, err)
12141212

@@ -1231,50 +1229,6 @@ func TestHandlerOTLPPush(t *testing.T) {
12311229
responseCode: http.StatusOK,
12321230
responseContentType: pbContentType,
12331231
},
1234-
{
1235-
name: "Attribute value too long",
1236-
maxMsgSize: 100000,
1237-
series: []prompb.TimeSeries{
1238-
{
1239-
Labels: []prompb.Label{
1240-
{Name: "__name__", Value: "foo"},
1241-
{Name: "too_long", Value: "huge value"},
1242-
},
1243-
Samples: []prompb.Sample{
1244-
{Value: 1, Timestamp: time.Date(2020, 4, 1, 0, 0, 0, 0, time.UTC).UnixNano()},
1245-
},
1246-
},
1247-
},
1248-
metadata: sampleMetadata,
1249-
verifyFunc: func(_ *testing.T, ctx context.Context, pushReq *Request, _ testCase) error {
1250-
var limitsCfg validation.Limits
1251-
flagext.DefaultValues(&limitsCfg)
1252-
limitsCfg.MaxLabelValueLength = len("huge value") - 1
1253-
distributors, _, _, _ := prepare(t, prepConfig{numDistributors: 1, limits: &limitsCfg})
1254-
distributor := distributors[0]
1255-
return distributor.prePushValidationMiddleware(func(context.Context, *Request) error { return nil })(ctx, pushReq)
1256-
},
1257-
responseCode: http.StatusBadRequest,
1258-
responseContentType: pbContentType,
1259-
errMessage: "received a metric whose attribute value length exceeds the limit of 9, attribute: 'too_long', value: 'huge value' (truncated) metric: 'foo{too_long=\"huge value\"}'. See: https://grafana.com/docs/grafana-cloud/send-data/otlp/otlp-format-considerations/#metrics-ingestion-limits",
1260-
expectedLogs: []string{`level=warn user=test msg="detected an error while ingesting OTLP metrics request (the request may have been partially ingested)" httpCode=400 err="received a metric whose attribute value length exceeds the limit of 9, attribute: 'too_long', value: 'huge value' (truncated) metric: 'foo{too_long=\"huge value\"}'. See: https://grafana.com/docs/grafana-cloud/send-data/otlp/otlp-format-considerations/#metrics-ingestion-limits" insight=true`},
1261-
expectedRetryHeader: false,
1262-
},
1263-
{
1264-
name: "Unexpected gRPC status error",
1265-
maxMsgSize: 100000,
1266-
series: sampleSeries,
1267-
metadata: sampleMetadata,
1268-
verifyFunc: func(*testing.T, context.Context, *Request, testCase) error {
1269-
return grpcstatus.New(codes.Unknown, "unexpected error calling some dependency").Err()
1270-
},
1271-
responseCode: http.StatusServiceUnavailable,
1272-
responseContentType: pbContentType,
1273-
responseContentLength: 44,
1274-
errMessage: "unexpected error calling some dependency",
1275-
expectedLogs: []string{`level=error user=test msg="detected an error while ingesting OTLP metrics request (the request may have been partially ingested)" httpCode=503 err="rpc error: code = Unknown desc = unexpected error calling some dependency"`},
1276-
expectedRetryHeader: true,
1277-
},
12781232
}
12791233
for _, tt := range tests {
12801234
t.Run(tt.name, func(t *testing.T) {
@@ -1295,11 +1249,10 @@ func TestHandlerOTLPPush(t *testing.T) {
12951249
"test": testLimits,
12961250
}),
12971251
)
1298-
1299-
pusher := func(ctx context.Context, pushReq *Request) error {
1252+
pusher := func(_ context.Context, pushReq *Request) error {
13001253
t.Helper()
13011254
t.Cleanup(pushReq.CleanUp)
1302-
return tt.verifyFunc(t, ctx, pushReq, tt)
1255+
return tt.verifyFunc(t, pushReq, tt)
13031256
}
13041257

13051258
logs := &concurrency.SyncBuffer{}
@@ -1311,9 +1264,7 @@ func TestHandlerOTLPPush(t *testing.T) {
13111264

13121265
assert.Equal(t, tt.responseCode, resp.Code)
13131266
assert.Equal(t, tt.responseContentType, resp.Header().Get("Content-Type"))
1314-
if tt.responseContentLength > 0 {
1315-
assert.Equal(t, strconv.Itoa(tt.responseContentLength), resp.Header().Get("Content-Length"))
1316-
}
1267+
assert.Equal(t, strconv.Itoa(tt.responseContentLength), resp.Header().Get("Content-Length"))
13171268
if tt.errMessage != "" {
13181269
body, err := io.ReadAll(resp.Body)
13191270
require.NoError(t, err)

pkg/distributor/validate.go

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ package distributor
88
import (
99
"errors"
1010
"fmt"
11-
"slices"
1211
"strings"
1312
"time"
1413
"unicode"
@@ -124,16 +123,6 @@ var (
124123
nativeHistogramCustomBucketsNotReducibleMsgFormat = globalerror.NativeHistogramCustomBucketsNotReducible.Message("received a native histogram sample with more custom buckets than the limit, timestamp: %d series: %s, buckets: %d, limit: %d")
125124
)
126125

127-
type LabelValueTooLongError struct {
128-
Label mimirpb.LabelAdapter
129-
Series []mimirpb.LabelAdapter
130-
Limit int
131-
}
132-
133-
func (e LabelValueTooLongError) Error() string {
134-
return fmt.Sprintf(labelValueTooLongMsgFormat, e.Label.Name, e.Label.Value, mimirpb.FromLabelAdaptersToString(e.Series))
135-
}
136-
137126
// sampleValidationConfig helps with getting required config to validate sample.
138127
type sampleValidationConfig interface {
139128
CreationGracePeriod(userID string) time.Duration
@@ -466,7 +455,7 @@ func validateLabels(m *sampleValidationMetrics, cfg labelValidationConfig, userI
466455
} else if len(l.Value) > maxLabelValueLength {
467456
cat.IncrementDiscardedSamples(ls, 1, reasonLabelValueTooLong, ts)
468457
m.labelValueTooLong.WithLabelValues(userID, group).Inc()
469-
return LabelValueTooLongError{Label: l, Series: slices.Clone(ls), Limit: maxLabelValueLength}
458+
return fmt.Errorf(labelValueTooLongMsgFormat, l.Name, l.Value, mimirpb.FromLabelAdaptersToString(ls))
470459
} else if lastLabelName == l.Name {
471460
cat.IncrementDiscardedSamples(ls, 1, reasonDuplicateLabelNames, ts)
472461
m.duplicateLabelNames.WithLabelValues(userID, group).Inc()

pkg/distributor/validate_test.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -182,15 +182,18 @@ func TestValidateLabels(t *testing.T) {
182182
metric: map[model.LabelName]model.LabelValue{model.MetricNameLabel: "badLabelValue", "much_shorter_name": "test_value_please_ignore_no_really_nothing_to_see_here", "team": "biz"},
183183
skipLabelNameValidation: false,
184184
skipLabelCountValidation: false,
185-
wantErr: alwaysErr(LabelValueTooLongError{
186-
Label: mimirpb.LabelAdapter{Name: "much_shorter_name", Value: "test_value_please_ignore_no_really_nothing_to_see_here"},
187-
Limit: 25,
188-
Series: []mimirpb.LabelAdapter{
189-
{Name: model.MetricNameLabel, Value: "badLabelValue"},
190-
{Name: "much_shorter_name", Value: "test_value_please_ignore_no_really_nothing_to_see_here"},
191-
{Name: "team", Value: "biz"},
192-
},
193-
}),
185+
wantErr: alwaysErr(fmt.Errorf(
186+
labelValueTooLongMsgFormat,
187+
"much_shorter_name",
188+
"test_value_please_ignore_no_really_nothing_to_see_here",
189+
mimirpb.FromLabelAdaptersToString(
190+
[]mimirpb.LabelAdapter{
191+
{Name: model.MetricNameLabel, Value: "badLabelValue"},
192+
{Name: "much_shorter_name", Value: "test_value_please_ignore_no_really_nothing_to_see_here"},
193+
{Name: "team", Value: "biz"},
194+
},
195+
),
196+
)),
194197
},
195198
{
196199
metric: map[model.LabelName]model.LabelValue{model.MetricNameLabel: "foo", "bar": "baz", "blip": "blop", "team": "plof"},

0 commit comments

Comments
 (0)