-
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-32248 Add tracing to rowservice #19314
base: master
Are you sure you want to change the base?
Conversation
Jira Issue: https://hpccsystems.atlassian.net//browse/HPCC-32248 Jirabot Action Result: |
fs/dafsserver/dafsserver.cpp
Outdated
@@ -162,6 +162,69 @@ static ISecureSocket *createSecureSocket(ISocket *sock, bool disableClientCertVe | |||
} | |||
#endif | |||
|
|||
//------------------------------------------------------------------------------ |
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.
ActiveSpanScope is very similar to ThreadedSpanScope described by Gavin here: https://hpccsystems.atlassian.net/jira/software/c/projects/HPCC/issues/HPCC-32982. I liked the name ActiveSpanScope because I believe the class has utility outside of multithreaded contexts, IE: time slicing. Would it be worthwhile to move this out of dafilesrv into jtrace?
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. These utility changes should be in jlib, ideally as separate PRs/requests. It would be worth merging your other PR, and having a PR that implements an agreed solution to HPCC-32982, and then rebasing this PR on it.
I'm open to discussing what the different classes should be called.
fs/dafilesrv/dafilesrv.cpp
Outdated
@@ -366,13 +366,31 @@ version: 1.0 | |||
detail: 100 | |||
)!!"; | |||
|
|||
IPropertyTree * loadConfigurationWithGlobalDefault(const char * defaultYaml, Owned<IPropertyTree>& globalConfig, const char * * argv, const char * componentTag, const char * envPrefix) |
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 function is similar to work Jake has done in HPCC-32991, might be worthwhile to retarget to master and call the overloaded doLoadConfiguration instead?
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. Should reuse the from HPCC-32991. If this change are wanted in to 9.8, we could consider cherry-picking back the changed in HPCC-32991 to 9.8.
std::string traceParent = fullTraceContext ? fullTraceContext : ""; | ||
traceParent = traceParent.substr(0,traceParent.find_last_of("-")); | ||
|
||
if (!traceParent.empty() && requestTraceParent != traceParent) |
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.
Note: I am checking if the traceParent has changed every time process is called here because the client side may use multiple spans during the lifetime a single CRemoteRequest. See below screenshots for an example.
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.
@jpmcmu looks good. A few minor comments. It would be good to rationalise the helper span scope classes so they cover all the options.
fs/dafsserver/dafsserver.cpp
Outdated
@@ -162,6 +162,69 @@ static ISecureSocket *createSecureSocket(ISocket *sock, bool disableClientCertVe | |||
} | |||
#endif | |||
|
|||
//------------------------------------------------------------------------------ |
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. These utility changes should be in jlib, ideally as separate PRs/requests. It would be worth merging your other PR, and having a PR that implements an agreed solution to HPCC-32982, and then rebasing this PR on it.
I'm open to discussing what the different classes should be called.
fs/dafsserver/dafsserver.cpp
Outdated
const char* fullTraceContext = requestTree->queryProp("_trace/traceparent"); | ||
|
||
// We only want to compare the trace-id & span-id, so remove the last "sampling" group | ||
std::string traceParent = fullTraceContext ? fullTraceContext : ""; |
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: You can use strrchr on the const char * to avoid cloning the string. Alternatively use std::string_view and assign to a new string.
fs/dafsserver/dafsserver.cpp
Outdated
Owned<IProperties> traceHeaders = createProperties(); | ||
traceHeaders->setProp("traceparent", fullTraceContext); | ||
|
||
std::string requestSpanName; |
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 efficiency: use a const char * and avoid a string being cloned.
if (traceParent != nullptr) | ||
{ | ||
Owned<IProperties> traceHeaders = createProperties(); | ||
traceHeaders->setProp("traceparent", traceParent); |
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 also have the sampling suffix removed?
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.
@jpmcmu - please see comments.
fs/dafilesrv/dafilesrv.cpp
Outdated
#endif | ||
|
||
// NB: bare-metal dafilesrv does not have a component specific xml, extracting relevant global configuration instead | ||
Owned<IPropertyTree> config = loadConfigurationWithGlobalDefault(defaultYaml, extractedGlobalConfig, argv, "dafilesrv", "DAFILESRV"); |
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.
instead of new function/adding to global, could you add 'tracing' to the component config instead?
e.g.:
#ifndef _CONTAINERIZED
Owned<IPropertyTree> env = getHPCCEnvironment();
IPropertyTree* tracing = env->getPropTree("Software/tracing");
if (tracing)
config->setPropTree("tracing", tracing);
#endif
(and combine with #else // __CONTAINERIZED block below)
- Added opentelemetry tracing to rowservice Signed-off-by: James McMullan [email protected]
fs/dafsserver/dafsserver.cpp
Outdated
|
||
if (!traceParent.empty() && requestTraceParent != traceParent) | ||
if (strlen(traceParent) != 0 && requestTraceParent != traceParent) |
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: isEmptyString is more efficient (since it only checks the 1st character)
fs/dafsserver/dafsserver.cpp
Outdated
|
||
if (!traceParent.empty() && requestTraceParent != traceParent) | ||
if (strlen(traceParent) != 0 && requestTraceParent != traceParent) |
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 know I made a comment "minor: You can use strrchr on the const char * to avoid cloning the string.".
I think that comment should have more explicit - you should still be creating a temporary string from the result. The modified code is not equivalent to the previous code - it is probably better as it was.
Previously the code set traceParent to the text before the last '-'
now it sets traceParent to the last '-' and the text that follows it.
Also the comparison will implicitly convert it to a std:string anyway - it would be better if that was explicit.
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.
Oh yeah, I am not sure what I was thinking here..
fs/dafsserver/dafsserver.cpp
Outdated
const char* traceParent = requestTree->queryProp("_trace/traceparent"); | ||
if (traceParent != nullptr) | ||
{ | ||
Owned<IProperties> traceHeaders = createProperties(); | ||
traceHeaders->setProp("traceparent", traceParent); | ||
|
||
versionSpan = queryTraceManager().createServerSpan("VersionRequest", traceHeaders); | ||
versionSpan.set(queryTraceManager().createServerSpan("VersionRequest", traceHeaders)); |
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 setown, otherwise I think the object will leak.
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.
@jpmcmu - couple of comments.
fs/dafilesrv/dafilesrv.cpp
Outdated
int main(int argc, const char* argv[]) | ||
{ | ||
InitModuleObjects(); | ||
|
||
EnableSEHtoExceptionMapping(); | ||
#ifndef __64BIT__ | ||
|
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/formatting. extra newline added incidentally (and one removed on line 369, but that looks more deliberate)
fs/dafilesrv/dafilesrv.cpp
Outdated
|
||
const char* componentTag = "dafilesrv"; | ||
Owned<IPropertyTree> componentDefault; | ||
if (defaultYaml) |
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.
why conditional? defaultYaml is always defined
fs/dafilesrv/dafilesrv.cpp
Outdated
{ | ||
Owned<IPropertyTree> defaultConfig = createPTreeFromYAMLString(defaultYaml, 0, ptr_ignoreWhiteSpace, nullptr); | ||
componentDefault.set(defaultConfig->queryPropTree(componentTag)); | ||
if (!componentDefault) |
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 should never be true, the const defaultYaml explicitly defines "dafilesrv" so I don't think there's any point in checking (code currently leads me to think it may be missing)
fs/dafilesrv/dafilesrv.cpp
Outdated
throw makeStringExceptionV(99, "Default configuration does not contain the tag %s", componentTag); | ||
} | ||
else | ||
componentDefault.setown(createPTree(componentTag)); |
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 the above would be better simplified to:
const char* componentTag = "dafilesrv";
Owned<IPropertyTree> defaultConfig = createPTreeFromYAMLString(defaultYaml, 0, ptr_ignoreWhiteSpace, nullptr);
Owned<IPropertyTree> componentDefault = defaultConfig->getPropTree(componentTag);
or I might be tempted to encapsulate this pattern into a another loadConfiguration variety (that calls onto loadConfiguration(IPropertyTree * defaultConfig, IPropertyTree * globalConfig, ...).
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.
@jpmcmu a couple of comments/issues.
@jakesmith @ghalliday Thanks for the reviews, I have implemented those changes |
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.
@jpmcmu - 1 follow up issue.
fs/dafilesrv/dafilesrv.cpp
Outdated
else | ||
componentDefault.setown(createPTree(componentTag)); | ||
Owned<IPropertyTree> defaultConfig = createPTreeFromYAMLString(defaultYaml, 0, ptr_ignoreWhiteSpace, nullptr); | ||
Owned<IPropertyTree> componentDefault(defaultConfig->queryPropTree(componentTag)); |
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.
-ve leak. Needs to be a getPropTree
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.
Ok, right, I need to pay more attention to query/get and set/setown, it is slightly unituitive to me for some reason. So, is the following correct: get* methods will increase the reference count, query* methods will not. Owned constructor does NOT increase reference count, set increases reference count while setown does not.
@jpmcmu It seems this PR went timeout on DFUAccessTest (unit test). Can you try to run that in your local environment?
Usually it takes seconds to finish. |
Some stack trace:
|
Signed-off-by: James McMullan [email protected]
Type of change:
Checklist:
Smoketest:
Testing: