Repository: jaegertracing/jaeger (Go)

Issue:
[Bug]: Operation metrics do not show up in SPM
### What happened?

Operation metrics do not show up in SPM when using v1.58.0

### Steps to reproduce

1. Using docker compose to setup all components: opentelemetry-collector, jaeger-collector, jaeger-cassandra-schema, jaeger-query, prometheus
2. jaeger-query with env var `METRICS_STORAGE_TYPE=prometheus` and args:
  1. --prometheus.server-url=http://prometheus:9090
  2. --prometheus.query.normalize-duration=true
  3. --prometheus.query.normalize-calls=true

### Expected behavior

Operation metrics show up in SPM as v1.57.0

### Relevant log output

Jquery UI v1.58.0 SPM Log

```
2024-06-22 13:21:54 {"level":"debug","ts":1719033714.6608455,"caller":"metricsstore/reader.go:269","msg":"Prometheus query results","results":"{service_name=\"sprint-boot\", span_name=\"GET /\"} =>\n0.10256410256410255 @[1719033414.598]\n0.12991608446596797 @[1719033474.598]\n0.15384746878178443 @[1719033534.598]\n0.17778172848285517 @[1719033594.598]\n0.20171147054499702 @[1719033654.598]\n0.22563716859540864 @[1719033714.598]\n{service_name=\"sprint-boot\", span_name=\"GET /chain\"} =>\n0.05128205128205127 @[1719033414.598]\n0.06495804223298399 @[1719033474.598]\n0.07521431807109462 @[1719033534.598]\n0.08889086424142759 @[1719033594.598]\n0.10085573527249851 @[1719033654.598]\n0.11281858429770432 @[1719033714.598]\n{service_name=\"sprint-boot\", span_name=\"GET /cpu_task\"} =>\n0.10427350427350426 @[1719033414.598]\n0.12991608446596797 @[1719033474.598]\n0.15213805246198683 @[1719033534.598]\n0.1794911681798057 @[1719033594.598]\n0.20342088978690379 @[1719033654.598]\n0.22563716859540864 @[1719033714.598]\n{service_name=\"sprint-boot\", span_name=\"GET /io_task\"} =>\n0.10427350427350426 @[1719033414.598]\n0.12991608446596797 @[1719033474.598]\n0.15213805246198683 @[1719033534.598]\n0.1794911681798057 @[1719033594.598]\n0.20342088978690379 @[1719033654.598]\n0.22563716859540864 @[1719033714.598]\n{service_name=\"sprint-boot\", span_name=\"GET /random_sleep\"} =>\n0.05128205128205127 @[1719033414.598]\n0.0632486200689581 @[1719033474.598]\n0.07521431807109462 @[1719033534.598]\n0.08889086424142759 @[1719033594.598]\n0.10085573527249851 @[1719033654.598]\n0.11281858429770432 @[1719033714.598]\n{service_name=\"sprint-boot\", span_name=\"GET /random_status\"} =>\n0.05128205128205128 @[1719033414.598]\n0.0632486200689581 @[1719033474.598]\n0.07521431807109462 @[1719033534.598]\n0.08889086424142759 @[1719033594.598]\n0.10085573527249851 @[1719033654.598]\n0.11281858429770432 @[1719033714.598]","query":"sum(rate(calls_total{service_name =~ \"sprint-boot\", span_kind =~ \"SPAN_KIND_SERVER\"}[10m])) by (service_name,span_name)","range":{"Start":"2024-06-22T05:16:54.598Z","End":"2024-06-22T05:21:54.598Z","Step":60000000000}}
2024-06-22 13:21:54 {"level":"debug","ts":1719033714.661306,"caller":"metricsstore/reader.go:269","msg":"Prometheus query results","results":"{service_name=\"sprint-boot\", span_name=\"GET /random_status\"} =>\n0.3333333333333333 @[1719033414.598]\n0.2972972972972973 @[1719033474.598]\n0.2727272727272727 @[1719033534.598]\n0.25 @[1719033594.598]\n0.2711864406779661 @[1719033654.598]\n0.28787878787878785 @[1719033714.598]","query":"sum(rate(calls_total{service_name =~ \"sprint-boot\", status_code = \"STATUS_CODE_ERROR\", span_kind =~ \"SPAN_KIND_SERVER\"}[10m])) by (service_name,span_name) / sum(rate(calls_total{service_name =~ \"sprint-boot\", span_kind =~ \"SPAN_KIND_SERVER\"}[10m])) by (service_name,span_name)","range":{"Start":"2024-06-22T05:16:54.598Z","End":"2024-06-22T05:21:54.598Z","Step":60000000000}}
```

Jaeger UI v1.57.0 SPM Log

```
2024-06-22 13:36:06 {"level":"debug","ts":1719034566.604898,"caller":"metricsstore/reader.go:280","msg":"Prometheus query results","results":"{service_name=\"fastapi\"} =>\n0.12361557437162476 @[1719034266.585]\n0.24508370370370366 @[1719034326.585]\n0.33814967295690274 @[1719034386.585]\n0.4562923921568627 @[1719034446.585]\n0.549230656665728 @[1719034506.585]\n0.6632368000000002 @[1719034566.585]","query":"sum(rate(calls_total{service_name =~ \"fastapi\", span_kind =~ \"SPAN_KIND_SERVER\"}[10m])) by (service_name)","range":{"Start":"2024-06-22T05:31:06.585Z","End":"2024-06-22T05:36:06.585Z","Step":60000000000}}
2024-06-22 13:36:06 {"level":"debug","ts":1719034566.6078162,"caller":"metricsstore/reader.go:280","msg":"Prometheus query results","results":"{service_name=\"fastapi\", span_name=\"GET /\"} =>\n9.299999999999999 @[1719034266.585]\n9.066666666666666 @[1719034326.585]\n8.600000000000003 @[1719034386.585]\n8.133333333333331 @[1719034446.585]\n7.749999999999998 @[1719034506.585]\n7.899999999999999 @[1719034566.585]\n{service_name=\"fastapi\", span_name=\"GET /chain\"} =>\n1380 @[1719034266.585]\n1380 @[1719034326.585]\n1380 @[1719034386.585]\n1380 @[1719034446.585]\n1380 @[1719034506.585]\n1380 @[1719034566.585]\n{service_name=\"fastapi\", span_name=\"GET /cpu_task\"} =>\n7.3500000000000005 @[1719034266.585]\n7.033333333333331 @[1719034326.585]\n6.633333333333333 @[1719034386.585]\n7.075000000000001 @[1719034446.585]\n7.275 @[1719034506.585]\n7.266666666666666 @[1719034566.585]\n{service_name=\"fastapi\", span_name=\"GET /io_task\"} =>\n1380 @[1719034266.585]\n1380 @[1719034326.585]\n1380 @[1719034386.585]\n1380 @[1719034446.585]\n1380 @[1719034506.585]\n1380 @[1719034566.585]\n{service_name=\"fastapi\", span_name=\"GET /random_sleep\"} =>\n9124.999999999998 @[1719034266.585]\n9062.499999999998 @[1719034326.585]\n8687.500000000002 @[1719034386.585]\n8550 @[1719034446.585]\n8749.999999999998 @[1719034506.585]\n8656.249999999998 @[1719034566.585]\n{service_name=\"fastapi\", span_name=\"GET /random_status\"} =>\n3.623583821887589 @[1719034266.585]\n4.696455934933791 @[1719034326.585]\n9.290976492187184 @[1719034386.585]\n5.660008580669294 @[1719034446.585]\n5.340169419574022 @[1719034506.585]\n4.926393026844507 @[1719034566.585]","query":"histogram_quantile(0.95, sum(rate(duration_milliseconds_bucket{service_name =~ \"fastapi\", span_kind =~ \"SPAN_KIND_SERVER\"}[10m])) by (service_name,span_name,le))","range":{"Start":"2024-06-22T05:31:06.585Z","End":"2024-06-22T05:36:06.585Z","Step":60000000000}}
2024-06-22 13:36:06 {"level":"debug","ts":1719034566.6137497,"caller":"metricsstore/reader.go:280","msg":"Prometheus query results","results":"{service_name=\"fastapi\", span_name=\"GET /random_status\"} =>\n0.2857142857142857 @[1719034266.585]\n0.13333333333333333 @[1719034326.585]\n0.19047619047619047 @[1719034386.585]\n0.13793103448275862 @[1719034446.585]\n0.1142857142857143 @[1719034506.585]\n0.09302325581395349 @[1719034566.585]","query":"sum(rate(calls_total{service_name =~ \"fastapi\", status_code = \"STATUS_CODE_ERROR\", span_kind =~ \"SPAN_KIND_SERVER\"}[10m])) by (service_name,span_name) / sum(rate(calls_total{service_name =~ \"fastapi\", span_kind =~ \"SPAN_KIND_SERVER\"}[10m])) by (service_name,span_name)","range":{"Start":"2024-06-22T05:31:06.585Z","End":"2024-06-22T05:36:06.585Z","Step":60000000000}}
2024-06-22 13:36:06 {"level":"debug","ts":1719034566.613718,"caller":"metricsstore/reader.go:280","msg":"Prometheus query results","results":"{service_name=\"fastapi\", span_name=\"GET /\"} =>\n0.028843634020045777 @[1719034266.585]\n0.052787259259259256 @[1719034326.585]\n0.07635637776446191 @[1719034386.585]\n0.09981396078431372 @[1719034446.585]\n0.12322482681602871 @[1719034506.585]\n0.14661024000000003 @[1719034566.585]\n{service_name=\"fastapi\", span_name=\"GET /chain\"} =>\n0.012361557437162477 @[1719034266.585]\n0.026393629629629628 @[1719034326.585]\n0.036360179887839 @[1719034386.585]\n0.04990698039215686 @[1719034446.585]\n0.05985205873921395 @[1719034506.585]\n0.07330512000000002 @[1719034566.585]\n{service_name=\"fastapi\", span_name=\"GET /cpu_task\"} =>\n0.026783374447185367 @[1719034266.585]\n0.05467251851851851 @[1719034326.585]\n0.07453836877006996 @[1719034386.585]\n0.10159635294117647 @[1719034446.585]\n0.1214644721472283 @[1719034506.585]\n0.14661024000000003 @[1719034566.585]\n{service_name=\"fastapi\", span_name=\"GET /io_task\"} =>\n0.026783374447185367 @[1719034266.585]\n0.05467251851851851 @[1719034326.585]\n0.07453836877006996 @[1719034386.585]\n0.10159635294117647 @[1719034446.585]\n0.1214644721472283 @[1719034506.585]\n0.14661024000000003 @[1719034566.585]\n{service_name=\"fastapi\", span_name=\"GET /random_sleep\"} =>\n0.014421817010022889 @[1719034266.585]\n0.028278888888888885 @[1719034326.585]\n0.03817818888223096 @[1719034386.585]\n0.051689372549019605 @[1719034446.585]\n0.061612413408014356 @[1719034506.585]\n0.07505048000000002 @[1719034566.585]\n{service_name=\"fastapi\", span_name=\"GET /random_status\"} =>\n0.01442181701002289 @[1719034266.585]\n0.028278888888888885 @[1719034326.585]\n0.03817818888223096 @[1719034386.585]\n0.05168937254901961 @[1719034446.585]\n0.061612413408014356 @[1719034506.585]\n0.07505048000000002 @[1719034566.585]","query":"sum(rate(calls_total{service_name =~ \"fastapi\", span_kind =~ \"SPAN_KIND_SERVER\"}[10m])) by (service_name,span_name)","range":{"Start":"2024-06-22T05:31:06.585Z","End":"2024-06-22T05:36:06.585Z","Step":60000000000}}
```

