Skip to content

Commit

Permalink
Fix query for latency metrics (jaegertracing#3559)
Browse files Browse the repository at this point in the history
Signed-off-by: Ashmita152 <[email protected]>

Co-authored-by: Albert <[email protected]>
Signed-off-by: Albert Teoh <[email protected]>
  • Loading branch information
Ashmita152 and albertteoh committed Jul 13, 2022
1 parent 13d4efb commit b983569
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion plugin/metrics/prometheus/metricsstore/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,11 @@ func (m *MetricsReader) GetLatencies(ctx context.Context, requestParams *metrics
buildPromQuery: func(p promQueryParams) string {
return fmt.Sprintf(
// Note: p.spanKindFilter can be ""; trailing commas are okay within a timeseries selection.
`histogram_quantile(%.2f, sum(latency_bucket{service_name =~ "%s", %s}) by (%s))`,
`histogram_quantile(%.2f, sum(rate(latency_bucket{service_name =~ "%s", %s}[%s])) by (%s))`,
requestParams.Quantile,
p.serviceFilter,
p.spanKindFilter,
p.rate,
p.groupBy,
)
},
Expand Down
12 changes: 6 additions & 6 deletions plugin/metrics/prometheus/metricsstore/reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ func TestGetLatencies(t *testing.T) {
wantLabels: map[string]string{
"service_name": "emailservice",
},
wantPromQlQuery: `histogram_quantile(0.95, sum(latency_bucket{service_name =~ "emailservice", ` +
`span_kind =~ "SPAN_KIND_SERVER"}) by (service_name,le))`,
wantPromQlQuery: `histogram_quantile(0.95, sum(rate(latency_bucket{service_name =~ "emailservice", ` +
`span_kind =~ "SPAN_KIND_SERVER"}[10m])) by (service_name,le))`,
},
{
name: "group by service and operation should be reflected in name/description and query group-by",
Expand All @@ -153,8 +153,8 @@ func TestGetLatencies(t *testing.T) {
"operation": "/OrderResult",
"service_name": "emailservice",
},
wantPromQlQuery: `histogram_quantile(0.95, sum(latency_bucket{service_name =~ "emailservice", ` +
`span_kind =~ "SPAN_KIND_SERVER"}) by (service_name,operation,le))`,
wantPromQlQuery: `histogram_quantile(0.95, sum(rate(latency_bucket{service_name =~ "emailservice", ` +
`span_kind =~ "SPAN_KIND_SERVER"}[10m])) by (service_name,operation,le))`,
},
{
name: "two services and span kinds result in regex 'or' symbol in query",
Expand All @@ -166,8 +166,8 @@ func TestGetLatencies(t *testing.T) {
wantLabels: map[string]string{
"service_name": "emailservice",
},
wantPromQlQuery: `histogram_quantile(0.95, sum(latency_bucket{service_name =~ "frontend|emailservice", ` +
`span_kind =~ "SPAN_KIND_SERVER|SPAN_KIND_CLIENT"}) by (service_name,le))`,
wantPromQlQuery: `histogram_quantile(0.95, sum(rate(latency_bucket{service_name =~ "frontend|emailservice", ` +
`span_kind =~ "SPAN_KIND_SERVER|SPAN_KIND_CLIENT"}[10m])) by (service_name,le))`,
},
} {
t.Run(tc.name, func(t *testing.T) {
Expand Down

0 comments on commit b983569

Please sign in to comment.