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

Include route name in query stats log lines emitted by query-frontends #8191

Merged
merged 2 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
* [ENHANCEMENT] Distributor: Introduce `-distributor.max-request-pool-buffer-size` to allow configuring the maximum size of the request pool buffers. #8082
* [ENHANCEMENT] Store-gateway: improve performance when streaming chunks to queriers is enabled (`-querier.prefer-streaming-chunks-from-store-gateways=true`) and the query selects fewer than `-blocks-storage.bucket-store.batch-series-size` series (defaults to 5000 series). #8039
* [ENHANCEMENT] Ingester: active series are now updated along with owned series. They decrease when series change ownership between ingesters. This helps provide a more accurate total of active series when ingesters are added. This is only enabled when `-ingester.track-ingester-owned-series` or `-ingester.use-ingester-owned-series-for-limits` are enabled. #8084
* [ENHANCEMENT] Query-frontend: include route name in query stats log lines. #8191
* [BUGFIX] Rules: improve error handling when querier is local to the ruler. #7567
* [BUGFIX] Querier, store-gateway: Protect against panics raised during snappy encoding. #7520
* [BUGFIX] Ingester: Prevent timely compaction of empty blocks. #7624
Expand Down
2 changes: 2 additions & 0 deletions pkg/frontend/transport/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/grafana/dskit/cancellation"
"github.com/grafana/dskit/flagext"
"github.com/grafana/dskit/httpgrpc"
"github.com/grafana/dskit/middleware"
"github.com/grafana/dskit/tenant"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
Expand Down Expand Up @@ -306,6 +307,7 @@ func (f *Handler) reportQueryStats(
"component", "query-frontend",
"method", r.Method,
"path", r.URL.Path,
"route_name", middleware.ExtractRouteName(r.Context()),
"user_agent", r.UserAgent(),
"status_code", queryResponseStatusCode,
"response_time", queryResponseTime,
Expand Down
5 changes: 5 additions & 0 deletions pkg/frontend/transport/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/go-kit/log/level"
"github.com/grafana/dskit/concurrency"
"github.com/grafana/dskit/httpgrpc"
"github.com/grafana/dskit/middleware"
"github.com/grafana/dskit/test"
"github.com/grafana/dskit/user"
"github.com/pkg/errors"
Expand Down Expand Up @@ -61,6 +62,8 @@ func TestWriteError(t *testing.T) {
}

func TestHandler_ServeHTTP(t *testing.T) {
const testRouteName = "the_test_route"

for _, tt := range []struct {
name string
cfg HandlerConfig
Expand Down Expand Up @@ -182,6 +185,7 @@ func TestHandler_ServeHTTP(t *testing.T) {

req := tt.request()
req = req.WithContext(user.InjectOrgID(req.Context(), "12345"))
req = middleware.WithRouteName(req, testRouteName)
resp := httptest.NewRecorder()

handler.ServeHTTP(resp, req)
Expand Down Expand Up @@ -215,6 +219,7 @@ func TestHandler_ServeHTTP(t *testing.T) {
require.Equal(t, "12345", msg["user"])
require.Equal(t, req.Method, msg["method"])
require.Equal(t, req.URL.Path, msg["path"])
require.Equal(t, testRouteName, msg["route_name"])
require.Equal(t, req.UserAgent(), msg["user_agent"])
require.Contains(t, msg, "response_time")
require.Equal(t, int64(len(responseData)), msg["response_size_bytes"])
Expand Down
Loading