-
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?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -366,13 +366,13 @@ version: 1.0 | |
detail: 100 | ||
)!!"; | ||
|
||
|
||
int main(int argc, const char* argv[]) | ||
{ | ||
InitModuleObjects(); | ||
|
||
EnableSEHtoExceptionMapping(); | ||
#ifndef __64BIT__ | ||
|
||
// Restrict stack sizes on 32-bit systems | ||
Thread::setDefaultStackSize(0x10000); // 64K stack (also set in windows DSP) | ||
#endif | ||
|
@@ -386,7 +386,29 @@ int main(int argc, const char* argv[]) | |
StringBuffer componentName; | ||
|
||
// NB: bare-metal dafilesrv does not have a component specific xml | ||
Owned<IPropertyTree> config = loadConfiguration(defaultYaml, argv, "dafilesrv", "DAFILESRV", nullptr, nullptr); | ||
Owned<IPropertyTree> extractedGlobalConfig = createPTree("dafilesrv"); | ||
|
||
#ifndef _CONTAINERIZED | ||
Owned<IPropertyTree> env = getHPCCEnvironment(); | ||
IPropertyTree* globalTracing = env->getPropTree("Software/tracing"); | ||
if (globalTracing != nullptr) | ||
extractedGlobalConfig->addPropTree("tracing", globalTracing); | ||
jakesmith marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#endif | ||
|
||
const char* componentTag = "dafilesrv"; | ||
Owned<IPropertyTree> componentDefault; | ||
if (defaultYaml) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why conditional? defaultYaml is always defined |
||
{ | ||
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 commentThe 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) |
||
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 commentThe reason will be displayed to describe this comment to others. Learn more. I think the above would be better simplified to:
or I might be tempted to encapsulate this pattern into a another loadConfiguration variety (that calls onto loadConfiguration(IPropertyTree * defaultConfig, IPropertyTree * globalConfig, ...). |
||
|
||
// NB: bare-metal dafilesrv does not have a component specific xml, extracting relevant global configuration instead | ||
Owned<IPropertyTree> config = loadConfiguration(componentDefault, extractedGlobalConfig, argv, componentTag, "DAFILESRV", nullptr, nullptr); | ||
|
||
Owned<IPropertyTree> keyPairInfo; // NB: not used in containerized mode | ||
// Get SSL Settings | ||
|
@@ -513,7 +535,6 @@ int main(int argc, const char* argv[]) | |
|
||
IPropertyTree *dafileSrvInstance = nullptr; | ||
#ifndef _CONTAINERIZED | ||
Owned<IPropertyTree> env = getHPCCEnvironment(); | ||
Owned<IPropertyTree> _dafileSrvInstance; | ||
if (env) | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -839,6 +839,9 @@ class CRemoteRequest : public CSimpleInterfaceOf<IInterface> | |
MemoryBuffer expandMb; | ||
Owned<IXmlWriterExt> responseWriter; // for xml or json response | ||
|
||
OwnedSpanLifetime requestSpan; | ||
std::string requestTraceParent; | ||
|
||
bool handleFull(MemoryBuffer &inMb, size32_t inPos, MemoryBuffer &compressMb, ICompressor *compressor, size32_t replyLimit, size32_t &totalSz) | ||
{ | ||
size32_t sz = inMb.length()-inPos; | ||
|
@@ -1092,13 +1095,51 @@ class CRemoteRequest : public CSimpleInterfaceOf<IInterface> | |
responseWriter->outputUInt(cursorHandle, sizeof(cursorHandle), "handle"); | ||
} | ||
} | ||
|
||
~CRemoteRequest() | ||
{ | ||
if (requestSpan != nullptr) | ||
{ | ||
requestSpan->setSpanStatusSuccess(true); | ||
} | ||
} | ||
|
||
OutputFormat queryFormat() const { return format; } | ||
unsigned __int64 queryReplyLimit() const { return replyLimit; } | ||
IRemoteActivity *queryActivity() const { return activity; } | ||
ICompressor *queryCompressor() const { return compressor; } | ||
|
||
void process(IPropertyTree *requestTree, MemoryBuffer &restMb, MemoryBuffer &responseMb, CClientStats &stats) | ||
{ | ||
const char* fullTraceContext = requestTree->queryProp("_trace/traceparent"); | ||
|
||
// We only want to compare the trace-id & span-id, so remove the last "sampling" group | ||
const char* traceParent = fullTraceContext ? fullTraceContext : ""; | ||
traceParent = strrchr(traceParent, '-'); | ||
|
||
if (strlen(traceParent) != 0 && requestTraceParent != traceParent) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. trivial: isEmptyString is more efficient (since it only checks the 1st character) There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 '-' There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh yeah, I am not sure what I was thinking here.. |
||
{ | ||
// Check to see if we have an existing span that needs to be marked successful before close | ||
if (requestSpan != nullptr) | ||
ghalliday marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
requestSpan->setSpanStatusSuccess(true); | ||
} | ||
|
||
Owned<IProperties> traceHeaders = createProperties(); | ||
traceHeaders->setProp("traceparent", fullTraceContext); | ||
|
||
const char* requestSpanName = nullptr; | ||
if (activity->queryIsReadActivity()) | ||
requestSpanName = "ReadRequest"; | ||
else | ||
requestSpanName = "WriteRequest"; | ||
|
||
requestSpan.set(queryTraceManager().createServerSpan(requestSpanName, traceHeaders)); | ||
requestTraceParent = traceParent; | ||
} | ||
|
||
ActiveSpanScope activeSpan(requestSpan.query()); | ||
|
||
if (requestTree->hasProp("replyLimit")) | ||
replyLimit = requestTree->getPropInt64("replyLimit", defaultDaFSReplyLimitKB) * 1024; | ||
|
||
|
@@ -3027,12 +3068,12 @@ class CRemoteFileServer : implements IRemoteFileServer, public CInterface | |
else | ||
{ | ||
if (gc) | ||
THROWJSOCKEXCEPTION(JSOCKERR_graceful_close); | ||
THROWJSOCKEXCEPTION(JSOCKERR_graceful_close); | ||
break; // wait for rest via subsequent notifySelected's | ||
} | ||
} | ||
else if (gc) | ||
THROWJSOCKEXCEPTION(JSOCKERR_graceful_close); | ||
THROWJSOCKEXCEPTION(JSOCKERR_graceful_close); | ||
// to be here, implies handled full message, loop around to see if more on the wire. | ||
// will break out if nothing/partial. | ||
} | ||
|
@@ -4818,7 +4859,7 @@ class CRemoteFileServer : implements IRemoteFileServer, public CInterface | |
* } | ||
* } | ||
* } | ||
* | ||
* | ||
* fetch continuation: | ||
* { | ||
* "format" : "binary", | ||
|
@@ -4960,8 +5001,23 @@ class CRemoteFileServer : implements IRemoteFileServer, public CInterface | |
} | ||
case StreamCmd::CLOSE: | ||
{ | ||
OwnedActiveSpanScope closeSpan; | ||
const char* traceParent = requestTree->queryProp("_trace/traceparent"); | ||
if (traceParent != nullptr) | ||
{ | ||
Owned<IProperties> traceHeaders = createProperties(); | ||
traceHeaders->setProp("traceparent", traceParent); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this also have the sampling suffix removed? |
||
|
||
closeSpan.set(queryTraceManager().createServerSpan("CloseRequest", traceHeaders)); | ||
} | ||
|
||
if (0 == cursorHandle) | ||
throw createDafsException(DAFSERR_cmdstream_protocol_failure, "cursor handle not supplied to 'close' command"); | ||
{ | ||
IDAFS_Exception* exception = createDafsException(DAFSERR_cmdstream_protocol_failure, "cursor handle not supplied to 'close' command"); | ||
closeSpan->recordException(exception); | ||
throw exception; | ||
} | ||
|
||
IFileIO *dummy; | ||
checkFileIOHandle(cursorHandle, dummy, true); | ||
break; | ||
|
@@ -4990,6 +5046,16 @@ class CRemoteFileServer : implements IRemoteFileServer, public CInterface | |
{ | ||
case StreamCmd::VERSION: | ||
{ | ||
OwnedActiveSpanScope versionSpan; | ||
const char* traceParent = requestTree->queryProp("_trace/traceparent"); | ||
if (traceParent != nullptr) | ||
{ | ||
Owned<IProperties> traceHeaders = createProperties(); | ||
traceHeaders->setProp("traceparent", traceParent); | ||
|
||
versionSpan.set(queryTraceManager().createServerSpan("VersionRequest", traceHeaders)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be setown, otherwise I think the object will leak. |
||
} | ||
|
||
if (outFmt_Binary == outputFormat) | ||
reply.append(DAFILESRV_VERSIONSTRING); | ||
else | ||
|
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)