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 2022/11/22 06:07:40 UTC

[GitHub] [skywalking] wu-sheng opened a new issue, #9999: [Feature] [Java] Expose complete Tracing toolkit

wu-sheng opened a new issue, #9999:
URL: https://github.com/apache/skywalking/issues/9999

   ### Search before asking
   
   - [X] I had searched in the [issues](https://github.com/apache/skywalking/issues?q=is%3Aissue) and found no similar feature requirement.
   
   
   ### Description
   
   SkyWalking Java is the most powerful and implementation-completed agent in the whole ecosystem for sure.
   It started with auto-instrumentation agent because it is good in Java, but people prefer this way much more than manually.
   
   With all these years of development, it has a complete tracing and metrics plugin system with a stable agent kernel.
   
   Meanwhile, we have received many users asking about that, they want to do manual instrumentation in some cases of auto-instrumentation can't cover. So, we have toolkit API libs.
   
   - Part of tracing APIs, https://skywalking.apache.org/docs/skywalking-java/next/en/setup/service-agent/java-agent/application-toolkit-trace/
   - Meter APIs, https://skywalking.apache.org/docs/skywalking-java/next/en/setup/service-agent/java-agent/application-toolkit-meter/
   
   ### Use case
   
   We was relying on OpenTracing APIs to expose most tracing APIs to help end users, but considering it has been archived and merged into OpenTelemetry. I think it is time for us to build our own Tracing APIs.
   
   To keep compatibility, all APIs in [Tracing toolkit](https://skywalking.apache.org/docs/skywalking-java/next/en/setup/service-agent/java-agent/application-toolkit-trace/) should be kept and we are going to add new.
   
   The proposal would be very easy, we are going to expose most APIs from `ContextManager` in the agent kernel, including
   - Span creating
   - Inject/extract for RPC tracing
   - Capture/continue for continue tracing context in the x-thread tracing
   - Tag and log for the current span
   - Async prepare/finish for span crossing threads
   
   Most APIs should be an empty shell, and use toolkit activation to link those APIs to kernel APIs directly.
   
   ### Related issues
   
   _No response_
   
   ### Are you willing to submit a PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
   


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org.apache.org

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


[GitHub] [skywalking] wu-sheng commented on issue #9999: [Feature] [Java] Expose complete Tracing APIs in the tracing toolkit

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

   Yes, you are.


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking] mufiye commented on issue #9999: [Feature] [Java] Expose complete Tracing APIs in the tracing toolkit

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

   > One more suggestion, we could consider SpanRef as a new API, thay could be more flexible.
   
   Is this SpanRef refering to `AsyncSpanRef`? Sorry, I can't understand the meaning of "the new API".


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking] wu-sheng commented on issue #9999: [Feature] [Java] Expose complete Tracing APIs in the tracing toolkit

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

   One more suggestion, we could consider SpanRef as a new API, thay could be more flexible.


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking] wu-sheng commented on issue #9999: [Feature] [Java] Expose complete Tracing APIs in the tracing toolkit

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

   > > One more suggestion, we could consider SpanRef as a new API, thay could be more flexible.
   > 
   > 
   > 
   > Is this SpanRef refering to `AsyncSpanRef`? Sorry, I can't understand the meaning of "a new API".
   
   Oh, sorry. I didn't mean that.
   It is alternative to the current ActiveSpan. The SpanRef is a point of new created or active span. User could directly use it, rather than calling ActiveSpan every time.


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking] mufiye commented on issue #9999: [Feature] [Java] Expose complete Tracing APIs in the tracing toolkit

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

   Good afternoon, @wu-sheng . Now I'm writing the code of the outer API first, but I encounter some problems:
   * First is the `SpanRef` how to point to the real span, the method I think is embedding a real span attribute `span` into the `SpanRef` object. WDYT?
   * Then we should import the `AsyncSpan` class into the `SpanRef` class. Is it allowed to import internal packages like this? Also for the `ContextSnapshot` imported into the `Tracer` class for `capture` and `continued` methods.
   * And for the `SpanRef` idea, I want to merge `AsyncSpanRef` and `SpanRef` proposed originally into the `SpanRef` showing as below codes. WDYT?
   ''' 
   import org.apache.skywalking.apm.agent.core.context.ContextSnapshot;
   
   public class SpanRef {
   
       private AsyncSpan span;
   
       public SpanRef(AsyncSpan span) {
           this.span = span;
       }
       
       public SpanRef prepareForAsync() {
           return null;
       }
   
       public SpanRef asyncFinish() {
           return null;
       }
   
       public void log(Throwable t) {
       }
       
       public void log(Map<String, ?> event) {
       }
   }
   '''


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking] mufiye commented on issue #9999: [Feature] [Java] Expose complete Tracing APIs in the tracing toolkit

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

   > There is much black magic in the agent kernel. I think you have known the things.
   
   To write the toolkit and unit test, I have read a lot agent kernel code. This kernel use lots of awesome things. Did you mean such things? Or this phrase has a special meaning in apm?


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking] mufiye commented on issue #9999: [Feature] [Java] Expose complete Tracing APIs in the tracing toolkit

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

   ```java
   import org.apache.skywalking.apm.agent.core.context.ContextSnapshot;
   
   // the message is used to encapsulate the ContextCarrier
   public class Tracer {
       public static SpanRef createEntrySpan(String operationName, Object message) {
           return null;
       }
   
       public static SpanRef createLocalSpan(String operationName) {
           return null;
       }
   
       public static SpanRef createExitSpan(String operationName, String remotePeer) {
           return null;
       }
   
       public static SpanRef createExitSpan(String operationName, String remotePeer, Object message) {
           return null;
       }
   
       public static void stopSpan() {
       }
   
       public static void inject(Object message) {
       }
   
       public static void extract(Object message) {
       }
   
       public static ContextSnapshot capture() {
           return null;
       }
   
       public static void continued(ContextSnapshot snapshot) {
       }
   }
   ```


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking] wu-sheng commented on issue #9999: [Feature] [Java] Expose complete Tracing toolkit

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

   This is a TODO task, if anyone has interest to do this, please comment here, and we need to discuss the whole APIs lib before start implementing.


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking] wu-sheng commented on issue #9999: [Feature] [Java] Expose complete Tracing APIs in the tracing toolkit

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

   > To implement the Async prepare/finish for span crossing threads, we should build a class corresponding to the span. Adding the prepareForAsync() and asyncFinish() to ActiveSpan is also feasible. But I want to separate it from the ActiveSpan class. WDYT?
   
   Let's name it AsyncSpanRef.


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking] mufiye commented on issue #9999: [Feature] [Java] Expose complete Tracing APIs in the tracing toolkit

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

   > ```
   >     public static ContextSnapshot capture() {
   >         return null;
   >     }
   > 
   >     public static void continued(ContextSnapshot snapshot) {
   >     }
   > ```
   > 
   > Don't return null, you could create a dummy implementation to avoid NPE.
   
   Ok, I will use the dummy implementation to avoid NPE for all such return statements. Thanks for your suggestions.


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking] wu-sheng commented on issue #9999: [Feature] [Java] Expose complete Tracing APIs in the tracing toolkit

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

   If you have an interceptor for `SpanRef`, then yes. 


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking] mufiye commented on issue #9999: [Feature] [Java] Expose complete Tracing APIs in the tracing toolkit

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

   > 
   Maybe in this format? I originally wrote as below.
   However, no matter what format these part codes are, the interception of `SpanRef` can take effect in the `aftermethod` of `TracerCreateLocalSpanInterceptor`? I am confused about it. And after reading source code about transform, I think it can not take effect?
   ```java
   public class TracerCreateLocalSpanInterceptor implements StaticMethodsAroundInterceptor {
       ...
       @Override
       public Object afterMethod(Class clazz, Method method, Object[] allArguments, Class<?>[] parameterTypes, Object ret) {
           AbstractSpan localSpan = ContextManager.createLocalSpan(String.valueOf(allArguments[0]));
           EnhancedInstance spanRef = (EnhancedInstance)new SpanRef();
           spanRef.setSkyWalkingDynamicField(localSpan);
           return spanRef;
       }
   }
   ```


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking] wu-sheng commented on issue #9999: [Feature] [Java] Expose complete Tracing APIs in the tracing toolkit

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

   You are enhancing `org.apache.skywalking.apm.toolkit.trace.ContextCarrier`, but try to cast `org.apache.skywalking.apm.toolkit.trace.ContextCarrierRef`. I think this is a code bug?


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking] mufiye commented on issue #9999: [Feature] [Java] Expose complete Tracing APIs in the tracing toolkit

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

   Hello, @wu-sheng . I have completed the toolkit and pass the unit test part. Now I am writing the plugin automatic tests. But I encounter one problem and I have no idea to solve it.
   To implement the createExitSpan with inject function, I use the Interceptor below. But when I start the automatic tests and run the `Tracer.createExitSpan`, it will report the Exception in the skywalking-api.log. I think the `ContextCarrier` implement the `EnhancedInstance` interface after intercepting, but why it can not cast?
   ```java
   public class Tracer {
       public static SpanRef createExitSpan(String operationName, ContextCarrierRef carrierRef, String remotePeer) {
           return new SpanRef();
       }
   }
   ```
   ```java
   public class TracerCreateExitSpanWithContextInterceptor implements StaticMethodsAroundInterceptor {
   
       @Override
       public void beforeMethod(Class clazz, Method method, Object[] allArguments, Class<?>[] parameterTypes, MethodInterceptResult result) {
   
       }
   
       @Override
       public Object afterMethod(Class clazz, Method method, Object[] allArguments, Class<?>[] parameterTypes, Object ret) {
           ContextCarrier contextCarrier = new ContextCarrier();
           AbstractSpan exitSpan = ContextManager.createExitSpan(String.valueOf(allArguments[0]), contextCarrier, String.valueOf(allArguments[2]));
           ((EnhancedInstance) allArguments[1]).setSkyWalkingDynamicField(contextCarrier);
           ((EnhancedInstance) ret).setSkyWalkingDynamicField(exitSpan);
           return ret;
       }
      
       ...
   }
   ```
   ```java
   public class ContextCarrierRef {
       public CarrierItemRef items() {
           return new CarrierItemRef();
       }
   }
   ```
   ```java
   public class ContextCarrierRefActivation extends ClassInstanceMethodsEnhancePluginDefine {
       private static final String ENHANCE_CLASS = "org.apache.skywalking.apm.toolkit.trace.ContextCarrier";
       private static final String ITEMS_METHOD_NAME = "items";
       private static final String ITEMS_INTERCEPTOR_CLASS = "org.apache.skywalking.apm.toolkit.activation.trace.ContextCarrierRefItemsInterceptor";
   
       @Override
       protected ClassMatch enhanceClass() {
           return NameMatch.byName(ENHANCE_CLASS);
       }
   
       @Override
       public ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
           return new ConstructorInterceptPoint[0];
       }
   
       @Override
       public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
           return new InstanceMethodsInterceptPoint[] {
               new InstanceMethodsInterceptPoint() {
                   @Override
                   public ElementMatcher<MethodDescription> getMethodsMatcher() {
                       return named(ITEMS_METHOD_NAME);
                   }
   
                   @Override
                   public String getMethodsInterceptor() {
                       return ITEMS_INTERCEPTOR_CLASS;
                   }
   
                   @Override
                   public boolean isOverrideArgs() {
                       return false;
                   }
               }
           };
       }
   }
   ```
   ```
   ERROR 2023-01-19 02:57:58.212 http-nio-8080-exec-2 StaticMethodsInter : class[class org.apache.skywalking.apm.toolkit.trace.Tracer] after static method[createExitSpan] intercept failure:org.apache.skywalking.apm.toolkit.trace.ContextCarrierRef cannot be cast to org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance 
   java.lang.ClassCastException: org.apache.skywalking.apm.toolkit.trace.ContextCarrierRef cannot be cast to org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance
   	at org.apache.skywalking.apm.toolkit.activation.trace.TracerCreateExitSpanWithContextInterceptor.afterMethod(TracerCreateExitSpanWithContextInterceptor.java:41)
   	at org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.StaticMethodsInter.intercept(StaticMethodsInter.java:94)
   	at org.apache.skywalking.apm.toolkit.trace.Tracer.createExitSpan(Tracer.java)
   	at test.apache.skywalking.apm.testcase.toolkit.controller.TestService.endServiceWithCarrier(TestService.java:81)
   	at test.apache.skywalking.apm.testcase.toolkit.controller.CaseController.testcase$original$mL17GHKM(CaseController.java:76)
   ...
   ```


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking] wu-sheng commented on issue #9999: [Feature] [Java] Expose complete Tracing APIs in the tracing toolkit

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

   If you want to expose the deep log API, to expose map structure, it is fine. But don't make it too complex.
   Tag APIs should be enough for now.


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking] wu-sheng commented on issue #9999: [Feature] [Java] Expose complete Tracing APIs in the tracing toolkit

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

   Take your time. I think the Java agent would only release after the Chinese new year. You should have enough time.
   Be patient, if this is your time playing SkyWalking's upstream, there are some barriers due to our testing CI.
   If you have any questions, let us know.


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking] wu-sheng commented on issue #9999: [Feature] [Java] Expose complete Tracing APIs in the tracing toolkit

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

   ContextCarrier is a shell, you could consider a thing similar or lambda as parameters. Each RPC/MQ has different parameters, so we need a general way to provide abstract APIs.


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking] mufiye commented on issue #9999: [Feature] [Java] Expose complete Tracing APIs in the tracing toolkit

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

   > I am not following the demo codes actually.
   > 
   > 1. About `public SpanRef(Object object)`, what is the `Object` about?
   > 2. Why `TracerCreateLocalSpanInterceptor` has an `AbstractSpan localSpan;` field? Interceptor should not have any field in most cases.
   
   1. For the first point, the `SpanRef` should take the `AbstractSpan` instance as parameter to assign the dynamic filed with `EnhancedInstance#setSkyWalkingDynamicField` in the construction period.
   2. For the second point, I will correct this by merging the codes in `beforeMethod` into the `afterMethod`. You just ignore the `AbstractSpan localSpan` statement.


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking] wu-sheng commented on issue #9999: [Feature] [Java] Expose complete Tracing APIs in the tracing toolkit

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

   > For the first point, the SpanRef should take the AbstractSpan instance as parameter to assign the dynamic filed with EnhancedInstance#setSkyWalkingDynamicField in the construction period.
   
   I think I know the gap now. You are creating the SpanRef in the interceptor, but actually, you could use `tracer.create` to build the SpanRef, and only `setSkyWalkingDynamicField` in the after method. Then you don't need this weird `object` as parameter.


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking] mufiye commented on issue #9999: [Feature] [Java] Expose complete Tracing APIs in the tracing toolkit

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

   Hello @wu-sheng, I'm interested in this issue and have read the documents and codes about this issue in detail. I have some rough ideas about the design of API and also some problems:
   1. For the span creating, I would like to use the annotation @LocalSpan, @EntrySpan, @ExitSpan like the @trace in apm-toolkit-trace.
   2. For the inject/extract for RPC tracing, I think they respectively correspond to the @ExitSpan and @EntrySpan, but I have no idea about how to pass the contextCarrier.
   3. For the capture/continued function, I think the api in apm-toolkit-trace is wonderful, maybe we can just use the similar way? Or I think the exposure of capture() and continued() which can be used before and after entering the thread may be another way.
   4. For tag and log for the current span, I would like to use the same functions' design log() and tag() in abstractTracingSpan, of course, the activation is as the link.
   5. For Async prepare/finish, I think the functions' design of prepareForAsync() and asyncFinish() in AbstractTracingSpan can be used, but I have no idea about how to guarantee that these two operations correspond to one span?
   I hope this will be my good first issue in apache-skywalking community. And it would be nice if you could offer some suggestions on my ideas.


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking] wu-sheng commented on issue #9999: [Feature] [Java] Expose complete Tracing APIs in the tracing toolkit

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

   > Could you please assign this task to me? And should I make a more detailed API design proposal first?
   
   Done. You don't have to wait for the assignment. SkyWalking community is more about volunteers driven. So, just take an action, and maintainers would like to provide helps as much as possible.


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking] wu-sheng commented on issue #9999: [Feature] [Java] Expose complete Tracing APIs in the tracing toolkit

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

   I mean, as you have enhanced one class successfully, there would not be special cases that could be enhanced or not. :)
   I think that was driving you to ask.
   My point is, don't treat this as a very complex thing, it is just simple enhancing and intercepting.


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking] wu-sheng commented on issue #9999: [Feature] [Java] Expose complete Tracing APIs in the tracing toolkit

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

   There is much black magic in the agent kernel. I think you have known the things.


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking] mufiye commented on issue #9999: [Feature] [Java] Expose complete Tracing APIs in the tracing toolkit

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

   > ```
   >     public static void inject(Object message) {
   >     }
   > 
   >     public static void extract(Object message) {
   >     }
   > ```
   > 
   > Don't use `Object` as parameter, it is too general.
   > 
   
   For this part implementation, I want use the `message` parameters corresponding to the message which will take the contextCarrier data such as `HttpHeaders` in asynchttpclient, `Metadata` in grpc. I will think about better parameter setting when I implement this part.


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking] wu-sheng commented on issue #9999: [Feature] [Java] Expose complete Tracing APIs in the tracing toolkit

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

   > the interception of SpanRef can take effect in the aftermethod of TracerCreateLocalSpanInterceptor?
   I am confused about it. And after reading source code about transform, I think it can not take effect?
   
   What are `can` and `can't` about? Which part?


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking] mufiye commented on issue #9999: [Feature] [Java] Expose complete Tracing APIs in the tracing toolkit

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

   > 
   
   Oh, sorry, it is `StaticMethodsAroundInterceptor` in code below actually but I write `InstanceMethodsAroundInterceptor` wrongly in description.
   The problem is that, I use the `SpanRef` with `EnhancedInstance#setSkyWalkingDynamicField` to encapsulate the created span such as entrySpan, localSpan, exitSpan. So to return the `SpanRef` instance, I should new an instance in the `createLocalSpan` method which is intercepted by the `TracerCreateLocalSpanInterceptor`. So I want to know if this construction process of `SpanRef` intercepeted by the `SpanRefConstructInterceptor` can take effect in the `TracerCreateLocalSpanInterceptor#afterMethod`.


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking] wu-sheng commented on issue #9999: [Feature] [Java] Expose complete Tracing APIs in the tracing toolkit

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

   I am not following the demo codes actually.  
   1. About `public SpanRef(Object object)`, what is the `Object` about? 
   2. Why `TracerCreateLocalSpanInterceptor` has an `AbstractSpan localSpan;` field? Interceptor should not have any field in most cases.


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking] wu-sheng commented on issue #9999: [Feature] [Java] Expose complete Tracing APIs in the tracing toolkit

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

   Thanks for updating new proposal so quickly.
   - About span, please add necessary methods into `org.apache.skywalking.apm.toolkit.trace.ActiveSpan`.
   - `TracerManager` -> `Tracer`
   - `tag` and `log` APIs have existed in `ActiveSpan`. Do you want to add more?
   - Why do we need `newAsyncSpan`?
   
   BTW, new APIs could be added into `toolkit-trace` lib with new activation.


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking] wu-sheng commented on issue #9999: [Feature] [Java] Expose complete Tracing APIs in the tracing toolkit

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

   > And I think the Tracer is more excellent than TracerManager, so I will use it. I also want to add new APIs into toolkit-trace lib with new activation to keep compatibility with old APIs.
   
   I think we only need to add necessary APIs. After all, all APIs in toolkit are empty shells.
   
   > But maybe we can add the new APIs more like the APIs in kernel ContextManager? 
   
   You don't have to do that. Kernel APIs don't have to expose. We expose features.


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking] sumanpal97 commented on issue #9999: [Feature] [Java] Expose complete Tracing APIs in the tracing toolkit

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

   Hi @wu-sheng , this will be my first contribution and i am interested to look into this issue..can you assign this issue to me?


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking] wu-sheng commented on issue #9999: [Feature] [Java] Expose complete Tracing APIs in the tracing toolkit

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

   @sumanpal97 Done. Please prepare your proposal of API design, before write any codes.
   This task would take some time.


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking] mufiye commented on issue #9999: [Feature] [Java] Expose complete Tracing APIs in the tracing toolkit

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

   Thanks for your suggestions.
   * For the `tag` and `log` APIs, I think the APIs in `ActiveSpan` are enough. But maybe we can add the new APIs more like the APIs in kernel `ContextManager`? And in the use case you proposed, the requirements of tag and log are right there. So don't these requirements have to be implemented as our own Tracing APIs?
   * To implement the Async prepare/finish for span crossing threads, we should build a class corresponding to the span. Adding the `prepareForAsync()` and `asyncFinish()` to `ActiveSpan` is also feasible. But I want to separate it from the `ActiveSpan` class. WDYT?
   And I think the `Tracer` is more excellent than `TracerManager`, so I will use it. I also want to add new APIs into toolkit-trace lib with new activation to keep compatibility with old APIs.


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking] mufiye commented on issue #9999: [Feature] [Java] Expose complete Tracing APIs in the tracing toolkit

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

   > If you have an interceptor for `SpanRef`, then yes.
   
   Ok, I think I should read the source code of agent again. Sorry to disturb you.


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking] wu-sheng commented on issue #9999: [Feature] [Java] Expose complete Tracing APIs in the tracing toolkit

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

   Refs work for this case, it is better than implementing this bundled with other libs. In the SkyWalking APIs, we don't need to mix with other libs. The API lib should be as light as possible.


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking] mufiye commented on issue #9999: [Feature] [Java] Expose complete Tracing APIs in the tracing toolkit

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

   > 
   
   
   > > And I think the Tracer is more excellent than TracerManager, so I will use it. I also want to add new APIs into toolkit-trace lib with new activation to keep compatibility with old APIs.
   > 
   > I think we only need to add necessary APIs. After all, all APIs in toolkit are empty shells.
   > 
   > > But maybe we can add the new APIs more like the APIs in kernel ContextManager?
   > 
   > You don't have to do that. Kernel APIs don't have to expose. We expose features.
   
   I understand what you mean and I will focus on exposing the features.


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking] mufiye commented on issue #9999: [Feature] [Java] Expose complete Tracing APIs in the tracing toolkit

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

   > > Could you please assign this task to me? And should I make a more detailed API design proposal first?
   > 
   > Done. You don't have to wait for the assignment. SkyWalking community is more about volunteers driven. So, just take an action, and maintainers would like to provide helps as much as possible.
   
   Ok, so I begin to start coding now.


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking] wu-sheng commented on issue #9999: [Feature] [Java] Expose complete Tracing APIs in the tracing toolkit

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

   `TracerCreateLocalSpanInterceptor` is not one per instance, so you can't write that way. `setSkyWalkingDynamicField` works.
   I am not totally following your question, could you share what it is more explicitly? 
   Generally, you could declare a field in the toolkit class as a host, or use the dynamic field. But don't add any field in any interceptor, it doesn't work.


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking] mufiye commented on issue #9999: [Feature] [Java] Expose complete Tracing APIs in the tracing toolkit

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

   Sorry, I can't get the meaning of "Don't use anything static". Is it means that I should not use `Tracer` to create local span?
   BTW, I have updated the code in the above comment.


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking] mufiye commented on issue #9999: [Feature] [Java] Expose complete Tracing APIs in the tracing toolkit

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

   > > the interception of SpanRef can take effect in the aftermethod of TracerCreateLocalSpanInterceptor?
   > > I am confused about it. And after reading source code about transform, I think it can not take effect?
   > 
   > What are `can` and `can't` about? Which part?
   
   I am confused about if below codes? Will the `SpanRef` implemented `EnhancedInstance` by the agent in first code block or the `SpanRef` intercepted by the `SpanRefConstructInterceptor` in second block? Both these blocks are in the `afterMethod` in other `Intercepter`.
   ```java
   EnhancedInstance spanRef = (EnhancedInstance)new SpanRef();
   ```
   or
   ```java
   SpanRef spanRef = new SpanRef(localSpan);
   ```


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking] wu-sheng closed issue #9999: [Feature] [Java] Expose complete Tracing APIs in the tracing toolkit

Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng closed issue #9999: [Feature] [Java] Expose complete Tracing APIs in the tracing toolkit
URL: https://github.com/apache/skywalking/issues/9999


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking] wu-sheng commented on issue #9999: [Feature] [Java] Expose complete Tracing APIs in the tracing toolkit

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

   > First is the SpanRef how to point to the real span, the method I think is embedding a real span attribute span into the SpanRef object. WDYT?
   
   From the API level, I think you don't need anything to do. In the activation, the `EnhancedInstance#setSkyWalkingDynamicField` to host the span in the span.
   
   > Then we should import the AsyncSpan class into the SpanRef class. Is it allowed to import internal packages like this? Also for the ContextSnapshot imported into the Tracer class for capture and continued methods.
   
   You don't have a chance to call any internal agent APIs in the activation. All those calling have to do through activation(plugin mechanism).


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking] mufiye commented on issue #9999: [Feature] [Java] Expose complete Tracing APIs in the tracing toolkit

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

   Ok, I think my initial thinking went in the wrong direction and I will try to make the new API design without adding annotations.


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking] mufiye commented on issue #9999: [Feature] [Java] Expose complete Tracing APIs in the tracing toolkit

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

   > > First is the SpanRef how to point to the real span, the method I think is embedding a real span attribute span into the SpanRef object. WDYT?
   > 
   > From the API level, I think you don't need anything to do. In the activation, the `EnhancedInstance#setSkyWalkingDynamicField` to host the span in the spanRef.
   > 
   > > Then we should import the AsyncSpan class into the SpanRef class. Is it allowed to import internal packages like this? Also for the ContextSnapshot imported into the Tracer class for capture and continued methods.
   > 
   > You don't have a chance to call any internal agent APIs in the toolkit part. All those calling have to do through activation(plugin mechanism).
   
   Ok, it is more reasonable and I will use the `EnhancedInstance#setSkyWalkingDynamicField`. So for the ContextSnapshot, I will use the `ContextSnapshotRef` and `EnhancedInstance#setSkyWalkingDynamicField` like the `SpanRef`.


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking] mufiye commented on issue #9999: [Feature] [Java] Expose complete Tracing APIs in the tracing toolkit

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

   > 
   
   Ok, I see. I will think again about the log API design.


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking] wu-sheng commented on issue #9999: [Feature] [Java] Expose complete Tracing APIs in the tracing toolkit

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

   Don't use anything static. In the new API, SpanRef and AsyncSpanRef should be created as same as the new Span created in the agent core level. Is there any issue to do so?


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking] mufiye commented on issue #9999: [Feature] [Java] Expose complete Tracing APIs in the tracing toolkit

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

   > I mean, as you have enhanced one class successfully, there would not be special cases that could be enhanced or not. :) I think that was driving you to ask. My point is, don't treat this as a very complex thing, it is just simple enhancing and intercepting.
   
   Ok, I get it now.


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking] mufiye commented on issue #9999: [Feature] [Java] Expose complete Tracing APIs in the tracing toolkit

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

   > There is much black magic in the agent kernel. I think you have known the things.
   
   To write the toolkit and unit test, I have read a lot agent kernel code. What did you means the "black magic"? Does this phrase has a special meaning in apm?


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking] mufiye commented on issue #9999: [Feature] [Java] Expose complete Tracing APIs in the tracing toolkit

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

   Ok, I think I am too careless that write the wrong ENHANCE_CLASS. When I encounter this problem, I think this too complicated. a little embarrassing haha


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking] mufiye commented on issue #9999: [Feature] [Java] Expose complete Tracing APIs in the tracing toolkit

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

   > ContextCarrier is a shell, you could consider a thing similar or lambda as parameters. Each RPC/MQ has different parameters, so we need a general way to provide abstract APIs.
   
   I think about how to provide the abstract APIs for injecting/capturing data processed by `ContextCarrier` to/from all kinds of messages. In my opinion, the core part code is as below statements.
   ```java
   // in asynchttpclient-2.x-plugin
   final HttpHeaders headers = httpRequest.getHeaders();
   CarrierItem next = contextCarrier.items();
   while (next.hasNext()) {
       next = next.next();
       headers.set(next.getHeadKey(), next.getHeadValue());
   }
   ```
   Originally, I want to release this part code of RPC/MQ inside the `inject` and `extract` toolkit-api. But now, as you say, each RPC/MQ has different parameters, so I think maybe exposing the `items()` in `ContextCarrier`, `hasNext()` and  `next()` in `CarrierItem` as the "Ref" format is better. So users can use these APIs freely to pass data by all kinds of messages such as HTTP headers, RPC metadata and so on. I'm not sure it's a reasonable idea. Could you give some suggestions? @wu-sheng 


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking] mufiye commented on issue #9999: [Feature] [Java] Expose complete Tracing APIs in the tracing toolkit

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

   I have one question that the constructor writen in the `InstanceMethodsAroundInterceptor` can be intercepeted by the defined `InstanceConstructorInterceptor`?  For example, the `spanRef` in `afterMethod` of `TracerCreateLocalSpanInterceptor`.
   ```
   public class TracerCreateLocalSpanInterceptor implements StaticMethodsAroundInterceptor {
       AbstractSpan localSpan;
   
       @Override
       public void beforeMethod(Class clazz, Method method, Object[] allArguments, Class<?>[] parameterTypes, MethodInterceptResult result) {
           localSpan = ContextManager.createLocalSpan(String.valueOf(allArguments[0]));
       }
   
       @Override
       public Object afterMethod(Class clazz, Method method, Object[] allArguments, Class<?>[] parameterTypes, Object ret) {
           SpanRef spanRef = new SpanRef(localSpan);
           return spanRef;
       }
       ...
   }
   ```
   ```
   public class SpanRefConstructInterceptor implements InstanceConstructorInterceptor {
       @Override
       public void onConstruct(EnhancedInstance objInst, Object[] allArguments) throws Throwable {
           objInst.setSkyWalkingDynamicField(allArguments[0]);
       }
   }
   ```


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking] mufiye commented on issue #9999: [Feature] [Java] Expose complete Tracing APIs in the tracing toolkit

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

   > > > One more suggestion, we could consider SpanRef as a new API, thay could be more flexible.
   > > 
   > > 
   > > Is this SpanRef refering to `AsyncSpanRef`? Sorry, I can't understand the meaning of "a new API".
   > 
   > Oh, sorry. I didn't mean that. It is alternative to the current ActiveSpan. The SpanRef is a point of new created or active span. User could directly use it, rather than calling ActiveSpan every time.
   
   Oh, I think I understand what you mean. So if we create a span, we can use `SpanRef` to point to this span. When we want to call the log function of this span, so we can just use this `SpanRef` directly, right?


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking] wu-sheng commented on issue #9999: [Feature] [Java] Expose complete Tracing APIs in the tracing toolkit

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

   ```
       public static void inject(Object message) {
       }
   
       public static void extract(Object message) {
       }
   ```
   
   Don't use `Object` as parameter, it is too general.
   
   ```
       public static ContextSnapshot capture() {
           return null;
       }
   
       public static void continued(ContextSnapshot snapshot) {
       }
   ```
   
   Don't return null, you could create a dummy implementation to avoid NPE.
   


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking] mufiye commented on issue #9999: [Feature] [Java] Expose complete Tracing APIs in the tracing toolkit

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

   Good evening@wu-sheng, I have organized new idea about api design today and write these API designs in brief. Could you give me some suggestions? And to what extent should the api design proposal be detailed?
   * **Span creating**
   
     ```java
     public class TracerManager{
         public static void createEntrySpan(String operationName, Object message){}
         public static void createLocalSpan(String operationName){}
         public static void createExitSpan(String operationName, Object message, String remotePeer){}
         public static void createExitSpan(String operationName, String remotePeer){}
         public static void stopSpan(){}
     }
     ```
   
   * **Inject/extract for RPC tracing**
   
     ```java
     // Question: how to pass the ContextCarrier
     // Answer: use message to encapsulate the ContextCarrier
     public class TracerManager{
         ...
         public static void inject(Object message){}
         public static void extract(Object message){}
     }
     ```
   
   * **Capture/continue for continue tracing context in the x-thread tracing**
   
     ```java
     public class TracerManager{
         ...
         public static ContextSnapshot capture(){}
         public static void continued(ContextSnapshot snapshot){}
     }
     ```
   
   * **Tag and log for the current span**
   
     ```java
     public class CurrentSpan{
         public static void log(Throwable t){}
         public static void log(Map<String, ?> event){}
         public static void tag(String key, String value){}
         public static void tag(AbstractTag<?> tag, String value){}
     }
     ```
   
   * **Async prepare/finish for span crossing threads**
   
     ```java
     public class newAsyncSpan{
       	...
         public newAsyncSpan prepareForAsync(); 
         public newAsyncSpan asyncFinish();
     }
     ```
   


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking] mufiye commented on issue #9999: [Feature] [Java] Expose complete Tracing APIs in the tracing toolkit

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

   > > And I think the Tracer is more excellent than TracerManager, so I will use it. I also want to add new APIs into toolkit-trace lib with new activation to keep compatibility with old APIs.
   > 
   > I think we only need to add necessary APIs. After all, all APIs in toolkit are empty shells.
   
   I will use the empty shell and the activation to link just like the API in apm-toolkit-trace and apm-toolkit-activation.
   
   


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking] mufiye commented on issue #9999: [Feature] [Java] Expose complete Tracing APIs in the tracing toolkit

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

   > > To implement the Async prepare/finish for span crossing threads, we should build a class corresponding to the span. Adding the prepareForAsync() and asyncFinish() to ActiveSpan is also feasible. But I want to separate it from the ActiveSpan class. WDYT?
   > 
   > Let's name it AsyncSpanRef.
   
   Ok, `AsyncSpanRef` is more reasonable.


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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


[GitHub] [skywalking] mufiye commented on issue #9999: [Feature] [Java] Expose complete Tracing APIs in the tracing toolkit

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

   Could you please assign this task to me? And should I make a more detailed API design proposal first?


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

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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