Skip to content

Commit 986b156

Browse files
committed
logging sharding stats
Signed-off-by: Alan Protasio <[email protected]>
1 parent 8cf2583 commit 986b156

File tree

12 files changed

+428
-147
lines changed

12 files changed

+428
-147
lines changed

pkg/frontend/transport/handler.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func NewHandler(cfg HandlerConfig, roundTripper http.RoundTripper, log log.Logge
112112

113113
func (f *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
114114
var (
115-
stats *querier_stats.Stats
115+
stats *querier_stats.QueryStats
116116
queryString url.Values
117117
)
118118

@@ -185,7 +185,7 @@ func (f *Handler) reportSlowQuery(r *http.Request, queryString url.Values, query
185185
level.Info(util_log.WithContext(r.Context(), f.log)).Log(logMessage...)
186186
}
187187

188-
func (f *Handler) reportQueryStats(r *http.Request, queryString url.Values, queryResponseTime time.Duration, stats *querier_stats.Stats, error error) {
188+
func (f *Handler) reportQueryStats(r *http.Request, queryString url.Values, queryResponseTime time.Duration, stats *querier_stats.QueryStats, error error) {
189189
tenantIDs, err := tenant.TenantIDs(r.Context())
190190
if err != nil {
191191
return
@@ -214,7 +214,9 @@ func (f *Handler) reportQueryStats(r *http.Request, queryString url.Values, quer
214214
"fetched_series_count", numSeries,
215215
"fetched_chunks_bytes", numBytes,
216216
"fetched_data_bytes", numDataBytes,
217-
}, formatQueryString(queryString)...)
217+
}, stats.LoadExtraFields()...)
218+
219+
logMessage = append(logMessage, formatQueryString(queryString)...)
218220

219221
if error != nil {
220222
s, ok := status.FromError(error)
@@ -264,7 +266,7 @@ func writeError(w http.ResponseWriter, err error) {
264266
server.WriteError(w, err)
265267
}
266268

267-
func writeServiceTimingHeader(queryResponseTime time.Duration, headers http.Header, stats *querier_stats.Stats) {
269+
func writeServiceTimingHeader(queryResponseTime time.Duration, headers http.Header, stats *querier_stats.QueryStats) {
268270
if stats != nil {
269271
parts := make([]string, 0)
270272
parts = append(parts, statsValue("querier_wall_time", stats.LoadWallTime()))

pkg/frontend/v1/frontendv1pb/frontend.pb.go

Lines changed: 50 additions & 52 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/frontend/v1/frontendv1pb/frontend.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ message FrontendToClient {
3939
message ClientToFrontend {
4040
httpgrpc.HTTPResponse httpResponse = 1;
4141
string clientID = 2;
42-
stats.Stats stats = 3;
42+
stats.Stats stats = 3[(gogoproto.customtype) = "github.com/cortexproject/cortex/pkg/querier/stats.QueryStats"];
4343
}
4444

4545
message NotifyClientShutdownRequest {

0 commit comments

Comments
 (0)