Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HPCC-33118 Update ESP to use new span scope classes #19368

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions esp/bindings/http/platform/httpservice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ int CEspHttpServer::processRequest()
//ensure the span is also terminated at the same time.
Owned<ISpan> serverSpan = m_request->createServerSpan(serviceName, methodName);
ctx->setRequestSpan(serverSpan);
ActiveSpanScope spanScope(serverSpan);

if (thebinding!=NULL)
{
Expand Down
2 changes: 1 addition & 1 deletion esp/bindings/http/platform/httptransport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1929,7 +1929,7 @@ ISpan * CHttpRequest::createServerSpan(const char * serviceName, const char * me

void CHttpRequest::annotateSpan(const char * key, const char * value)
{
m_context->queryActiveSpan()->setSpanAttribute(key, value);
queryThreadedActiveSpan()->setSpanAttribute(key, value);
}

void CHttpRequest::updateContext()
Expand Down
2 changes: 1 addition & 1 deletion esp/platform/esp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ interface IEspContext : extends IInterface
virtual IHttpMessage* queryRequest() = 0;

virtual void setRequestSpan(ISpan * span)=0; // Call this function to set the server span for the query. The spans's lifetime will match the lifetime of the context object.
virtual ISpan * queryActiveSpan() const = 0;
virtual ISpan * queryRequestSpan() const = 0;
virtual IProperties * getClientSpanHeaders() const = 0;
virtual const char* getGlobalId() const = 0;
virtual const char* getCallerId() const = 0;
Expand Down
8 changes: 5 additions & 3 deletions esp/platform/espcontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class CEspContext : public CInterface, implements IEspContext
Owned<IEspSecureContextEx> m_secureContext;

StringAttr m_transactionID;
OwnedActiveSpanScope m_requestSpan; // When the context is destroy the span will end.
OwnedSpanLifetime m_requestSpan; // When the context is destroy the span will end.
IHttpMessage* m_request;

public:
Expand Down Expand Up @@ -628,9 +628,11 @@ class CEspContext : public CInterface, implements IEspContext
}
virtual void setRequestSpan(ISpan * span) override
{
m_requestSpan.set(span);
// The server span for a request can be set only once.
if (span && span != m_requestSpan && m_requestSpan == queryNullSpan())
m_requestSpan.set(span);
}
virtual ISpan * queryActiveSpan() const override
virtual ISpan * queryRequestSpan() const override
{
return m_requestSpan;
}
Expand Down
2 changes: 1 addition & 1 deletion esp/services/esdl_svc_engine/esdl_binding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1571,7 +1571,7 @@ void EsdlServiceImpl::sendTargetSOAP(IEspContext & context,
httpclient->setPassword(password.str());
}

ISpan * activeSpan = context.queryActiveSpan();
ISpan * activeSpan = queryThreadedActiveSpan();
OwnedActiveSpanScope clientSpan(activeSpan->createClientSpan("soapcall"));

Owned<IProperties> headers = ::getClientHeaders(clientSpan);
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 @@ -2068,7 +2068,7 @@ int CWsEclBinding::submitWsEclWorkunit(IEspContext & context, WsEclWuInfo &wsinf

bool noTimeout = false;

ISpan * activeSpan = context.queryActiveSpan();
ISpan * activeSpan = queryThreadedActiveSpan();
OwnedActiveSpanScope clientSpan(activeSpan->createClientSpan("run_workunit"));
Owned<IProperties> httpHeaders = ::getClientHeaders(clientSpan);
recordTraceDebugOptions(workunit, httpHeaders);
Expand Down
2 changes: 1 addition & 1 deletion esp/services/ws_workunits/ws_workunitsHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3792,7 +3792,7 @@ void WsWuHelpers::submitWsWorkunit(IEspContext& context, IConstWorkUnit* cw, con
}
}

ISpan * activeSpan = context.queryActiveSpan();
ISpan * activeSpan = queryThreadedActiveSpan();
OwnedActiveSpanScope clientSpan(activeSpan->createClientSpan("run_workunit"));
Owned<IProperties> httpHeaders = ::getClientHeaders(clientSpan);
recordTraceDebugOptions(wu, httpHeaders);
Expand Down
2 changes: 1 addition & 1 deletion system/jlib/jtrace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ extern jlib_decl void testJLogExporterPrintAttributes(StringBuffer & out, const
*/

//The following class is responsible for ensuring that the active span is restored in a context when the scope is exited
//Use a template class so it can be reused for IContextLogger and IEspContext
//Use a template class so it can be used for IContextLogger and any other conforming interface.
template <class CONTEXT>
class ContextSpanScopeImp
{
Expand Down
Loading