Skip to content

Commit

Permalink
query-frontend: add context to start call log
Browse files Browse the repository at this point in the history
Add more context to link start call with finished call.

Signed-off-by: Aymeric <aymeric.daurelle@cdiscount.com>
  • Loading branch information
Aymeric committed Oct 12, 2021
1 parent d5156d8 commit 7201cba
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re

- [#4663](https://github.com/thanos-io/thanos/pull/4663) Fetcher: Fix discovered data races
- [#4753](https://github.com/thanos-io/thanos/pull/4753) Store: valide block sync concurrency parameter
- [#4769](https://github.com/thanos-io/thanos/pull/4769) Query-frontend: add context to start call log

### Added

Expand Down
7 changes: 4 additions & 3 deletions cmd/thanos/query_frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,10 @@ func runQueryFrontend(
logger,
ins.NewHandler(
name,
logMiddleware.HTTPMiddleware(
name,
gziphandler.GzipHandler(middleware.RequestID(f)),
gziphandler.GzipHandler(
middleware.RequestID(
logMiddleware.HTTPMiddleware(name, f),
),
),
),
// Cortex frontend middlewares require orgID.
Expand Down
6 changes: 3 additions & 3 deletions pkg/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,9 @@ func GetInstr(

return tracing.HTTPMiddleware(tracer, name, logger,
ins.NewHandler(name,
logMiddleware.HTTPMiddleware(name,
gziphandler.GzipHandler(
middleware.RequestID(hf),
gziphandler.GzipHandler(
middleware.RequestID(
logMiddleware.HTTPMiddleware(name, hf),
),
),
),
Expand Down
6 changes: 3 additions & 3 deletions pkg/logging/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ type HTTPServerMiddleware struct {
logger log.Logger
}

func (m *HTTPServerMiddleware) preCall(start time.Time) {
func (m *HTTPServerMiddleware) preCall(name string, start time.Time, r *http.Request) {
logger := m.opts.filterLog(m.logger)
level.Debug(logger).Log("http.start_time", start.String(), "msg", "started call")
level.Debug(logger).Log("http.start_time", start.String(), "http.method", fmt.Sprintf("%s %s", r.Method, r.URL), "http.request_id", r.Header.Get("X-Request-ID"), "thanos.method_name", name, "msg", "started call")
}

func (m *HTTPServerMiddleware) postCall(name string, start time.Time, wrapped *httputil.ResponseWriterWithStatus, r *http.Request) {
Expand Down Expand Up @@ -68,7 +68,7 @@ func (m *HTTPServerMiddleware) HTTPMiddleware(name string, next http.Handler) ht
next.ServeHTTP(w, r)

case LogStartAndFinishCall:
m.preCall(start)
m.preCall(name, start, r)
next.ServeHTTP(wrapped, r)
m.postCall(name, start, wrapped, r)

Expand Down

0 comments on commit 7201cba

Please sign in to comment.