Fixing async and preparing child entry/exit#36
Conversation
|
Ok, this PR is ready. To reiterate, the point of this plugin inheritance scheme is to make sure things like: app.get('/mysqlexit', function (req, res, next) {
http.request(`http://somewhere.com/`, (r) => {
mysqlConnection.query('SELECT * FROM `table`', function (error, results, fields) {
if (error)
next(error);
else
res.end(JSON.stringify(results));
});
}).end();
});work correctly. Previously the With something like Axios which stops its span before passing control back to the user: app.get('/mysqlexit', function (req, res, next) {
axios.get(`http://localhost:${portOut}/`).then((r) => {
mysqlConnection.query('SELECT * FROM `table`', function (error, results, fields) {
if (error)
next(error);
else
res.end(JSON.stringify(results));
});
});
});The db exit span will be created after the http span finishes and so will be a sibling of the http span and a child of the |
|
Hold off on merging a bit, still working out some details. |
|
I restored this because apart from covering up some of the errors in async before this flag was doing one other important thing that didn't have to do with those errors. |
|
Ok, NOW it looks good, any other errors that might pop up can be fixed in other PRs. |
835adb1 to
5b0cebe
Compare
8f9cebb to
0990d85
Compare
|
Tests under Node 10 failed, although I've rerun it, still failed, can you recheck? |
Its a legitimate problem, not just config, something that's different between N10 and 12/14 is causing the spans to not stop in http, looking at it. |
|
Ok, well this is in a good-ish place now, all my tests are running correctly. I will probably do more work on this but maybe this would be a good place to checkpoint and merge as this PR is getting a little big and already has several different feature changes? |
The changes here are the result of preparing for allowing Exit/Exit and Entry/Entry parent child relationships during which I discovered and am in the process of fixing and improving some async functionality.
The source of the problem which necessitated #27 was discovered and fixed. The
httpandaxiosmodules did not properlyasync()on returning a connection. Also,async()itself now duplicates the spans list for the current task in order that async tasks created before theasync()don't have their copies of the list corrupted by subsequent operations in the current task. This all removes the necessity for a separateinvalidflag, which flag itself was only a partial patch for the main problem which would still manifest in other ways.The functionality of the
httpmodule is also being expanded so that errors on'data'events are properly attributed to the span.Also,
span.resync()no longer needed beforespan.stop(), a span can be errored or stopped while async.Not for merge just yet.