@@ -77,14 +77,18 @@ private static SpanContext tryExtractTracingContext(byte[] userMetadataBytes) {
7777 if (!TraceId .isValid (traceId ) || !SpanId .isValid (spanId ))
7878 return null ;
7979
80- return SpanContext .createFromRemoteParent (traceId , spanId , TraceFlags .getSampled (), TraceState .getDefault ());
80+ return SpanContext .createFromRemoteParent (traceId , spanId , TraceFlags .getSampled (),
81+ TraceState .getDefault ());
8182 } catch (Throwable t ) {
8283 return null ;
8384 }
8485 }
8586
86- static CompletableFuture <WriteResult > traceAppend (BiFunction <ManagedChannel , List <EventData >, CompletableFuture <WriteResult >> appendOperation , ManagedChannel channel ,
87- List <EventData > events , String streamId , EventStoreDBClientSettings settings , UserCredentials optionalCallCredentials ) {
87+ static CompletableFuture <WriteResult > traceAppend (
88+ BiFunction <ManagedChannel , List <EventData >, CompletableFuture <WriteResult >> appendOperation ,
89+ ManagedChannel channel ,
90+ List <EventData > events , String streamId , EventStoreDBClientSettings settings ,
91+ UserCredentials optionalCallCredentials ) {
8892 Span span = createSpan (
8993 ClientTelemetryConstants .Operations .APPEND ,
9094 SpanKind .CLIENT ,
@@ -115,9 +119,13 @@ static CompletableFuture<WriteResult> traceAppend(BiFunction<ManagedChannel, Lis
115119 }
116120 }
117121
118- static void traceSubscribe (Runnable tracedOperation , String subscriptionId , ManagedChannel channel , EventStoreDBClientSettings settings ,
122+ static void traceSubscribe (Runnable tracedOperation , String subscriptionId , ManagedChannel channel ,
123+ EventStoreDBClientSettings settings ,
119124 UserCredentials optionalCallCredentials , RecordedEvent event ) {
120125 SpanContext remoteParentContext = tryExtractTracingContext (event .getUserMetadata ());
126+
127+ if (remoteParentContext == null ) return ;
128+
121129 Span span = createSpan (
122130 ClientTelemetryConstants .Operations .SUBSCRIBE ,
123131 SpanKind .CONSUMER ,
@@ -145,7 +153,8 @@ static void traceSubscribe(Runnable tracedOperation, String subscriptionId, Mana
145153 }
146154 }
147155
148- static Span createSpan (String operationName , SpanKind spanKind , SpanContext parentContext , ClientTelemetryTags customAttributes ) {
156+ static Span createSpan (String operationName , SpanKind spanKind , SpanContext parentContext ,
157+ ClientTelemetryTags customAttributes ) {
149158 SpanBuilder spanBuilder = getTracer ().spanBuilder (operationName ).setSpanKind (spanKind );
150159
151160 if (parentContext != null )
0 commit comments