-
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-33145: Optimize ESP server span creation #19373
base: master
Are you sure you want to change the base?
HPCC-33145: Optimize ESP server span creation #19373
Conversation
Jira Issue: https://hpccsystems.atlassian.net//browse/HPCC-33145 Jirabot Action Result: |
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.
A couple of minor comments
@@ -2089,6 +2089,7 @@ int CHttpRequest::processHeaders(IMultiException *me) | |||
char oneline[MAX_HTTP_HEADER_LEN + 2]; | |||
|
|||
int lenread = m_bufferedsocket->readline(oneline, MAX_HTTP_HEADER_LEN + 1, me); | |||
m_receivedAt.now(); // use receipt of a first loe as the start time for a server 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.
typo: line?
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.
Yep
wantTracing = !(methodName.isEmpty() || | ||
strieq(methodName, "files") || | ||
strieq(methodName, "xslt") || | ||
strieq(methodName, "frame") || |
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 "body" deliberately missing?
How do we ensure this stays in sync with the code later in the function? Should at least be a comment.
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.
Good catch. Not only is "body" not intentionally missing, but this doesn't account for the underscore that could be added to each name.
I'm thinking about defining a mapping of method name to enumerated value. This tracing check will only need to check the map for a matching entry. The subsequent handling code will be refactored to switch on the enumerated value. Only one set of string comparisons will be necessary, for a small performance boost.
e5d40b8
to
80b6799
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.
@timothyklemm I like the change. There is one issue.
The other two comments I would not have added if there was no other comments. They are there for discussion/to help the clarity of the code.
{ | ||
// The presence of a method name in the get request map is sufficient to | ||
// suppress trace output. The enumerated value will be used later. | ||
untracedRequestIt = getRequests.find(methodName); |
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 will not be executed if !isTracingEnabled, which means the switch statement later on will not work. This needs to be unconditional - and because it is now using a map it should be ok to be unconditional.
return onGetFile(m_request.get(), m_response.get(), pathEx.str()); | ||
} | ||
else if (!stricmp(methodName.str(), "xslt")) | ||
if (untracedRequestIt != getRequests.end()) |
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.
picky style/encapsulation: Rather than comparing against the map null entry I would add a None entry to UntracedGetMethod, and have a local variable of that type, which was filled in. Why? Because the later test is reasonably separated from where the variable is set up, and a test against getRequests.end() isn't immediately obvious that what it is checking.
@@ -297,6 +299,50 @@ void CEspHttpServer::traceRequest(IEspContext* ctx, const char* normalizeMethod) | |||
span->setSpanAttribute("url.full", full); | |||
} | |||
|
|||
// Enumeration of "esp" service methods that are never traced. Add new values as additional | |||
// requests become relevant. | |||
enum class UntracedGetMethod |
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.
picky naming: What characteristic do these methods have that means they are not traced? Is it they are simple file requests? Something else? That adjective should be used to describe the method, rather than "Untraced" - because they are untraced for that reason, not the other way around.
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.
Looks a close. A couple of minor comment.
{"soapreq", UntracedGetMethod::SoapReq}, | ||
using EspGetMethodMap = std::map<const char*, EspGetMethod, EspGetMethodNameComparator>; | ||
// Association of method names to specific "esp" service requests. This mapping allows | ||
// pprocessRequest to decide if the request should be traced before processing the request, without |
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.
typo: pprocessRequest
@@ -402,29 +411,30 @@ int CEspHttpServer::processRequest() | |||
// so maximize the amount of request processing that can be traced. Specifically, user | |||
// authentication and authorization may generate trace output. | |||
bool wantTracing = true; |
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: Should be initialised to queryTraceManager().isTracingEnabled()
otherwise it will be true if it is an unhandled get method even if that function returns false.
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.
Looks good afaics. Thanks, please squash.
- Create the server span as soon as the request information needed to decide if a span should be created is available. - Change the server span's start time to reflect the time when the first line of the incoming request is read. Signed-off-by: Tim Klemm <[email protected]>
2d79881
to
be76f8c
Compare
@ghalliday it's squashed. |
@ghalliday there's a build break on master unrelated to this change. I just ran into it after updating my local build. |
if a span should be created is available.
of the incoming request is read.
Signed-off-by: Tim Klemm [email protected]
Type of change:
Checklist:
Smoketest:
Testing: