Skip to content

Commit 7bb4436

Browse files
authored
[r351] Revert "otlp: Stick to OTLP vocabulary on invalid label value length … (#12264)
This reverts commit 9bf900e.
1 parent 95576e2 commit 7bb4436

6 files changed

Lines changed: 29 additions & 90 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@
6363
* Renamed `cortex_ingest_storage_writer_produce_requests_total` to `cortex_ingest_storage_writer_produce_records_enqueued_total`
6464
* Renamed `cortex_ingest_storage_writer_produce_failures_total` to `cortex_ingest_storage_writer_produce_records_failed_total`
6565
* [CHANGE] Distributor: moved HA tracker timeout config to limits. #11774
66-
* Moved `distributor.ha_tracker.ha_tracker_update_timeout` to `limits.ha_tracker_update_timeout`.
67-
* Moved `distributor.ha_tracker.ha_tracker_update_timeout_jitter_max` to `limits.ha_tracker_update_timeout_jitter_max`.
68-
* Moved `distributor.ha_tracker.ha_tracker_failover_timeout` to `limits.ha_tracker_failover_timeout`.
66+
* Moved `distributor.ha_tracker.ha_tracker_update_timeout` to `limits.ha_tracker.ha_tracker_update_timeout`
67+
* Moved `distributor.ha_tracker.ha_tracker_update_timeout_jitter_max` to `limits.ha_tracker.ha_tracker_update_timeout_jitter_max`
68+
* Moved `distributor.ha_tracker.ha_tracker_failover_timeout` to `limits.ha_tracker.ha_tracker_failover_timeout`
6969
* [CHANGE] Distributor: `Memberlist` marked as stable as an option for backend storage for the HA tracker. #11861
7070
* [CHANGE] Distributor: `etcd` deprecated as an option for backend storage for the HA tracker. #12047
7171
* [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
@@ -150,7 +150,6 @@
150150
* [ENHANCEMENT] Query-frontend: Accurate tracking of samples processed from cache. #11719
151151
* [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
152152
* [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
153-
* [ENHANCEMENT] otlp: Stick to OTLP vocabulary on invalid label value length error. #11889
154153
* [BUGFIX] OTLP: Fix response body and Content-Type header to align with spec. #10852
155154
* [BUGFIX] Compactor: fix issue where block becomes permanently stuck when the Compactor's block cleanup job partially deletes a block. #10888
156155
* [BUGFIX] Storage: fix intermittent failures in S3 upload retries. #10952

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
@@ -685,14 +681,3 @@ func translateBucketsLayout(spans []prompb.BucketSpan, deltas []int64) (int32, [
685681

686682
return firstSpan.Offset - 1, buckets
687683
}
688-
689-
type otelAttributeValueTooLongError struct {
690-
LabelValueTooLongError
691-
}
692-
693-
func (e otelAttributeValueTooLongError) Error() string {
694-
return fmt.Sprintf(
695-
"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",
696-
e.Limit, e.Label.Name, e.Label.Value, mimirpb.FromLabelAdaptersToString(e.Series),
697-
)
698-
}

pkg/distributor/otel_test.go

Lines changed: 13 additions & 46 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"
@@ -880,7 +879,7 @@ func TestHandlerOTLPPush(t *testing.T) {
880879
metadata []mimirpb.MetricMetadata
881880
compression string
882881
maxMsgSize int
883-
verifyFunc func(*testing.T, context.Context, *Request, testCase) error
882+
verifyFunc func(*testing.T, *Request, testCase) error
884883
requestContentType string
885884
responseCode int
886885
responseContentType string
@@ -893,7 +892,7 @@ func TestHandlerOTLPPush(t *testing.T) {
893892
resourceAttributePromotionConfig OTelResourceAttributePromotionConfig
894893
}
895894

896-
samplesVerifierFunc := func(t *testing.T, _ context.Context, pushReq *Request, tc testCase) error {
895+
samplesVerifierFunc := func(t *testing.T, pushReq *Request, tc testCase) error {
897896
t.Helper()
898897

899898
request, err := pushReq.WriteRequest()
@@ -995,7 +994,7 @@ func TestHandlerOTLPPush(t *testing.T) {
995994
maxMsgSize: 30,
996995
series: sampleSeries,
997996
metadata: sampleMetadata,
998-
verifyFunc: func(_ *testing.T, _ context.Context, pushReq *Request, _ testCase) error {
997+
verifyFunc: func(_ *testing.T, pushReq *Request, _ testCase) error {
999998
_, err := pushReq.WriteRequest()
1000999
return err
10011000
},
@@ -1011,7 +1010,7 @@ func TestHandlerOTLPPush(t *testing.T) {
10111010
maxMsgSize: 100000,
10121011
series: sampleSeries,
10131012
metadata: sampleMetadata,
1014-
verifyFunc: func(_ *testing.T, _ context.Context, pushReq *Request, _ testCase) error {
1013+
verifyFunc: func(_ *testing.T, pushReq *Request, _ testCase) error {
10151014
_, err := pushReq.WriteRequest()
10161015
return err
10171016
},
@@ -1027,7 +1026,7 @@ func TestHandlerOTLPPush(t *testing.T) {
10271026
maxMsgSize: 100000,
10281027
series: sampleSeries,
10291028
metadata: sampleMetadata,
1030-
verifyFunc: func(_ *testing.T, _ context.Context, pushReq *Request, _ testCase) error {
1029+
verifyFunc: func(_ *testing.T, pushReq *Request, _ testCase) error {
10311030
_, err := pushReq.WriteRequest()
10321031
return err
10331032
},
@@ -1044,7 +1043,7 @@ func TestHandlerOTLPPush(t *testing.T) {
10441043
maxMsgSize: 30,
10451044
series: sampleSeries,
10461045
metadata: sampleMetadata,
1047-
verifyFunc: func(_ *testing.T, _ context.Context, pushReq *Request, _ testCase) error {
1046+
verifyFunc: func(_ *testing.T, pushReq *Request, _ testCase) error {
10481047
_, err := pushReq.WriteRequest()
10491048
return err
10501049
},
@@ -1060,7 +1059,7 @@ func TestHandlerOTLPPush(t *testing.T) {
10601059
maxMsgSize: 30,
10611060
series: sampleSeries,
10621061
metadata: sampleMetadata,
1063-
verifyFunc: func(_ *testing.T, _ context.Context, pushReq *Request, _ testCase) error {
1062+
verifyFunc: func(_ *testing.T, pushReq *Request, _ testCase) error {
10641063
_, err := pushReq.WriteRequest()
10651064
return err
10661065
},
@@ -1075,7 +1074,7 @@ func TestHandlerOTLPPush(t *testing.T) {
10751074
maxMsgSize: 100000,
10761075
series: sampleSeries,
10771076
metadata: sampleMetadata,
1078-
verifyFunc: func(*testing.T, context.Context, *Request, testCase) error {
1077+
verifyFunc: func(*testing.T, *Request, testCase) error {
10791078
return httpgrpc.Errorf(http.StatusTooManyRequests, "go slower")
10801079
},
10811080
responseCode: http.StatusTooManyRequests,
@@ -1104,7 +1103,7 @@ func TestHandlerOTLPPush(t *testing.T) {
11041103
Unit: "metric_unit",
11051104
},
11061105
},
1107-
verifyFunc: func(t *testing.T, _ context.Context, pushReq *Request, _ testCase) error {
1106+
verifyFunc: func(t *testing.T, pushReq *Request, _ testCase) error {
11081107
request, err := pushReq.WriteRequest()
11091108
require.NoError(t, err)
11101109

@@ -1147,7 +1146,7 @@ func TestHandlerOTLPPush(t *testing.T) {
11471146
Unit: "metric_unit",
11481147
},
11491148
},
1150-
verifyFunc: func(t *testing.T, _ context.Context, pushReq *Request, _ testCase) error {
1149+
verifyFunc: func(t *testing.T, pushReq *Request, _ testCase) error {
11511150
request, err := pushReq.WriteRequest()
11521151
require.NoError(t, err)
11531152

@@ -1170,35 +1169,6 @@ func TestHandlerOTLPPush(t *testing.T) {
11701169
responseCode: http.StatusOK,
11711170
responseContentType: pbContentType,
11721171
},
1173-
{
1174-
name: "Attribute value too long",
1175-
maxMsgSize: 100000,
1176-
series: []prompb.TimeSeries{
1177-
{
1178-
Labels: []prompb.Label{
1179-
{Name: "__name__", Value: "foo"},
1180-
{Name: "too_long", Value: "huge value"},
1181-
},
1182-
Samples: []prompb.Sample{
1183-
{Value: 1, Timestamp: time.Date(2020, 4, 1, 0, 0, 0, 0, time.UTC).UnixNano()},
1184-
},
1185-
},
1186-
},
1187-
metadata: sampleMetadata,
1188-
verifyFunc: func(_ *testing.T, ctx context.Context, pushReq *Request, _ testCase) error {
1189-
var limitsCfg validation.Limits
1190-
flagext.DefaultValues(&limitsCfg)
1191-
limitsCfg.MaxLabelValueLength = len("huge value") - 1
1192-
distributors, _, _, _ := prepare(t, prepConfig{numDistributors: 1, limits: &limitsCfg})
1193-
distributor := distributors[0]
1194-
return distributor.prePushValidationMiddleware(func(context.Context, *Request) error { return nil })(ctx, pushReq)
1195-
},
1196-
responseCode: http.StatusBadRequest,
1197-
responseContentType: pbContentType,
1198-
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",
1199-
expectedLogs: []string{`level=error 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`},
1200-
expectedRetryHeader: false,
1201-
},
12021172
}
12031173
for _, tt := range tests {
12041174
t.Run(tt.name, func(t *testing.T) {
@@ -1219,11 +1189,10 @@ func TestHandlerOTLPPush(t *testing.T) {
12191189
"test": testLimits,
12201190
}),
12211191
)
1222-
1223-
pusher := func(ctx context.Context, pushReq *Request) error {
1192+
pusher := func(_ context.Context, pushReq *Request) error {
12241193
t.Helper()
12251194
t.Cleanup(pushReq.CleanUp)
1226-
return tt.verifyFunc(t, ctx, pushReq, tt)
1195+
return tt.verifyFunc(t, pushReq, tt)
12271196
}
12281197

12291198
logs := &concurrency.SyncBuffer{}
@@ -1235,9 +1204,7 @@ func TestHandlerOTLPPush(t *testing.T) {
12351204

12361205
assert.Equal(t, tt.responseCode, resp.Code)
12371206
assert.Equal(t, tt.responseContentType, resp.Header().Get("Content-Type"))
1238-
if tt.responseContentLength > 0 {
1239-
assert.Equal(t, strconv.Itoa(tt.responseContentLength), resp.Header().Get("Content-Length"))
1240-
}
1207+
assert.Equal(t, strconv.Itoa(tt.responseContentLength), resp.Header().Get("Content-Length"))
12411208
if tt.errMessage != "" {
12421209
body, err := io.ReadAll(resp.Body)
12431210
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"
@@ -123,16 +122,6 @@ var (
123122
nativeHistogramCustomBucketsNotReducibleMsgFormat = globalerror.NativeHistogramCustomBucketsNotReducible.Message("received a native histogram sample with more custom buckets than the limit, timestamp: %d series: %s, buckets: %d, limit: %d")
124123
)
125124

126-
type LabelValueTooLongError struct {
127-
Label mimirpb.LabelAdapter
128-
Series []mimirpb.LabelAdapter
129-
Limit int
130-
}
131-
132-
func (e LabelValueTooLongError) Error() string {
133-
return fmt.Sprintf(labelValueTooLongMsgFormat, e.Label.Name, e.Label.Value, mimirpb.FromLabelAdaptersToString(e.Series))
134-
}
135-
136125
// sampleValidationConfig helps with getting required config to validate sample.
137126
type sampleValidationConfig interface {
138127
CreationGracePeriod(userID string) time.Duration
@@ -462,7 +451,7 @@ func validateLabels(m *sampleValidationMetrics, cfg labelValidationConfig, userI
462451
} else if len(l.Value) > maxLabelValueLength {
463452
cat.IncrementDiscardedSamples(ls, 1, reasonLabelValueTooLong, ts)
464453
m.labelValueTooLong.WithLabelValues(userID, group).Inc()
465-
return LabelValueTooLongError{Label: l, Series: slices.Clone(ls), Limit: maxLabelValueLength}
454+
return fmt.Errorf(labelValueTooLongMsgFormat, l.Name, l.Value, mimirpb.FromLabelAdaptersToString(ls))
466455
} else if lastLabelName == l.Name {
467456
cat.IncrementDiscardedSamples(ls, 1, reasonDuplicateLabelNames, ts)
468457
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
@@ -152,15 +152,18 @@ func TestValidateLabels(t *testing.T) {
152152
metric: map[model.LabelName]model.LabelValue{model.MetricNameLabel: "badLabelValue", "much_shorter_name": "test_value_please_ignore_no_really_nothing_to_see_here", "team": "biz"},
153153
skipLabelNameValidation: false,
154154
skipLabelCountValidation: false,
155-
err: LabelValueTooLongError{
156-
Label: mimirpb.LabelAdapter{Name: "much_shorter_name", Value: "test_value_please_ignore_no_really_nothing_to_see_here"},
157-
Limit: 25,
158-
Series: []mimirpb.LabelAdapter{
159-
{Name: model.MetricNameLabel, Value: "badLabelValue"},
160-
{Name: "much_shorter_name", Value: "test_value_please_ignore_no_really_nothing_to_see_here"},
161-
{Name: "team", Value: "biz"},
162-
},
163-
},
155+
err: fmt.Errorf(
156+
labelValueTooLongMsgFormat,
157+
"much_shorter_name",
158+
"test_value_please_ignore_no_really_nothing_to_see_here",
159+
mimirpb.FromLabelAdaptersToString(
160+
[]mimirpb.LabelAdapter{
161+
{Name: model.MetricNameLabel, Value: "badLabelValue"},
162+
{Name: "much_shorter_name", Value: "test_value_please_ignore_no_really_nothing_to_see_here"},
163+
{Name: "team", Value: "biz"},
164+
},
165+
),
166+
),
164167
},
165168
{
166169
metric: map[model.LabelName]model.LabelValue{model.MetricNameLabel: "foo", "bar": "baz", "blip": "blop", "team": "plof"},

0 commit comments

Comments
 (0)