From 111b97bbb2fdf65b874f0afc81d9029575ff58a8 Mon Sep 17 00:00:00 2001 From: sashass1315 Date: Tue, 3 Feb 2026 14:46:30 +0200 Subject: [PATCH] Update tracing_test.go --- rpc/tracing_test.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/rpc/tracing_test.go b/rpc/tracing_test.go index f32a647e6f..e77d7d89c7 100644 --- a/rpc/tracing_test.go +++ b/rpc/tracing_test.go @@ -19,6 +19,7 @@ package rpc import ( "context" "net/http/httptest" + "strings" "testing" "go.opentelemetry.io/otel" @@ -196,8 +197,8 @@ func TestTracingBatchHTTP(t *testing.T) { } // TestTracingSubscribeUnsubscribe verifies that subscribe and unsubscribe calls -// do not emit any spans. -// Note: This works because client.newClientConn() passes nil as the tracer provider. +// do not emit RPC server spans (like "jsonrpc.service/method"). +// Note: handleSubscribe does not create the main RPC span, only internal encoding spans. func TestTracingSubscribeUnsubscribe(t *testing.T) { t.Parallel() server, tracer, exporter := newTracingServer(t) @@ -213,12 +214,16 @@ func TestTracingSubscribeUnsubscribe(t *testing.T) { // Unsubscribe. sub.Unsubscribe() - // Flush and check that no spans were emitted. + // Flush and check that no RPC server spans were emitted. + // Internal spans like "rpc.encodeJSONResponse" are allowed. if err := tracer.ForceFlush(context.Background()); err != nil { t.Fatalf("failed to flush: %v", err) } spans := exporter.GetSpans() - if len(spans) != 0 { - t.Errorf("expected no spans for subscribe/unsubscribe, got %d", len(spans)) + for _, span := range spans { + // RPC server spans have names like "jsonrpc.service/method" + if strings.HasPrefix(span.Name, "jsonrpc.") { + t.Errorf("unexpected RPC server span for subscribe/unsubscribe: %s", span.Name) + } } }