-
Notifications
You must be signed in to change notification settings - Fork 304
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-30350 Add open telemetry support to roxie/hthor/thor #17822
Conversation
@rpastrana @afishbeck this is ready for review.
And the traceid/spanid was created and the remote span id was recorded for the child soapcalls. |
https://track.hpccsystems.com/browse/HPCC-30350 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ghalliday looks good, left a few questions and suggestions on minor concerns.
system/jlib/jtrace.cpp
Outdated
virtual void getLogPrefix(StringBuffer & out) const override | ||
{ | ||
const char * caller = queryCallerId(); | ||
if (caller) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
!isEmptyString ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will change
system/jlib/jtrace.cpp
Outdated
if (caller) | ||
{ | ||
out.append('['); | ||
if (caller) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is test on L:259 enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The outer condition is not right - I have since fixed.
system/jlib/jtrace.cpp
Outdated
out.appendf("caller:%s", caller); | ||
|
||
const char *local = queryLocalId(); | ||
if (local && *local) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
!isEmptyString ?
system/jlib/jtrace.cpp
Outdated
const char *local = queryLocalId(); | ||
if (local && *local) | ||
{ | ||
if (caller) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
L:259?
const char * queryTraceName() const | ||
{ | ||
return tracerName.get(); | ||
} | ||
|
||
virtual const char* queryGlobalId() const override |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in this file we typically have a new line between method definitions.
system/jlib/jtrace.cpp
Outdated
@@ -518,6 +515,12 @@ class CServerSpan : public CSpan | |||
hpccGlobalId.set(httpHeaders->queryProp(kGlobalIdHttpHeaderName)); | |||
else if (httpHeaders->hasProp(kLegacyGlobalIdHttpHeaderName)) | |||
hpccGlobalId.set(httpHeaders->queryProp(kLegacyGlobalIdHttpHeaderName)); | |||
else if (hasMask(flags, SpanFlags::EnsureGlobalId)) | |||
{ | |||
StringBuffer gen_id; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor, but var name doesn't follow file convention
StringBuffer gen_id; | ||
appendGloballyUniqueId(gen_id); | ||
hpccGlobalId.set(gen_id.str()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looking over the new span flags, I notice we're not handling 'EnsureTraceId' here, and now I'm wondering what that flag's intention is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the current behavior if a server span is created but there is not a trace header? Do we end up with a server span with it's own trace-id, but no reference to a remote parent span?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may not be needed - I will delete for the moment, and can add back in later.
@@ -2863,25 +2868,33 @@ class DummyLogCtx : implements IContextLogger | |||
{ | |||
return 0; | |||
} | |||
virtual void setGlobalId(const char *id, SocketEndpoint &ep, unsigned pid) override | |||
virtual void setActiveSpan(ISpan * span) override |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor, but this overloads the OTel "active span" concept, but it seems to convey a slightly different meaning. I would consider another term (not sure what it would be)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I've seen of the OTel active span concept it's basically for single threaded applications. I see this as the "per query" version of the active span concept.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I've seen of the OTel active span concept it's basically for single threaded applications. I see this as the "per query" version of the active span concept.
@afishbeck is this in reply to my comment to Gavin?
If so, it is still overloading the term and can be misunderstood. It should go without saying, and I'm sure you'll agree, we should avoid any/all potential confusion if possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I could see someone already familiar with the OTel API making an assumption about what this means when they read the name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any suggestions for a better name? setCurrentSpan()?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
current span was my immediate thought as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think "current span" would be fine here.
system/jlib/jlog.cpp
Outdated
@@ -2822,10 +2822,15 @@ void IContextLogger::logOperatorException(IException *E, const char *file, unsig | |||
} | |||
class CRuntimeStatisticCollection; | |||
|
|||
/* | |||
This class is used to implement the defauult log context - especially used for engines that only support a single query at a time |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very minor, 'default'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ghalliday some comments / questions.
if (globalId.length()) | ||
{ | ||
workunit->setDebugValue("GlobalId", globalId.str(), true); | ||
workunit->setDebugValue("GlobalIdHeader", globalIdHeader.str(), true); //use same header received |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ghalliday @rpastrana Note for when the ESP instrumentation is done, but I would expect open telemetry headers to also be added to the workunit here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes - I would actually expect this to now call the new function recordTraceDebugOptions()
common/thorhelper/thorsoapcall.cpp
Outdated
{ | ||
const char * key = iter->getPropKey(); | ||
if (!httpHeaderBlockContainsHeader(httpheaders, key)) | ||
request.append(key).append(": ").append(traceHeaders->queryProp(key)).append("\r\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any chance the value is empty?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pass. I'll add a check.
roxie/ccd/ccdlistener.cpp
Outdated
s.append("]"); | ||
ensureContextLogger(); | ||
|
||
Owned<ISpan> requestSpan = queryTraceManager().createServerSpan("request", headers, flags); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be passing allHeaders?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well spotted. I will fix.
@@ -2863,25 +2868,33 @@ class DummyLogCtx : implements IContextLogger | |||
{ | |||
return 0; | |||
} | |||
virtual void setGlobalId(const char *id, SocketEndpoint &ep, unsigned pid) override | |||
virtual void setActiveSpan(ISpan * span) override |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I've seen of the OTel active span concept it's basically for single threaded applications. I see this as the "per query" version of the active span concept.
@@ -1308,6 +1302,7 @@ class RoxieWorkUnitWorker : public RoxieQueryWorker | |||
StringBuffer s; | |||
logctx.getStats(s); | |||
|
|||
//MORE: logctx.queryActiveSpan()->getLogPrefix() or similar. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed we need a consistent way of doing this for each flavor of tracing. And longer term we will need to make sure there is enough info to tie traces and log lines together so the tools can hop between the two.
msgctx->setTransactionId(uid, nullptr, false); | ||
else | ||
|
||
msgctx->startSpan(uid, httpHelper.queryRequestHeaders()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not too clear on how this interacts with or replaces the span created above, currently line 1801:
msgctx->startSpan(nullptr, httpHelper.queryRequestHeaders());
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this really just be setting attributes on the initial span. For example if necessary updating the global-id header or related attributes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant to delete the 1st one - I will fix. You should not be able to update the global-id/trace-id once the span has been started. Other properties are ok though.
StringBuffer gen_id; | ||
appendGloballyUniqueId(gen_id); | ||
hpccGlobalId.set(gen_id.str()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the current behavior if a server span is created but there is not a trace header? Do we end up with a server span with it's own trace-id, but no reference to a remote parent span?
roxie/ccd/ccdprotocol.cpp
Outdated
} | ||
} | ||
|
||
msgctx->startSpan(nullptr, httpHelper.queryRequestHeaders()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spans will be used to analyze timings. Since there is a delay from when the socket was accepted and when the span is created I think we should have saved off the real start times and pass them in here to be used for the span.
From the open telemetry c++ sdk docs:
struct StartSpanOptions
{
// Optionally sets the start time of a Span.
//
// If the start time of a Span is set, timestamps from both the system clock
// and steady clock must be provided.
//
// Timestamps from the steady clock can be used to most accurately measure a
// Span's duration, while timestamps from the system clock can be used to most
// accurately place a Span's
// time point relative to other Spans collected across a distributed system.
common::SystemTimestamp start_system_time;
common::SteadyTimestamp start_steady_time;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created HPCC-30374 and pasted your comment from here in there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will push an update.
common/thorhelper/thorsoapcall.cpp
Outdated
{ | ||
const char * key = iter->getPropKey(); | ||
if (!httpHeaderBlockContainsHeader(httpheaders, key)) | ||
request.append(key).append(": ").append(traceHeaders->queryProp(key)).append("\r\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pass. I'll add a check.
if (globalId.length()) | ||
{ | ||
workunit->setDebugValue("GlobalId", globalId.str(), true); | ||
workunit->setDebugValue("GlobalIdHeader", globalIdHeader.str(), true); //use same header received |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes - I would actually expect this to now call the new function recordTraceDebugOptions()
roxie/ccd/ccdlistener.cpp
Outdated
s.append("]"); | ||
ensureContextLogger(); | ||
|
||
Owned<ISpan> requestSpan = queryTraceManager().createServerSpan("request", headers, flags); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well spotted. I will fix.
roxie/ccd/ccdprotocol.cpp
Outdated
} | ||
} | ||
|
||
msgctx->startSpan(nullptr, httpHelper.queryRequestHeaders()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created HPCC-30374 and pasted your comment from here in there.
msgctx->setTransactionId(uid, nullptr, false); | ||
else | ||
|
||
msgctx->startSpan(uid, httpHelper.queryRequestHeaders()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant to delete the 1st one - I will fix. You should not be able to update the global-id/trace-id once the span has been started. Other properties are ok though.
@@ -2863,25 +2868,33 @@ class DummyLogCtx : implements IContextLogger | |||
{ | |||
return 0; | |||
} | |||
virtual void setGlobalId(const char *id, SocketEndpoint &ep, unsigned pid) override | |||
virtual void setActiveSpan(ISpan * span) override |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any suggestions for a better name? setCurrentSpan()?
system/jlib/jtrace.cpp
Outdated
virtual void getLogPrefix(StringBuffer & out) const override | ||
{ | ||
const char * caller = queryCallerId(); | ||
if (caller) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will change
system/jlib/jtrace.cpp
Outdated
if (caller) | ||
{ | ||
out.append('['); | ||
if (caller) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The outer condition is not right - I have since fixed.
StringBuffer gen_id; | ||
appendGloballyUniqueId(gen_id); | ||
hpccGlobalId.set(gen_id.str()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may not be needed - I will delete for the moment, and can add back in later.
dd3d336
to
e5f3441
Compare
@afishbeck @rpastrana rebased and issues addressed (2 new commits, 1 from changes I spotted, and second in response to reviews) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ghalliday I didn't find any worthwhile issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ghalliday A couple of general comments, and I think you were going to rename ActiveSpan, otherwise ready to approve.
helm/hpcc/values.schema.json
Outdated
@@ -1743,12 +1743,12 @@ | |||
"httpCallerIdHeader": { | |||
"type": "string", | |||
"default": "HPCC-Caller-Id", | |||
"description": "HTTP Header field to use for sending and receiving CallerId" | |||
"description": "HTTP Header field to use for sending and receiving CallerId (deprecated and ignored)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should disappear when rebased?
@@ -2863,25 +2868,33 @@ class DummyLogCtx : implements IContextLogger | |||
{ | |||
return 0; | |||
} | |||
virtual void setGlobalId(const char *id, SocketEndpoint &ep, unsigned pid) override | |||
virtual void setActiveSpan(ISpan * span) override |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think "current span" would be fine here.
@@ -351,11 +301,57 @@ class CSpan : public CInterfaceOf<ISpan> | |||
return opentelemetry::trace::SpanContext::GetInvalid(); | |||
} | |||
|
|||
virtual void getLogPrefix(StringBuffer & out) const override |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar comment elsewhere. We want to avoid verbosity but ultimately should the span id be included here so that log processors can tie the trace info to the log lines. It makes for really nice navigation through the UI?
We have to maintain bw compatibility with the global-id services. But long term I hope that the global-id and local-id become attributes of the span and we only log the span-id.
The back end could then tie everything together. But that requires coordination with Kevin L. and Shanaka.
ac588bc
to
429f1f7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One comment
roxie/ccd/ccdlistener.cpp
Outdated
|
||
Owned<IProperties> traceHeaders = extractTraceDebugOptions(wu); | ||
Owned<ISpan> requestSpan = queryTraceManager().createServerSpan(wu->queryWuid(), traceHeaders); | ||
updateDummyContextLogger().setActiveSpan(requestSpan); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why this would not be something like logxtx.setActiveSpan(requestSpan). What is the dummy context logger for?
Signed-off-by: Gavin Halliday <[email protected]>
429f1f7
to
12afc8f
Compare
Type of change:
Checklist:
Smoketest:
Testing: