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

Function ExtractShardingInfo

pkg/querysharding/util.go:53–73  ·  view source on GitHub ↗
(matchers []*labels.Matcher)

Source from the content-addressed store, hash-verified

51}
52
53func ExtractShardingInfo(matchers []*labels.Matcher) ([]*labels.Matcher, *storepb.ShardInfo, error) {
54 r := make([]*labels.Matcher, 0, len(matchers))
55
56 shardInfo := storepb.ShardInfo{}
57 for _, matcher := range matchers {
58 if matcher.Name == CortexShardByLabel && matcher.Type == labels.MatchEqual {
59 decoded, err := base64.StdEncoding.DecodeString(matcher.Value)
60 if err != nil {
61 return r, nil, err
62 }
63 err = shardInfo.Unmarshal(decoded)
64 if err != nil {
65 return r, nil, err
66 }
67 } else {
68 r = append(r, matcher)
69 }
70 }
71
72 return r, &shardInfo, nil
73}
74
75func ExtractShardingMatchers(matchers []*labels.Matcher) ([]*labels.Matcher, *storepb.ShardMatcher, error) {
76 r, shardInfo, err := ExtractShardingInfo(matchers)

Callers 3

SelectMethod · 0.92
fetchSeriesFromStoresMethod · 0.92
ExtractShardingMatchersFunction · 0.85

Calls 1

UnmarshalMethod · 0.45

Tested by

no test coverage detected