From 862e826861a640f959d3e3fac0feee5f077d8016 Mon Sep 17 00:00:00 2001 From: Rodrigo Pastrana Date: Tue, 2 Jul 2024 15:43:01 -0400 Subject: [PATCH] HPCC-31971 SoapCall Span Enhancement - Renames socket write span - Provides target url and service in name - Provides target service and request type Signed-off-by: Rodrigo Pastrana --- common/thorhelper/thorsoapcall.cpp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/common/thorhelper/thorsoapcall.cpp b/common/thorhelper/thorsoapcall.cpp index bee4d69b47d..99c5241ecc7 100644 --- a/common/thorhelper/thorsoapcall.cpp +++ b/common/thorhelper/thorsoapcall.cpp @@ -2559,10 +2559,16 @@ class CWSCAsyncFor : implements IWSCAsyncFor, public CInterface, public CAsyncFo { checkTimeLimitExceeded(&remainingMS); checkRoxieAbortMonitor(master->roxieAbortMonitor); - OwnedSpanScope socketOperationSpan = master->activitySpanScope->createClientSpan("Socket Write"); - setSpanURLAttributes(socketOperationSpan, url); - Owned traceHeaders = ::getClientHeaders(socketOperationSpan); + StringBuffer spanName; + spanName.appendf("%s %s %s:%d", getWsCallTypeName(master->wscType), master->service.str(), url.host.str(), url.port); + OwnedSpanScope requestSpan = master->activitySpanScope->createClientSpan(spanName.str()); + + setSpanURLAttributes(requestSpan, url); + requestSpan->setSpanAttribute("request.type", getWsCallTypeName(master->wscType)); + requestSpan->setSpanAttribute("service.name", master->service.str()); + + Owned traceHeaders = ::getClientHeaders(requestSpan); createHttpRequest(request, url, traceHeaders); socket->write(request.str(), request.length()); @@ -2575,7 +2581,7 @@ class CWSCAsyncFor : implements IWSCAsyncFor, public CInterface, public CAsyncFo bool keepAlive2; StringBuffer contentType; int rval = readHttpResponse(response, socket, keepAlive2, contentType); - socketOperationSpan->setSpanAttribute("http.response.status_code", (int64_t)rval); + requestSpan->setSpanAttribute("http.response.status_code", (int64_t)rval); keepAlive = keepAlive && keepAlive2; if (soapTraceLevel > 4) @@ -2583,22 +2589,22 @@ class CWSCAsyncFor : implements IWSCAsyncFor, public CInterface, public CAsyncFo if (rval != 200) { - socketOperationSpan->setSpanStatusSuccess(false); + requestSpan->setSpanStatusSuccess(false); if (rval == 503) { - socketOperationSpan->recordError(SpanError("Server Too Busy", 1001, true, true)); + requestSpan->recordError(SpanError("Server Too Busy", 1001, true, true)); throw new ReceivedRoxieException(1001, "Server Too Busy"); } StringBuffer text; text.appendf("HTTP error (%d) in processQuery",rval); rtlAddExceptionTag(text, "soapresponse", response.str()); - socketOperationSpan->recordError(SpanError(text.str(), -1, true, true)); + requestSpan->recordError(SpanError(text.str(), -1, true, true)); throw MakeStringExceptionDirect(-1, text.str()); } if (response.length() == 0) { - socketOperationSpan->recordError(SpanError("Zero length response in processQuery", -1, true, true)); + requestSpan->recordError(SpanError("Zero length response in processQuery", -1, true, true)); throw MakeStringException(-1, "Zero length response in processQuery"); } checkTimeLimitExceeded(&remainingMS); @@ -2614,7 +2620,7 @@ class CWSCAsyncFor : implements IWSCAsyncFor, public CInterface, public CAsyncFo persistentHandler->add(socket, &ep, proto); } - socketOperationSpan->setSpanStatusSuccess(true); + requestSpan->setSpanStatusSuccess(true); break; } catch (IReceivedRoxieException *e)