From 628e1b3a3f8fe8fad59a2276e55b7f3b67053d72 Mon Sep 17 00:00:00 2001 From: Deepanshu Mehndiratta Date: Tue, 29 Aug 2023 11:43:18 +0530 Subject: [PATCH] Emit the error code and type to the tracing span for inbound calls (#903) * Emit the error code and type to the tracing span for inbound calls * Update Inbound Span error type and code fields and emit tags instead of logs * Change Error Type Span Tag key to rpc.tchannel.error_type --- inbound.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/inbound.go b/inbound.go index b89e697c..cd4a570f 100644 --- a/inbound.go +++ b/inbound.go @@ -31,6 +31,11 @@ import ( "golang.org/x/net/context" ) +const ( + systemErrorType = "system" + appErrorType = "application" +) + var errInboundRequestAlreadyActive = errors.New("inbound request is already active; possible duplicate client id") // handleCallReq handles an incoming call request, registering a message @@ -415,6 +420,13 @@ func (response *InboundCallResponse) doneSending() { if span := response.span; span != nil { if response.applicationError || response.systemError { ext.Error.Set(span, true) + errorType := appErrorType + if response.systemError { + errorType = systemErrorType + // if the error is a system error, set the error code in span log + span.SetTag("rpc.tchannel.system_error_code", GetSystemErrorCode(response.err)) + } + span.SetTag("rpc.tchannel.error_type", errorType) } span.FinishWithOptions(opentracing.FinishOptions{FinishTime: now}) }