MCPcopy Create free account
hub / github.com/cortexproject/cortex / Do

Method Do

pkg/querier/tripperware/instantquery/limits.go:37–61  ·  view source on GitHub ↗
(ctx context.Context, r tripperware.Request)

Source from the content-addressed store, hash-verified

35}
36
37func (l limitsMiddleware) Do(ctx context.Context, r tripperware.Request) (tripperware.Response, error) {
38 log, ctx := spanlogger.New(ctx, "limits")
39 defer log.Finish()
40
41 tenantIDs, err := users.TenantIDs(ctx)
42 if err != nil {
43 return nil, httpgrpc.Errorf(http.StatusBadRequest, "%s", err.Error())
44 }
45
46 // Enforce the max query length.
47 if maxQueryLength := validation.SmallestPositiveNonZeroDurationPerTenant(tenantIDs, l.MaxQueryLength); maxQueryLength > 0 {
48 expr, err := cortexparser.ParseExpr(r.GetQuery())
49 if err != nil {
50 return nil, httpgrpc.Errorf(http.StatusBadRequest, "%s", err.Error())
51 }
52
53 // Enforce query length across all selectors in the query.
54 length := promql.FindNonOverlapQueryLength(expr, 0, 0, l.lookbackDelta)
55 if length > maxQueryLength {
56 return nil, httpgrpc.Errorf(http.StatusBadRequest, validation.ErrQueryTooLong, length, maxQueryLength)
57 }
58 }
59
60 return l.next.Do(ctx, r)
61}

Callers

nothing calls this directly

Calls 8

NewFunction · 0.92
TenantIDsFunction · 0.92
FinishMethod · 0.80
GetQueryMethod · 0.65
DoMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected