mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-07 23:48:36 +00:00
Update tracing_test.go
This commit is contained in:
parent
5f17eea09c
commit
111b97bbb2
1 changed files with 10 additions and 5 deletions
|
|
@ -19,6 +19,7 @@ package rpc
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"go.opentelemetry.io/otel"
|
"go.opentelemetry.io/otel"
|
||||||
|
|
@ -196,8 +197,8 @@ func TestTracingBatchHTTP(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestTracingSubscribeUnsubscribe verifies that subscribe and unsubscribe calls
|
// TestTracingSubscribeUnsubscribe verifies that subscribe and unsubscribe calls
|
||||||
// do not emit any spans.
|
// do not emit RPC server spans (like "jsonrpc.service/method").
|
||||||
// Note: This works because client.newClientConn() passes nil as the tracer provider.
|
// Note: handleSubscribe does not create the main RPC span, only internal encoding spans.
|
||||||
func TestTracingSubscribeUnsubscribe(t *testing.T) {
|
func TestTracingSubscribeUnsubscribe(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
server, tracer, exporter := newTracingServer(t)
|
server, tracer, exporter := newTracingServer(t)
|
||||||
|
|
@ -213,12 +214,16 @@ func TestTracingSubscribeUnsubscribe(t *testing.T) {
|
||||||
// Unsubscribe.
|
// Unsubscribe.
|
||||||
sub.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 {
|
if err := tracer.ForceFlush(context.Background()); err != nil {
|
||||||
t.Fatalf("failed to flush: %v", err)
|
t.Fatalf("failed to flush: %v", err)
|
||||||
}
|
}
|
||||||
spans := exporter.GetSpans()
|
spans := exporter.GetSpans()
|
||||||
if len(spans) != 0 {
|
for _, span := range spans {
|
||||||
t.Errorf("expected no spans for subscribe/unsubscribe, got %d", len(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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue