-
Notifications
You must be signed in to change notification settings - Fork 307
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-30403 Provide ECL based API for Tracing #18057
HPCC-30403 Provide ECL based API for Tracing #18057
Conversation
https://track.hpccsystems.com/browse/HPCC-30403 |
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.
@rpastrana looks good. A few very minor comments.
system/jlib/jtrace.cpp
Outdated
@@ -730,6 +730,18 @@ IProperties * getClientHeaders(const ISpan * span) | |||
return headers.getClear(); | |||
} | |||
|
|||
void setSpanAttribute(ISpan * span, const char * name, const char * val) |
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: Not sure why you would call this rather than span->setSpanAttribute()
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.
yeah I ended up going this route because in logging.cpp, ctx->queryContextLogger() returns a const, this approach seemed to bypass the const restriction on the ctxLogger. Do we want to make the contexlogger non-const?
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.
You can still call
activeSpan->setSpanAttribute(name, value);
from within a const function. const generally prevents direct member variables from being modified - it does not prevent objects pointed to by member variables from being modified.
plugins/logging/logging.cpp
Outdated
{ | ||
StringBuffer ret; | ||
Owned<IProperties> httpHeaders = ctx->queryContextLogger().getSpanContext(); | ||
if (httpHeaders) |
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.
Can this ever return null? If not it is clearer without the if() test. (It also confuses static analysers).
plugins/logging/logging.cpp
Outdated
StringBuffer attVal(valueLen, value); | ||
|
||
ctx->queryContextLogger().setSpanAttribute(attName.str(), attVal.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.
minor: newline missing from end of file.
} | ||
virtual void setSpanAttribute(const char *name, const char *value) const override | ||
{ | ||
return ctx->setSpanAttribute(name, value); |
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.
observation: This did not use to be legal (return with a void expression), but it appears it is now.
@ghalliday made these change during pto hoping to get the pr merged in time for latest rc. import lib_logging;
output(lib_logging.Logging.getSpanID());
output(lib_logging.Logging.getTraceID());
>379563f3fcd56bc9
>0c483675c6c887d9fb49885c0f2ba116 import lib_logging;
output(lib_logging.Logging.getTraceSpanHeader());
output(lib_logging.Logging.getTraceStateHeader());
>00-a9f8b7d14d25d9233b829b3481bfaf93-6846688c1431ef1d-01
import lib_logging;
output(lib_logging.Logging.getSpanID());
lib_logging.Logging.setSpanAttribute('some','{"lines":[{"fields":[{"timestamp": "2023-11-06T20:52:19.265Z","hpcc.log.threadid": "232","hpcc.log.timestamp": "2023-11-06 20:52:19.265","kubernetes.container.name": "myeclccserver",}]},{"fields":[{"hpcc.log.jobid": "W20231111-222222","hpcc.log.audience": "OPR","hpcc.log.message": "hthor build community_9.4.9-closedown0Debug[heads/HPCC-30401-JTrace-optional-traceid-support-0-gc85263-dirty]", "kubernetes.pod.name": "hthor-job-w20231106-205213-jdcss",}]}]}'); |
system/jlib/jtrace.cpp
Outdated
@@ -730,6 +730,18 @@ IProperties * getClientHeaders(const ISpan * span) | |||
return headers.getClear(); | |||
} | |||
|
|||
void setSpanAttribute(ISpan * span, const char * name, const char * val) |
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.
You can still call
activeSpan->setSpanAttribute(name, value);
from within a const function. const generally prevents direct member variables from being modified - it does not prevent objects pointed to by member variables from being modified.
plugins/logging/logging.cpp
Outdated
if (httpHeaders) | ||
ret.set(httpHeaders->queryProp("traceID")); | ||
|
||
StringBuffer ret(ctx->queryContextLogger().getSpanContext()->queryProp("traceID")); |
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.
This change isn't correct - it will now leak the properties (we return pointers rather than smart pointers).
plugins/logging/logging.cpp
Outdated
return ret.detach(); | ||
} | ||
|
||
LOGGING_API void LOGGING_CALL setSpanAttribute(ICodeContext *ctx, |
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.
trivial. Is this newline accidental?
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.
Please squash (one trivial comment about a newline)
@rpastrana Also looks like it needs rebasing. |
f15f89b
to
3a558fd
Compare
@ghalliday added a regression suite test case for this, if nothing else, to document the use case. If you're ok with the change I'll squash. |
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.
All looks good, please squash
- Adds several tracing related calls to ECL logging lib - Defines getTraceSpanHeader, getTraceStateHeader - Defines getTraceID, getSpanID, setSpanAttribute - Adds regression tests Signed-off-by: Rodrigo Pastrana <rodrigo.pastrana@lexisnexisrisk.com>
3a558fd
to
ef2ba93
Compare
@ghalliday squashed |
Type of change:
Checklist:
Smoketest:
Testing: