Skip to content

Commit

Permalink
HPCC-30397 Review existing server spans to match expected conventions
Browse files Browse the repository at this point in the history
Signed-off-by: Gavin Halliday <[email protected]>
  • Loading branch information
ghalliday committed Nov 20, 2023
1 parent 3630d8f commit 61cc451
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 13 deletions.
3 changes: 2 additions & 1 deletion ecl/eclagent/eclagent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2131,7 +2131,8 @@ void EclAgent::runProcess(IEclProcess *process)
allocatorMetaCache.setown(createRowAllocatorCache(this));

Owned<IProperties> traceHeaders = extractTraceDebugOptions(queryWorkUnit());
Owned<ISpan> requestSpan = queryTraceManager().createServerSpan(queryWorkUnit()->queryWuid(), traceHeaders);
Owned<ISpan> requestSpan = queryTraceManager().createServerSpan("run_workunit", traceHeaders);
requestSpan->setSpanAttribute("hpcc.wuid", queryWorkUnit()->queryWuid());
updateDummyContextLogger().setActiveSpan(requestSpan);

// a component may specify an alternate name for the agent/workflow memory area,
Expand Down
2 changes: 1 addition & 1 deletion esp/bindings/http/platform/httpservice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ int CEspHttpServer::processRequest()
}

//Avoids unrestrictedSSType requests
m_request->startSpan();
m_request->startSpan(serviceName, methodName);

if(stricmp(method.str(), POST_METHOD)==0)
thebinding->handleHttpPost(m_request.get(), m_response.get());
Expand Down
9 changes: 7 additions & 2 deletions esp/bindings/http/platform/httptransport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1915,11 +1915,16 @@ int CHttpRequest::receive(IMultiException *me)
return 0;
}

void CHttpRequest::startSpan()
void CHttpRequest::startSpan(const char * serviceName, const char * methodName)
{
//MORE: The previous code would be better off querying httpHeaders...
StringBuffer spanName;
spanName.append(serviceName);
if (!isEmptyString(methodName))
spanName.append("/").append(methodName);
spanName.toLowerCase();
Owned<IProperties> httpHeaders = getHeadersAsProperties(m_headers);
Owned<ISpan> requestSpan = queryTraceManager().createServerSpan("HTTPRequest", httpHeaders, SpanFlags::EnsureGlobalId);
Owned<ISpan> requestSpan = queryTraceManager().createServerSpan(spanName, httpHeaders, SpanFlags::EnsureGlobalId);
m_context->setActiveSpan(requestSpan);
}

Expand Down
2 changes: 1 addition & 1 deletion esp/bindings/http/platform/httptransport.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ public:

virtual int receive(IMultiException *me);

void startSpan();
void startSpan(const char * serviceName, const char * methodName);
void updateContext();
void annotateSpan(const char * key, const char * value);

Expand Down
2 changes: 1 addition & 1 deletion esp/services/ws_ecl/ws_ecl_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2001,7 +2001,7 @@ int CWsEclBinding::submitWsEclWorkunit(IEspContext & context, WsEclWuInfo &wsinf

Owned<ISpan> clientSpan;
ISpan * activeSpan = context.queryActiveSpan();
clientSpan.setown(activeSpan->createClientSpan("wsecl/SubmitWorkunit"));
clientSpan.setown(activeSpan->createClientSpan("run_workunit"));
Owned<IProperties> httpHeaders = ::getClientHeaders(clientSpan);
recordTraceDebugOptions(workunit, httpHeaders);

Expand Down
5 changes: 5 additions & 0 deletions esp/services/ws_workunits/ws_workunitsHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3769,6 +3769,11 @@ void WsWuHelpers::submitWsWorkunit(IEspContext& context, IConstWorkUnit* cw, con
}
}

ISpan * activeSpan = context.queryActiveSpan();
Owned<ISpan> clientSpan(activeSpan->createClientSpan("run_workunit"));
Owned<IProperties> httpHeaders = ::getClientHeaders(clientSpan);
recordTraceDebugOptions(wu, httpHeaders);

if (resetWorkflow)
wu->resetWorkflow();
if (!compile)
Expand Down
8 changes: 5 additions & 3 deletions roxie/ccd/ccdlistener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1179,7 +1179,8 @@ class RoxieWorkUnitWorker : public RoxieQueryWorker
Owned<StringContextLogger> logctx = new StringContextLogger(wuid.get());

