Skip to content

Commit

Permalink
debug logs
Browse files Browse the repository at this point in the history
  • Loading branch information
ashwanthgoli committed Mar 20, 2024
1 parent c512687 commit fef9dde
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/ingester/grpc_querytags.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import (
"google.golang.org/grpc"
"google.golang.org/grpc/metadata"

"github.com/go-kit/log/level"
"github.com/grafana/loki/pkg/util/httpreq"
util_log "github.com/grafana/loki/pkg/util/log"
)

const (
Expand All @@ -31,6 +33,9 @@ func injectIntoGRPCRequest(ctx context.Context) (context.Context, error) {
}
md = md.Copy()
md.Set("x-query-tags", queryTags)

level.Info(util_log.Logger).Log("msg", "inject query tag", "value", queryTags)

newCtx := metadata.NewOutgoingContext(ctx, md)

return newCtx, nil
Expand All @@ -48,6 +53,8 @@ func extractFromGRPCRequest(ctx context.Context) (context.Context, error) {
return ctx, nil
}

level.Info(util_log.Logger).Log("msg", "extract query tag", "value", headerValues[0])

return context.WithValue(ctx, httpreq.QueryTagsHTTPHeader, headerValues[0]), nil
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/ingester/ingester.go
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,8 @@ func (i *Ingester) Query(req *logproto.QueryRequest, queryServer logproto.Querie
// initialize stats collection for ingester queries.
_, ctx := stats.NewContext(queryServer.Context())

level.Info(i.logger).Log("msg", "Query: query tags from ctx", "value", getQueryTags(ctx))

if req.Plan == nil {
parsed, err := syntax.ParseLogSelector(req.Selector, true)
if err != nil {
Expand Down Expand Up @@ -935,6 +937,8 @@ func (i *Ingester) QuerySample(req *logproto.SampleQueryRequest, queryServer log
_, ctx := stats.NewContext(queryServer.Context())
sp := opentracing.SpanFromContext(ctx)

level.Info(i.logger).Log("msg", "Query: query tags from ctx", "value", getQueryTags(ctx))

// If the plan is empty we want all series to be returned.
if req.Plan == nil {
parsed, err := syntax.ParseSampleExpr(req.Selector)
Expand Down

0 comments on commit fef9dde

Please sign in to comment.