You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2021/03/04 18:39:27 UTC

[GitHub] [skywalking-nodejs] tom-pytel commented on pull request #36: WIP: fixing async and preparing child entry/exit

tom-pytel commented on pull request #36:
URL: https://github.com/apache/skywalking-nodejs/pull/36#issuecomment-790839419


   Ok, this PR is ready. To reiterate, the point of this plugin inheritance scheme is to make sure things like:
   ```js
   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 `http.request()` and `mysqlConnection.query()` exit spans would be merged into a single one, now the db exit span will be a child of the http exit span since it is created in user code which is actually processing the http request.
   
   With something like Axios which stops its span before passing control back to the user:
   ```js
   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 `app.get()` entry span.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org