diff --git a/src/main/kotlin/io/emeraldpay/dshackle/reader/SpannedReader.kt b/src/main/kotlin/io/emeraldpay/dshackle/reader/SpannedReader.kt index 71ec09ed..922c78c1 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/reader/SpannedReader.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/reader/SpannedReader.kt @@ -33,16 +33,16 @@ class SpannedReader( return reader.read(key) .contextWrite { ReactorSleuth.putSpanInScope(tracer, it, newSpan) } .doOnError { - newSpan.apply { - tag(SPAN_ERROR, "true") - tag(SPAN_STATUS_MESSAGE, it.message) - end() - } + newSpan.tag(SPAN_ERROR, "true") + .tag(SPAN_STATUS_MESSAGE, it.message) + .end() } .doOnNext { newSpan.end() } + .doOnCancel { + newSpan.tag(SPAN_STATUS_MESSAGE, "cancelled").end() + } .switchIfEmpty { - newSpan.tag(SPAN_READER_RESULT, "empty result") - newSpan.end() + newSpan.tag(SPAN_READER_RESULT, "empty result").end() Mono.empty() } } diff --git a/src/main/kotlin/io/emeraldpay/dshackle/rpc/NativeCall.kt b/src/main/kotlin/io/emeraldpay/dshackle/rpc/NativeCall.kt index 03b7b5ff..dcc32d87 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/rpc/NativeCall.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/rpc/NativeCall.kt @@ -124,6 +124,9 @@ open class NativeCall( ) } .doOnNext { callRes -> completeSpan(callRes, requestCount) } + .doOnCancel { + tracer.currentSpan()?.tag(SPAN_STATUS_MESSAGE, "cancel")?.end() + } .contextWrite { ctx -> createTracingReactorContext(ctx, requestCount, requestId, requestSpan) } } }