Skip to content

Commit

Permalink
fix(chostorage.metrics): fix data race
Browse files Browse the repository at this point in the history
  • Loading branch information
ernado committed Dec 29, 2023
1 parent a6588aa commit cadfa57
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions internal/chstorage/querier_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,12 +378,13 @@ func (p *promQuerier) selectSeries(ctx context.Context, sortSeries bool, hints *
fmt.Sprintf("JSONExtractString(resource, %s)", singleQuoted(name)),
}
}
value := m.Value
if m.Name == labels.MetricName {
mappedValue, err := p.getMetricName(ctx, m.Value)
if err != nil {
return "", errors.Wrap(err, "get metric name mapping")
}
m.Value = mappedValue
value = mappedValue
}
query.WriteString("(\n")
for i, sel := range selectors {
Expand All @@ -393,9 +394,9 @@ func (p *promQuerier) selectSeries(ctx context.Context, sortSeries bool, hints *
// Note: predicate negated above.
switch m.Type {
case labels.MatchEqual, labels.MatchNotEqual:
fmt.Fprintf(&query, "%s = %s\n", sel, singleQuoted(m.Value))
fmt.Fprintf(&query, "%s = %s\n", sel, singleQuoted(value))
case labels.MatchRegexp, labels.MatchNotRegexp:
fmt.Fprintf(&query, "%s REGEXP %s\n", sel, singleQuoted(m.Value))
fmt.Fprintf(&query, "%s REGEXP %s\n", sel, singleQuoted(value))
default:
return "", errors.Errorf("unexpected type %q", m.Type)
}
Expand Down

0 comments on commit cadfa57

Please sign in to comment.