Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QueryFrontend: pre-compile regexp #5383

Merged
merged 2 commits into from May 24, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions pkg/queryfrontend/roundtrip.go
Expand Up @@ -27,6 +27,8 @@ const (
seriesOp = "series"
)

var opPattern = regexp.MustCompile("/api/v1/label/.+/values$")
djdongjin marked this conversation as resolved.
Show resolved Hide resolved

// NewTripperware returns a Tripperware which sends requests to different sub tripperwares based on the query type.
func NewTripperware(config Config, reg prometheus.Registerer, logger log.Logger) (queryrange.Tripperware, error) {
var (
Expand Down Expand Up @@ -120,8 +122,7 @@ func getOperation(r *http.Request) string {
case strings.HasSuffix(r.URL.Path, "/api/v1/series"):
return seriesOp
default:
matched, err := regexp.MatchString("/api/v1/label/.+/values$", r.URL.Path)
if err == nil && matched {
if opPattern.MatchString(r.URL.Path) {
return labelValuesOp
}
}
Expand Down