Owned<IProperties> traceHeaders = extractTraceDebugOptions(wu);
Owned<ISpan> requestSpan = queryTraceManager().createServerSpan(wu->queryWuid(), traceHeaders);
Owned<ISpan> requestSpan = queryTraceManager().createServerSpan("run_workunit", traceHeaders);
requestSpan->setSpanAttribute("hpcc.wuid", wuid);
logctx->setActiveSpan(requestSpan);

Owned<IQueryFactory> queryFactory;
Expand Down Expand Up @@ -1438,7 +1439,7 @@ class RoxieProtocolMsgContext : implements IHpccProtocolMsgContext, public CInte
return *cascade;
}

virtual void startSpan(const char * id, const IProperties * headers) override
virtual void startSpan(const char * id, const char * queryName, const IProperties * headers) override
{
Linked<const IProperties> allHeaders = headers;
SpanFlags flags = (ensureGlobalIdExists) ? SpanFlags::EnsureGlobalId : SpanFlags::None;
Expand All @@ -1455,7 +1456,8 @@ class RoxieProtocolMsgContext : implements IHpccProtocolMsgContext, public CInte

ensureContextLogger();

Owned<ISpan> requestSpan = queryTraceManager().createServerSpan("request", allHeaders, flags);
const char * spanName = !isEmptyString(queryName) ? queryName : "run_query";
Owned<ISpan> requestSpan = queryTraceManager().createServerSpan(spanName, allHeaders, flags);
logctx->setActiveSpan(requestSpan);

const char * globalId = requestSpan->queryGlobalId();
Expand Down
2 changes: 1 addition & 1 deletion roxie/ccd/ccdprotocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1891,7 +1891,7 @@ class RoxieSocketWorker : public ProtocolQueryWorker
uid = NULL;
sanitizeQuery(queryPT, queryName, sanitizedText, httpHelper, uid, isBlind, isDebug);

msgctx->startSpan(uid, httpHelper.queryRequestHeaders());
msgctx->startSpan(uid, queryName, httpHelper.queryRequestHeaders());

if (!uid)
uid = "-";
Expand Down
2 changes: 1 addition & 1 deletion roxie/ccd/hpccprotocol.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ interface IHpccProtocolMsgContext : extends IInterface
virtual bool getIntercept() = 0;
virtual void outputLogXML(IXmlStreamFlusher &out) = 0;
virtual void writeLogXML(IXmlWriter &writer) = 0;
virtual void startSpan(const char * uid, const IProperties * headers) = 0;
virtual void startSpan(const char * uid, const char * queryName, const IProperties * headers) = 0;
};

interface IHpccProtocolResultsWriter : extends IInterface
Expand Down
4 changes: 3 additions & 1 deletion thorlcr/graph/thgraphmaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1485,7 +1485,9 @@ CJobMaster::CJobMaster(IConstWorkUnit &_workunit, const char *graphName, ILoaded
init();

Owned<IProperties> traceHeaders = extractTraceDebugOptions(workunit);
Owned<ISpan> requestSpan = queryTraceManager().createServerSpan(workunit->queryWuid(), traceHeaders);
Owned<ISpan> requestSpan = queryTraceManager().createServerSpan("run_graph", traceHeaders);
requestSpan->setSpanAttribute("hpcc.wuid", workunit->queryWuid());
requestSpan->setSpanAttribute("hpcc.graph", graphName);
logctx->setActiveSpan(requestSpan);

resumed = WUActionResume == workunit->getAction();
Expand Down
4 changes: 3 additions & 1 deletion thorlcr/graph/thgraphslave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1680,7 +1680,9 @@ CJobSlave::CJobSlave(ISlaveWatchdog *_watchdog, IPropertyTree *_workUnitInfo, co
init();

Owned<IProperties> traceHeaders = deserializeTraceDebugOptions(workUnitInfo->queryPropTree("Debug"));
Owned<ISpan> requestSpan = queryTraceManager().createServerSpan(wuid, traceHeaders);
Owned<ISpan> requestSpan = queryTraceManager().createServerSpan("run_graph", traceHeaders);
requestSpan->setSpanAttribute("hpcc.wuid", wuid);
requestSpan->setSpanAttribute("hpcc.graph", graphName);
logctx->setActiveSpan(requestSpan);

oldNodeCacheMem = 0;
Expand Down

0 comments on commit 61cc451

Please sign in to comment.