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 2019/03/14 07:54:11 UTC

[GitHub] [incubator-skywalking] wu-sheng opened a new pull request #2360: Async core APIs in java agent

wu-sheng opened a new pull request #2360: Async core APIs in java agent
URL: https://github.com/apache/incubator-skywalking/pull/2360
 
 
   Hi
   I am thinking about async core APIs for several months, but no action until now. In the discussion with @BFergerson in #2341 for vert.x scenario, I have some practical ideas. 
   
   cc @adriancole You may be interested about this.
   
   ### Advanced APIs
   #### Async Span APIs
   There is a set of advanced APIs in Span, which work specific for async scenario. When tags, logs, attributes(including end time) of the span
   needs to set in another thread, you should use these APIs.
   
   ```java
       /**
        * The span finish at current tracing context, but the current span is still alive, until {@link #asyncFinish}
        * called.
        *
        * This method must be called<br/>
        * 1. In original thread(tracing context).
        * 2. Current span is active span.
        *
        * During alive, tags, logs and attributes of the span could be changed, in any thread.
        *
        * The execution times of {@link #prepareForAsync} and {@link #asyncFinish()} must match.
        *
        * @return the current span
        */
       AbstractSpan prepareForAsync();
   
       /**
        * Notify the span, it could be finished.
        *
        * The execution times of {@link #prepareForAsync} and {@link #asyncFinish()} must match.
        *
        * @return the current span
        */
       AbstractSpan asyncFinish();
   ```
   1. Call `#prepareForAsync` in original context.
   1. Propagate the span to any other thread.
   1. After all set, call `#asyncFinish` in any thread.
   1. Tracing context will be finished and report to backend when all spans's `#prepareForAsync` finished(Judged by count of API execution).
   

----------------------------------------------------------------
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


With regards,
Apache Git Services