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/26 02:39:06 UTC

[GitHub] [skywalking] yaojingguo opened a new issue #6625: make apm-toolkit-trace support a a programmatic interface

yaojingguo opened a new issue #6625:
URL: https://github.com/apache/skywalking/issues/6625


   Please answer these questions before submitting your issue.
   
   - Why do you submit this issue?
   - [ ] Question or discussion
   - [ ] Bug
   - [x] Requirement
   - [ ] Feature or performance improvement
   ___
   # Requirement
   I want to pragmatically instrument Java code. There are possible two ways to do it. 
   
   ## gRPC API
   This approach uses gPRC API to report segments to the OAP server. This approach is similar to [go2sky]. But there is a problem with it. The spans create by gPRC API can be related to the spans created by the Java agent. Consider the following example:
   
   ```Java
   @GetMapping("/greeting")
   public String greeting() {
      foo();
      return "hello";
   }
   private void foo() {
      // Create a span B and report it to OAP server
   }
   ```
   Java agent creates an entry span A for the greeting method. There will be no ChildOf relation created between span A and span B  since Java agent and gRPC API do the instrument separately. In one word, this approach does not integrate well with the automatic instrument by Java agent.
   
   ## apm-toolkit-trace
   [apm-toolkit-trace] uses Java annotations to create tracing data such as span, log, and tag. For example, we can use `@Trace` annotation to create a span for bar method:
   
   ```Java
   @Trace
   public void bar() {
   }
   ```
   The problem is that I can't decide whether to create a span for bar at runtime. For example, I want to disable span creation for bar method by default. After I turn on some flag, I want to create spans for the invocation of the method bar.
   
   So the existing approaches do not solve my problem. I want to implement the following feature by extending apm-toolkit-trace module. My idea is to add the following APIs to  apm-toolkit-trace module (This API list is incomplete. If this design makes sense, I will make a complete API list for review):
   
   - createLoalSpan
   - createEntrySpan
   - createExitSpan
   - stopSpan
   
   The above methods essentially do the same thing as the aforementioned annotations. For example, createLoalSpan and stopSpan can do the same thing as `@Trace` annotation. In summary, my idea is to provide a programmatic interface for the functionalities which have existed in apm-toolkit-trace module.
   
   [go2sky]: https://github.com/SkyAPM/go2sky
   [apm-toolkit-trace]: https://github.com/apache/skywalking/blob/master/docs/en/setup/service-agent/java-agent/Application-toolkit-trace.md
   


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



[GitHub] [skywalking] wu-sheng closed issue #6625: make apm-toolkit-trace support a a programmatic interface

Posted by GitBox <gi...@apache.org>.
wu-sheng closed issue #6625:
URL: https://github.com/apache/skywalking/issues/6625


   


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



[GitHub] [skywalking] wu-sheng commented on issue #6625: make apm-toolkit-trace support a a programmatic interface

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on issue #6625:
URL: https://github.com/apache/skywalking/issues/6625#issuecomment-807896879


   I am not sure following your first case, a span should not be reported to the backend without a segment wrapper.


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



[GitHub] [skywalking] wu-sheng commented on issue #6625: make apm-toolkit-trace support a a programmatic interface

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on issue #6625:
URL: https://github.com/apache/skywalking/issues/6625#issuecomment-808072400


   I and @yaojingguo did a face to face discussion about this. There are 2 potential direction
   1. Use the OpenTracing bridge APIs to do this. But also, should aware of, OT is not practical. And AFAIK, SkyWalking will stay on OT-Java-0.30 only, or delete the support later(no specific plan yet)
   2. Enhance the toolkit APIs with some static methods, such as `TraceContext#createXXXspan()`. But we wouldn't recommend to expose the reference of span to the end user, due to the context propagation is based on agent core, rather than UI.


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



[GitHub] [skywalking] yaojingguo commented on issue #6625: make apm-toolkit-trace support a a programmatic interface

Posted by GitBox <gi...@apache.org>.
yaojingguo commented on issue #6625:
URL: https://github.com/apache/skywalking/issues/6625#issuecomment-807908329


   Yes, you are right. I have updated my comment. PTAL


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



[GitHub] [skywalking] yaojingguo commented on issue #6625: make apm-toolkit-trace support a a programmatic interface

Posted by GitBox <gi...@apache.org>.
yaojingguo commented on issue #6625:
URL: https://github.com/apache/skywalking/issues/6625#issuecomment-824092631


   I will try to make a PR this week.


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



[GitHub] [skywalking] wu-sheng commented on issue #6625: make apm-toolkit-trace support a a programmatic interface

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on issue #6625:
URL: https://github.com/apache/skywalking/issues/6625#issuecomment-822865047


   @yaojingguo Any update about this?


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