From aa5bf04ef7f0a51afadf9d55646d18187ff27e37 Mon Sep 17 00:00:00 2001 From: Rodrigo Pastrana Date: Wed, 10 Apr 2024 11:08:27 -0400 Subject: [PATCH] HPCC-31570 SoapCall to propagate client span headers - New method param allows trace headers passed in to http request - Supplies client span trace header - Delays http req creation after client span - Ensures client span lifespan remains as tight as possible - Re-orders createHttpRequest params - Declares const param Signed-off-by: Rodrigo Pastrana --- common/thorhelper/thorsoapcall.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/common/thorhelper/thorsoapcall.cpp b/common/thorhelper/thorsoapcall.cpp index 9fa2dbcdd0c..bee4d69b47d 100644 --- a/common/thorhelper/thorsoapcall.cpp +++ b/common/thorhelper/thorsoapcall.cpp @@ -756,7 +756,7 @@ interface IWSCAsyncFor: public IInterface virtual void processException(const Url &url, ConstPointerArray &inputRows, IException *e) = 0; virtual void checkTimeLimitExceeded(unsigned * _remainingMS) = 0; - virtual void createHttpRequest(Url &url, StringBuffer &request) = 0; + virtual void createHttpRequest(StringBuffer &request, const Url &url, const IProperties * traceHeaders) = 0; virtual int readHttpResponse(StringBuffer &response, ISocket *socket, bool &keepAlive, StringBuffer &contentType) = 0; virtual void processResponse(Url &url, StringBuffer &response, ColumnProvider * meta, const char *contentType) = 0; @@ -1958,7 +1958,7 @@ class CWSCAsyncFor : implements IWSCAsyncFor, public CInterface, public CAsyncFo } } - void createHttpRequest(Url &url, StringBuffer &request) + void createHttpRequest(StringBuffer &request, const Url &url, const IProperties * traceHeaders) { // Create the HTTP POST request if (master->wscType == STsoap) @@ -1992,7 +1992,6 @@ class CWSCAsyncFor : implements IWSCAsyncFor, public CInterface, public CAsyncFo if (!httpHeaderBlockContainsHeader(httpheaders, ACCEPT_ENCODING)) request.appendf("%s: gzip, deflate\r\n", ACCEPT_ENCODING); #endif - Owned traceHeaders = ::getClientHeaders(master->activitySpanScope); if (traceHeaders) { Owned iter = traceHeaders->getIterator(); @@ -2454,7 +2453,6 @@ class CWSCAsyncFor : implements IWSCAsyncFor, public CInterface, public CAsyncFo unsigned retryInterval = 0; Url &url = master->urlArray.item(idx); - createHttpRequest(url, request); unsigned startidx = idx; while (!master->aborted) { @@ -2563,6 +2561,10 @@ class CWSCAsyncFor : implements IWSCAsyncFor, public CInterface, public CAsyncFo checkRoxieAbortMonitor(master->roxieAbortMonitor); OwnedSpanScope socketOperationSpan = master->activitySpanScope->createClientSpan("Socket Write"); setSpanURLAttributes(socketOperationSpan, url); + + Owned traceHeaders = ::getClientHeaders(socketOperationSpan); + createHttpRequest(request, url, traceHeaders); + socket->write(request.str(), request.length()); if (soapTraceLevel > 4)