### Screenshot

v1.58.0 SPM is unable to show operation metrics 
![v1 58 0 spm](https://github.com/jaegertracing/jaeger-ui/assets/1564148/c56c72b7-6b4d-4a79-bbfe-0905f2ebaef7)

v1.57.0 SPM works fine
<img width="1415" alt="v1 57 0 spm" src="https://github.com/jaegertracing/jaeger-ui/assets/1564148/136ccaf7-dcf4-47fe-a4fe-7c24ba1456d9">


### Additional context

After the PR https://github.com/jaegertracing/jaeger/pull/5539, the label of operation has been modified to `span_name`. However, the Jaeger UI does not update, causing this issue. Using breakpoints, I checked this in versions v1.58.0 and v1.57.0.

Version v1.57.0 works fine.
![v1 57 0 js](https://github.com/jaegertracing/jaeger-ui/assets/1564148/9733baaa-665d-47fd-84cf-27767e6d4a48)

In version v1.58.0, the label name is `span_name`, so it is unable to retrieve operation metrics.
![v1 58 0 js](https://github.com/jaegertracing/jaeger-ui/assets/1564148/a40b33c2-a37a-494d-b3fd-9341a98e602d)

### Jaeger backend version

v1.58.0

### SDK

OpenTelemetry Python SDK v0.40b0

### Pipeline

OTEL SDK -> OpenTelemetry Collector -> Jaeger Collector -> Cassandra
OTEL SDK -> OpenTelemetry Collector -> Prometheus
Cassandra, Prometheus <- Jager Query

### Stogage backend

cassandra 4.1.2

### Operating system

macOS

### Deployment model

Docker

### Deployment configs

```shell
docker-compose.yaml

version: "3.4"

services:
  fastapi:
    build: ./app_fastapi/
    container_name: fastapi
    ports:
      - "8000:8000"
    environment:
      - TARGET_ONE_SVC=spring-boot:8080
      - TARGET_TWO_SVC=spring-boot:8080
      - OTEL_TRACES_EXPORTER=otlp
      - OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4317
      - OTEL_METRICS_EXPORTER=none
      - OTEL_SERVICE_NAME=fastapi
    command: "opentelemetry-instrument python main.py"

  spring-boot:
    build: ./app_springboot/
    container_name: spring-boot
    ports:
      - "8080:8080"
    environment:
      - TARGET_ONE_SVC=fastapi:8000
      - TARGET_TWO_SVC=fastapi:8000
      - OTEL_EXPORTER=otlp_span
      - OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4317
      - OTEL_EXPORTER_OTLP_INSECURE=true
      - OTEL_METRICS_EXPORTER=none
      - OTEL_SERVICE_NAME=sprint-boot
    command: "java -javaagent:/opentelemetry-javaagent.jar -jar /app.jar"

  otel-collector:
    image: otel/opentelemetry-collector-contrib:0.102.0
    container_name: otel-collector
    command:
      - "--config=/conf/config.yaml"
    volumes:
      - ./etc/otel-collector/jaeger.yaml:/conf/config.yaml
    ports:
      - "4317" # OTLP gRPC receiver
      - "4318" # OTLP http receiver
      - "8889:8889" # Prometheus metrics exporter
    restart: on-failure
    depends_on:
      - jaeger-collector

  jaeger-collector:
    image: jaegertracing/jaeger-collector:1.58.0
    container_name: jaeger-collector
    command: 
      - "--cassandra.keyspace=jaeger_v1_dc1"
      - "--cassandra.servers=cassandra"
      - "--collector.otlp.enabled=true"
    ports:
      - "4317" # accept OpenTelemetry Protocol (OTLP) over gRPC
    restart: on-failure
    depends_on:
      - cassandra-schema

  cassandra:
    image: cassandra:4.1.2
    container_name: cassandra

  cassandra-schema:
    image: jaegertracing/jaeger-cassandra-schema:1.58.0
    container_name: cassandra-schema
    depends_on:
      - cassandra

  jaeger-query:
    image: jaegertracing/jaeger-query:1.58.0
    container_name: jaeger-query
    environment:
      - METRICS_STORAGE_TYPE=prometheus
      - LOG_LEVEL=debug
    command:
      - "--cassandra.keyspace=jaeger_v1_dc1"
      - "--cassandra.servers=cassandra"
      - "--prometheus.server-url=http://prometheus:9090"
      - "--prometheus.query.normalize-duration=true"
      - "--prometheus.query.normalize-calls=true"
    ports:
      - "16686:16686"
      - "16687:16687"
    restart: on-failure
    depends_on:
      - cassandra-schema

  prometheus:
    image: prom/prometheus:v2.52.0
    container_name: prometheus
    ports:
      - "9090:9090"
    volumes:
      - ./etc/prometheus/:/etc/prometheus/
    command:
      - "--config.file=/etc/prometheus/prometheus.yml"


otel-collector config
```yaml
receivers:
  otlp:
    protocols:
      grpc:
      http: 

exporters:
  otlp:
    endpoint: jaeger-collector:4317
    tls:
      insecure: true
  prometheus:
    endpoint: "0.0.0.0:8889"

connectors:
  spanmetrics:

processors:
  batch:

service:
  pipelines:
    traces:
      receivers: [otlp]
      processors: [batch]
      exporters: [spanmetrics, otlp]
    metrics/spanmetrics:
      receivers: [spanmetrics]
      exporters: [prometheus]
```

Prometheus config
```
global:
  scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
  evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
  # scrape_timeout is set to the global default (10s).

# Alertmanager configuration
alerting:
  alertmanagers:
    - static_configs:
        - targets:
          # - alertmanager:9093

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  # - "first_rules.yml"
  # - "second_rules.yml"

# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: "prometheus"

    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

    static_configs:
      - targets: ["localhost:9090"]

  - job_name: aggregated-trace-metrics
    static_configs:
    - targets: ['otel-collector:8889']
```
```



Discussion:
A patch was released 1.58.1



Patch:
diff --git a/plugin/metrics/prometheus/metricsstore/dbmodel/to_domain.go b/plugin/metrics/prometheus/metricsstore/dbmodel/to_domain.go
index 65082c9d257..0a9510678ad 100644
--- a/plugin/metrics/prometheus/metricsstore/dbmodel/to_domain.go
+++ b/plugin/metrics/prometheus/metricsstore/dbmodel/to_domain.go
@@ -31,8 +31,8 @@ type Translator struct {
 // New returns a new Translator.
 func New(spanNameLabel string) Translator {
 	return Translator{
-		// "span_name" is the label name that Jaeger UI expects.
-		labelMap: map[string]string{spanNameLabel: "span_name"},
+		// "operation" is the label name that Jaeger UI expects.
+		labelMap: map[string]string{spanNameLabel: "operation"},
 	}
 }
 
diff --git a/plugin/metrics/prometheus/metricsstore/reader.go b/plugin/metrics/prometheus/metricsstore/reader.go
index 253a09ef8c3..e65c97edbdc 100644
--- a/plugin/metrics/prometheus/metricsstore/reader.go
+++ b/plugin/metrics/prometheus/metricsstore/reader.go
@@ -55,7 +55,7 @@ type (
 		metricsTranslator dbmodel.Translator
 		latencyMetricName string
 		callsMetricName   string
-		operationLabel    string
+		operationLabel    string // name of the attribute that contains span name / operation
 	}
 
 	promQueryParams struct {
@@ -90,7 +90,7 @@ func NewMetricsReader(cfg config.Configuration, logger *zap.Logger, tracer trace
 		return nil, fmt.Errorf("failed to initialize prometheus client: %w", err)
 	}
 
-	operationLabel := "span_name"
+	const operationLabel = "span_name"
 
 	mr := &MetricsReader{
 		client: promapi.NewAPI(client),


Test patch:
diff --git a/plugin/metrics/prometheus/metricsstore/dbmodel/to_domain_test.go b/plugin/metrics/prometheus/metricsstore/dbmodel/to_domain_test.go
index 25b8bf09c12..ad14ed3f4c2 100644
--- a/plugin/metrics/prometheus/metricsstore/dbmodel/to_domain_test.go
+++ b/plugin/metrics/prometheus/metricsstore/dbmodel/to_domain_test.go
@@ -48,7 +48,7 @@ func TestToDomainMetricsFamily(t *testing.T) {
 
 	wantMetricLabels := map[string]string{
 		"label_key": "label_value",
-		"span_name": "span_name_value", // assert the name is translated to a Jaeger-friendly label.
+		"operation": "span_name_value", // assert the name is translated to a Jaeger-friendly label.
 	}
 	assert.Len(t, mf.Metrics, 1)
 	for _, ml := range mf.Metrics[0].Labels {
diff --git a/plugin/metrics/prometheus/metricsstore/reader_test.go b/plugin/metrics/prometheus/metricsstore/reader_test.go
index 8dc4a0d2748..fb178d72599 100644
--- a/plugin/metrics/prometheus/metricsstore/reader_test.go
+++ b/plugin/metrics/prometheus/metricsstore/reader_test.go
@@ -16,7 +16,6 @@ package metricsstore
 
 import (
 	"context"
-	"fmt"
 	"io"
 	"net"
 	"net/http"
@@ -183,7 +182,7 @@ func TestGetLatencies(t *testing.T) {
 			wantName:         "service_operation_latencies",
 			wantDescription:  "0.95th quantile latency, grouped by service & operation",
 			wantLabels: map[string]string{
-				"span_name":    "/OrderResult",
+				"operation":    "/OrderResult",
 				"service_name": "emailservice",
 			},
 			wantPromQlQuery: `histogram_quantile(0.95, sum(rate(duration_bucket{service_name =~ "emailservice", ` +
@@ -215,7 +214,7 @@ func TestGetLatencies(t *testing.T) {
 			wantName:        "service_operation_latencies",
 			wantDescription: "0.95th quantile latency, grouped by service & operation",
 			wantLabels: map[string]string{
-				"span_name":    "/OrderResult",
+				"operation":    "/OrderResult",
 				"service_name": "emailservice",
 			},
 			wantPromQlQuery: `histogram_quantile(0.95, sum(rate(span_metrics_duration_bucket{service_name =~ "emailservice", ` +
@@ -234,7 +233,7 @@ func TestGetLatencies(t *testing.T) {
 			wantName:        "service_operation_latencies",
 			wantDescription: "0.95th quantile latency, grouped by service & operation",
 			wantLabels: map[string]string{
-				"span_name":    "/OrderResult",
+				"operation":    "/OrderResult",
 				"service_name": "emailservice",
 			},
 			wantPromQlQuery: `histogram_quantile(0.95, sum(rate(duration_seconds_bucket{service_name =~ "emailservice", ` +
@@ -257,7 +256,7 @@ func TestGetLatencies(t *testing.T) {
 
 			m, err := reader.GetLatencies(context.Background(), &params)
 			require.NoError(t, err)
-			assertMetrics(t, tc.name, m, tc.wantLabels, tc.wantName, tc.wantDescription)
+			assertMetrics(t, m, tc.wantLabels, tc.wantName, tc.wantDescription)
 			assert.Len(t, exp.GetSpans(), 1, "HTTP request was traced and span reported")
 		})
 	}
@@ -286,7 +285,7 @@ func TestGetCallRates(t *testing.T) {
 			wantName:         "service_operation_call_rate",
 			wantDescription:  "calls/sec, grouped by service & operation",
 			wantLabels: map[string]string{
-				"span_name":    "/OrderResult",
+				"operation":    "/OrderResult",
 				"service_name": "emailservice",
 			},
 			wantPromQlQuery: `sum(rate(calls{service_name =~ "emailservice", ` +
@@ -317,7 +316,7 @@ func TestGetCallRates(t *testing.T) {
 			wantName:        "service_operation_call_rate",
 			wantDescription: "calls/sec, grouped by service & operation",
 			wantLabels: map[string]string{
-				"span_name":    "/OrderResult",
+				"operation":    "/OrderResult",
 				"service_name": "emailservice",
 			},
 			wantPromQlQuery: `sum(rate(span_metrics_calls{service_name =~ "emailservice", ` +
@@ -335,7 +334,7 @@ func TestGetCallRates(t *testing.T) {
 			wantName:        "service_operation_call_rate",
 			wantDescription: "calls/sec, grouped by service & operation",
 			wantLabels: map[string]string{
-				"span_name":    "/OrderResult",
+				"operation":    "/OrderResult",
 				"service_name": "emailservice",
 			},
 			wantPromQlQuery: `sum(rate(calls_total{service_name =~ "emailservice", ` +
@@ -357,7 +356,7 @@ func TestGetCallRates(t *testing.T) {
 
 			m, err := reader.GetCallRates(context.Background(), &params)
 			require.NoError(t, err)
-			assertMetrics(t, tc.name, m, tc.wantLabels, tc.wantName, tc.wantDescription)
+			assertMetrics(t, m, tc.wantLabels, tc.wantName, tc.wantDescription)
 			assert.Len(t, exp.GetSpans(), 1, "HTTP request was traced and span reported")
 		})
 	}
@@ -387,7 +386,7 @@ func TestGetErrorRates(t *testing.T) {
 			wantName:         "service_operation_error_rate",
 			wantDescription:  "error rate, computed as a fraction of errors/sec over calls/sec, grouped by service & operation",
 			wantLabels: map[string]string{
-				"span_name":    "/OrderResult",
+				"operation":    "/OrderResult",
 				"service_name": "emailservice",
 			},
 			wantPromQlQuery: `sum(rate(calls{service_name =~ "emailservice", status_code = "STATUS_CODE_ERROR", ` +
@@ -439,7 +438,7 @@ func TestGetErrorRates(t *testing.T) {
 			wantName:        "service_operation_error_rate",
 			wantDescription: "error rate, computed as a fraction of errors/sec over calls/sec, grouped by service & operation",
 			wantLabels: map[string]string{
-				"span_name":    "/OrderResult",
+				"operation":    "/OrderResult",
 				"service_name": "emailservice",
 			},
 			wantPromQlQuery: `sum(rate(span_metrics_calls{service_name =~ "emailservice", status_code = "STATUS_CODE_ERROR", ` +
@@ -458,7 +457,7 @@ func TestGetErrorRates(t *testing.T) {
 			wantName:        "service_operation_error_rate",
 			wantDescription: "error rate, computed as a fraction of errors/sec over calls/sec, grouped by service & operation",
 			wantLabels: map[string]string{
-				"span_name":    "/OrderResult",
+				"operation":    "/OrderResult",
 				"service_name": "emailservice",
 			},
 			wantPromQlQuery: `sum(rate(calls_total{service_name =~ "emailservice", status_code = "STATUS_CODE_ERROR", ` +
@@ -481,7 +480,7 @@ func TestGetErrorRates(t *testing.T) {
 
 			m, err := reader.GetErrorRates(context.Background(), &params)
 			require.NoError(t, err)
-			assertMetrics(t, tc.name, m, tc.wantLabels, tc.wantName, tc.wantDescription)
+			assertMetrics(t, m, tc.wantLabels, tc.wantName, tc.wantDescription)
 			assert.Len(t, exp.GetSpans(), 1, "HTTP request was traced and span reported")
 		})
 	}
@@ -945,7 +944,7 @@ func prepareMetricsReaderAndServer(t *testing.T, config config.Configuration, wa
 	return reader, mockPrometheus
 }
 
-func assertMetrics(t *testing.T, testName string, gotMetrics *metrics.MetricFamily, wantLabels map[string]string, wantName, wantDescription string) {
+func assertMetrics(t *testing.T, gotMetrics *metrics.MetricFamily, wantLabels map[string]string, wantName, wantDescription string) {
 	assert.Len(t, gotMetrics.Metrics, 1)
 	assert.Equal(t, wantName, gotMetrics.Name)
 	assert.Equal(t, wantDescription, gotMetrics.Help)
@@ -953,9 +952,8 @@ func assertMetrics(t *testing.T, testName string, gotMetrics *metrics.MetricFami
 	assert.Len(t, mps, 1)
 
 	// logging for expected and actual labels
-	fmt.Printf("Test Name: %s\n", testName)
-	fmt.Printf("Expected labels: %v\n", wantLabels)
-	fmt.Printf("Actual labels: %v\n", gotMetrics.Metrics[0].Labels)
+	t.Logf("Expected labels: %v\n", wantLabels)
+	t.Logf("Actual labels: %v\n", gotMetrics.Metrics[0].Labels)
 
 	// There is no guaranteed order of labels, so we need to take the approach of using a map of expected values.
 	labels := gotMetrics.Metrics[0].Labels
@@ -968,8 +966,8 @@ func assertMetrics(t *testing.T, testName string, gotMetrics *metrics.MetricFami
 	assert.Empty(t, wantLabels)
 
 	// Additional logging to show that all expected labels were found and matched
-	fmt.Printf("Remaining expected labels after matching: %v\n", wantLabels)
-	fmt.Printf("\n")
+	t.Logf("Remaining expected labels after matching: %v\n", wantLabels)
+	t.Logf("\n")
 
 	assert.Equal(t, int64(1620351786), mps[0].Timestamp.GetSeconds())