Adding "start_delta" entry to metrics.go line (#6550)

* Adding "start_delta" entry to metrics.go line

This will help us determine if a 3h query (derived from "length") is for some random 3h period in the past, or within the last 3h

Signed-off-by: Danny Kopping <danny.kopping@grafana.com>

* Fixing test

Signed-off-by: Danny Kopping <danny.kopping@grafana.com>

* Appeasing the linter; for once it was actually useful

Signed-off-by: Danny Kopping <danny.kopping@grafana.com>

* Adding "end_delta" as well

Signed-off-by: Danny Kopping <danny.kopping@grafana.com>

* Removing rounding

Signed-off-by: Danny Kopping <danny.kopping@grafana.com>

* Fixing test

Signed-off-by: Danny Kopping <danny.kopping@grafana.com>
pull/6714/head
Danny Kopping 4 years ago committed by GitHub
parent e171c4bcd6
commit fa42c12f4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      pkg/logql/metrics.go
  2. 9
      pkg/logql/metrics_test.go

@ -116,6 +116,8 @@ func RecordRangeAndInstantQueryMetrics(
"query_type", queryType,
"range_type", rt,
"length", p.End().Sub(p.Start()),
"start_delta", time.Since(p.Start()),
"end_delta", time.Since(p.End()),
"step", p.Step(),
"duration", logql_stats.ConvertSecondsToNanoseconds(stats.Summary.ExecTime),
"status", status,

@ -4,6 +4,7 @@ import (
"bytes"
"context"
"fmt"
"regexp"
"testing"
"time"
@ -82,11 +83,11 @@ func TestLogSlowQuery(t *testing.T) {
TotalEntriesReturned: 10,
},
}, logqlmodel.Streams{logproto.Stream{Entries: make([]logproto.Entry, 10)}})
require.Equal(t,
fmt.Sprintf(
"level=info org_id=foo traceID=%s latency=slow query=\"{foo=\\\"bar\\\"} |= \\\"buzz\\\"\" query_type=filter range_type=range length=1h0m0s step=1m0s duration=25.25s status=200 limit=1000 returned_lines=10 throughput=100kB total_bytes=100kB total_entries=10 queue_time=2ns subqueries=0 cache_chunk_req=0 cache_chunk_hit=0 cache_chunk_bytes_stored=0 cache_chunk_bytes_fetched=0 cache_index_req=0 cache_index_hit=0 cache_result_req=0 cache_result_hit=0 source=logvolhist feature=beta\n",
require.Regexp(t,
regexp.MustCompile(fmt.Sprintf(
`level=info org_id=foo traceID=%s latency=slow query=".*" query_type=filter range_type=range length=1h0m0s start_delta=.* end_delta=.* step=1m0s duration=25.25s status=200 limit=1000 returned_lines=10 throughput=100kB total_bytes=100kB total_entries=10 queue_time=2ns subqueries=0 cache_chunk_req=0 cache_chunk_hit=0 cache_chunk_bytes_stored=0 cache_chunk_bytes_fetched=0 cache_index_req=0 cache_index_hit=0 cache_result_req=0 cache_result_hit=0 source=logvolhist feature=beta\n`,
sp.Context().(jaeger.SpanContext).SpanID().String(),
),
)),
buf.String())
util_log.Logger = log.NewNopLogger()
}

Loading…
Cancel
Save