Skip to content

Commit

Permalink
adds span metadata for split queries (#1567)
Browse files Browse the repository at this point in the history
* adds span metadata for split queries

* finishes interval span
  • Loading branch information
owen-d authored and cyriltovena committed Jan 23, 2020
1 parent 83dfdf0 commit bde0389
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/querier/queryrange/split_by_interval.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (

"github.com/cortexproject/cortex/pkg/querier/queryrange"
"github.com/grafana/loki/pkg/logproto"
"github.com/opentracing/opentracing-go"
otlog "github.com/opentracing/opentracing-go/log"
"github.com/weaveworks/common/user"
)

Expand Down Expand Up @@ -98,12 +100,17 @@ func (h *splitByInterval) Process(
func (h *splitByInterval) loop(ctx context.Context, ch <-chan *lokiResult) {

for data := range ch {

sp, ctx := opentracing.StartSpanFromContext(ctx, "interval")
queryrange.LogToSpan(ctx, data.req)

resp, err := h.next.Do(ctx, data.req)
if err != nil {
data.err <- err
} else {
data.resp <- resp
}
sp.Finish()
}
}

Expand All @@ -117,6 +124,11 @@ func (h *splitByInterval) Do(ctx context.Context, r queryrange.Request) (queryra

intervals := splitByTime(lokiRequest, h.interval)

if sp := opentracing.SpanFromContext(ctx); sp != nil {
sp.LogFields(otlog.Int("n_intervals", len(intervals)))

}

if lokiRequest.Direction == logproto.BACKWARD {
for i, j := 0, len(intervals)-1; i < j; i, j = i+1, j-1 {
intervals[i], intervals[j] = intervals[j], intervals[i]
Expand Down

0 comments on commit bde0389

Please sign in to comment.