Show error spans like in dproxy (#144)

This commit is contained in:
KirillPamPam
2023-02-20 14:30:41 +04:00
committed by GitHub
parent acf559f3e1
commit 8310d79f9c

View File

@@ -126,17 +126,22 @@ open class NativeCall(
}
private fun completeSpan(callResult: CallResult, requestCount: Int) {
val span = tracer.currentSpan()
if (callResult.isError()) {
errorSpan(span, callResult.error?.message ?: "Internal error")
}
if (requestCount > 1) {
val span = tracer.currentSpan()
if (callResult.isError()) {
span?.error(
RuntimeException(callResult.error?.message ?: "Internal error")
)
}
span?.end()
}
}
private fun errorSpan(span: Span?, message: String) {
span?.apply {
tag("error", "true")
tag("status.message", message)
}
}
private fun createTracingReactorContext(
ctx: Context,
requestCount: Int,
@@ -222,10 +227,11 @@ open class NativeCall(
log.error("Lost context for a native call", it)
0
}
tracer.currentSpan()?.error(it)
val message = it?.message ?: "Internal error"
errorSpan(tracer.currentSpan(), message)
return BlockchainOuterClass.NativeCallReplyItem.newBuilder()
.setSucceed(false)
.setErrorMessage(it?.message ?: "Internal error")
.setErrorMessage(message)
.setErrorCode(500)
.setId(id)
.build()