Skip to content

Commit

Permalink
reorders the assert in the sequence call
Browse files Browse the repository at this point in the history
Signed-off-by: Afzal Ansari <afzal442@gmail.com>
  • Loading branch information
afzal442 committed Jul 28, 2023
1 parent 3295970 commit abeeeb6
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
Expand Up @@ -237,8 +237,9 @@ func (m MetricsReader) executeQuery(ctx context.Context, p metricsQueryParams) (

mv, warnings, err := m.client.QueryRange(ctx, promQuery, queryRange)
if err != nil {
err = fmt.Errorf("failed executing metrics query: %w", err)
logErrorToSpan(span, err)
return &metrics.MetricFamily{}, fmt.Errorf("failed executing metrics query: %w", err)
return &metrics.MetricFamily{}, err
}
if len(warnings) > 0 {
m.logger.Warn("Warnings detected on Prometheus query", zap.Any("warnings", warnings), zap.String("query", promQuery), zap.Any("range", queryRange))
Expand Down
12 changes: 6 additions & 6 deletions plugin/metrics/prometheus/metricsstore/reader_test.go
Expand Up @@ -151,11 +151,11 @@ func TestMetricsServerError(t *testing.T) {
}, logger, tracer)
require.NoError(t, err)
m, err := reader.GetCallRates(context.Background(), &params)
assert.NotNil(t, exp.GetSpans()[0].Status)
assert.Len(t, exp.GetSpans(), 1, "HTTP request was traced and span reported")
assert.NotNil(t, m)
require.Error(t, err)
assert.Contains(t, err.Error(), "failed executing metrics query")
require.Len(t, exp.GetSpans(), 1, "HTTP request was traced and span reported")
assert.Equal(t, "service_call_rate", exp.GetSpans()[0].Name)
}

func TestGetLatencies(t *testing.T) {
Expand Down Expand Up @@ -254,9 +254,9 @@ func TestGetLatencies(t *testing.T) {
defer mockPrometheus.Close()

m, err := reader.GetLatencies(context.Background(), &params)
assert.Len(t, exp.GetSpans(), 1, "HTTP request was traced and span reported")
require.NoError(t, err)
assertMetrics(t, m, tc.wantLabels, tc.wantName, tc.wantDescription)
assert.Len(t, exp.GetSpans(), 1, "HTTP request was traced and span reported")
})
}
}
Expand Down Expand Up @@ -354,9 +354,9 @@ func TestGetCallRates(t *testing.T) {
defer mockPrometheus.Close()

m, err := reader.GetCallRates(context.Background(), &params)
assert.Len(t, exp.GetSpans(), 1, "HTTP request was traced and span reported")
require.NoError(t, err)
assertMetrics(t, m, tc.wantLabels, tc.wantName, tc.wantDescription)
assert.Len(t, exp.GetSpans(), 1, "HTTP request was traced and span reported")
})
}
}
Expand Down Expand Up @@ -479,9 +479,9 @@ func TestGetErrorRates(t *testing.T) {
defer mockPrometheus.Close()

m, err := reader.GetErrorRates(context.Background(), &params)
assert.Len(t, exp.GetSpans(), 1, "HTTP request was traced and span reported")
require.NoError(t, err)
assertMetrics(t, m, tc.wantLabels, tc.wantName, tc.wantDescription)
assert.Len(t, exp.GetSpans(), 1, "HTTP request was traced and span reported")
})
}
}
Expand Down Expand Up @@ -512,9 +512,9 @@ func TestWarningResponse(t *testing.T) {
defer mockPrometheus.Close()

m, err := reader.GetErrorRates(context.Background(), &params)
assert.Len(t, exp.GetSpans(), 1, "HTTP request was traced and span reported")
require.NoError(t, err)
assert.NotNil(t, m)
assert.Len(t, exp.GetSpans(), 1, "HTTP request was traced and span reported")
}

func TestGetRoundTripperTLSConfig(t *testing.T) {
Expand Down

0 comments on commit abeeeb6

Please sign in to comment.