diff --git a/plugin/metrics/prometheus/metricsstore/reader.go b/plugin/metrics/prometheus/metricsstore/reader.go index 99b968f6ef43..13595eebe5b1 100644 --- a/plugin/metrics/prometheus/metricsstore/reader.go +++ b/plugin/metrics/prometheus/metricsstore/reader.go @@ -29,6 +29,7 @@ import ( "github.com/prometheus/client_golang/api" promapi "github.com/prometheus/client_golang/api/prometheus/v1" "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/codes" semconv "go.opentelemetry.io/otel/semconv/v1.20.0" "go.opentelemetry.io/otel/trace" "go.uber.org/zap" @@ -302,6 +303,7 @@ func startSpanForQuery(ctx context.Context, metricName, query string, tp trace.T func logErrorToSpan(span trace.Span, err error) { span.RecordError(err, trace.WithAttributes(semconv.OTelStatusCodeError)) + span.SetStatus(codes.Error, err.Error()) } func getHTTPRoundTripper(c *config.Configuration, logger *zap.Logger) (rt http.RoundTripper, err error) { diff --git a/plugin/metrics/prometheus/metricsstore/reader_test.go b/plugin/metrics/prometheus/metricsstore/reader_test.go index 0caf3c84d0b1..56b53b0dbd88 100644 --- a/plugin/metrics/prometheus/metricsstore/reader_test.go +++ b/plugin/metrics/prometheus/metricsstore/reader_test.go @@ -155,7 +155,7 @@ func TestMetricsServerError(t *testing.T) { 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) + assert.Equal(t, "Error", exp.GetSpans()[0].Status.Code.String()) } func TestGetLatencies(t *testing.T) {