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/18 09:26:06 UTC

[GitHub] [skywalking] celine2c opened a new issue #6576: Will ContextManager.continued merge spans?

celine2c opened a new issue #6576:
URL: https://github.com/apache/skywalking/issues/6576


   Please answer these questions before submitting your issue.
   
   - Why do you submit this issue?
   - [ ] Question or discussion
   
   ___
   ### Question
   Will ContextManager.continued merge spans?
   ___
   ### Bug
   - Which version of SkyWalking, OS, and JRE?
   
   - Which company or project?
   
   - What happened?
   I have read the following
   https://github.com/apache/skywalking/blob/5.x/docs/en/Plugin-Development-Guide.md#contextsnapshot
   In this it is mentioned, like in the main thread, create a snap shot, pass it to the sub thread.
   In the entry class, I created an entry span, and I put few tags and its values in the span.
   I intercepted the constructor of the Runnable class and took the snapshot. I set the snapshot using objInst.setSkyWalkingDynamicField().
   In the run interceptor, in the before method, I created the local span, then called
   ContextManager.continued(contextSnapshot);
   Now in the thread process, I put few more tags and its values in the span 
   At run interceptor after method, when I am reading the tags and its values, I can see the tags from the local span i created, but the tags from the main span is not visible.
   I expect contextmanager.continued will be starting the span from where the snapshot was taken. 
   How can I merge the two spans to get the details from both the spans?
   
   ___
   ### Requirement or improvement
   - Please describe your requirements or improvement 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.

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



[GitHub] [skywalking] celine2c commented on issue #6576: Will ContextManager.continued merge spans?

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


   Hi,
   
   My requirement is I have a parent process, which will spawn 2 threads. All the threads, including the parent will be doing some process and adding the status of the process they are handling , say success or failure in the span tags. At the end who ever finishes the last, there, I want to see the success of entire process. I hope the way to communicate with threads is contextmanager.snapshot. I want the segment to be hold till the entire threads are done which i guess can be achieved through prepareforasync and asynFinish. If I cannot merge them, what would be the best way you suggest to get a single segment with the details from all the three threads?
   
   Thanks!


-- 
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 #6576: Will ContextManager.continued merge spans?

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


   > In that case, from the child, how can I get access to the parent span?
   
   No, you can't. Tracing is not for propagating the business context. Are you asking for some other use 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.

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



[GitHub] [skywalking] wu-sheng commented on issue #6576: Will ContextManager.continued merge spans?

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


   About (1), what do you mean by not creating 2nd segment? Your logic seems correct.
   (2), In the main thread, you should stop the stop, in another thread, you should do asyncStop. The documentation has included how to use the APIs, I think.


-- 
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] celine2c commented on issue #6576: Will ContextManager.continued merge spans?

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


   Hi,
   
   1. I meant the entry in the collector. I am trying to capture the details in ElasticSearch. So I can see the span name 1 (entry span) only. Not the entry with span name 2(localspan) - I expected both
   2. Yes I tried to stop it in the main thread and asyncFinish in the second thread. So how can I pass the span to the static method interceptor of the second thread?
   
   Thanks!


-- 
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] celine2c commented on issue #6576: Will ContextManager.continued merge spans?

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


   Ok thanks.
   
   In that case, from the child, how can I get access to the parent span?
   
   Thanks in advance


----------------------------------------------------------------
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 #6576: Will ContextManager.continued merge spans?

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


   You could do this by using `prepareforasync and asynFinish`, notice, this will have performance impact(even limited), because it causes more memory.


-- 
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 #6576: Will ContextManager.continued merge spans?

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


   I am not sure what is the context of your question anymore. I am fully confused about your question, it looks like you lack basic tracing knowledge rather than things related to SkyWalking.
   We are not mentoring program to help you to understand the tracing system, sorry.


-- 
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] celine2c commented on issue #6576: Will ContextManager.continued merge spans?

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


   Hi,
   
   I was able to fix my issue with the help of approach one. Thanks!
   
   Now I am getting Entry span and few local spans. 
   
   Scenario 1:
   A is calling B and A is calling C. These are all in the same instance/jvm. 
   So I am creating A as the entry span, B and C as local spans. ie A is the parent to both B&C. So far so good. 
   How can the sequence of local spans achieved ? ie I want to know that B is called first and then C. Is there an option? I can see the reference is only to A.
   
   Scenario 2:
   A is calling B of the same instance/jvm. But B is calling C of different process, in a different JVM.
   So A is an entry span, B is a local span. C is again an entry span.
   When I check the reference, I can see that C has the reference to B.
   Now I was to show/read them in two different ways.
   1. For high level, I want to show only the processes/jvms included, ie I want to show only A -> C
   2. For those who want to see in detail,  then I want to show A -> B -> C
   
   1 can be achieved if I don't initiate the local span for B. But it is needed for scenario 2. Is there an option to achieve both ?
   
   
   Thanks!


-- 
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] celine2c commented on issue #6576: Will ContextManager.continued merge spans?

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


   Hi,
   
   I tried both the approaches but both are not giving expected results.
   
   1. For the contextManager.capture() approach - Expectation is, this will create two seperate segments, there will be a child of releationship between two.
   	
   		MainThread
   			createsEntrySpan
   			calls Runnable
   				In the runnable's constructor I take the snapshot.
   				Pass the snapshot in the EnhancedInstance's setSkyWalkingDynamicField
   			Do processing as the main thread has more job to do
   			stopSpan
   		
   		SubThread (this will start before or after the stopSpan according to the process jobs of the main thread)
   			In the run before method interceptor, I get the snapshot from EnhancedInstance's getSkyWalkingDynamicField
   				creates local span
   				ContextManager.continued
   			Do processes
   			In the run after method interceptor, stopSpan.
   			
   	This approach, creates the first segment, but not the second one. 
   	Is this behaving right or am I missing something?
   	
   2. 	For the prepareForAsync approach - Expectation is, this will pass the spans between threads and once asyncFinish is called, it will create a singleSpan
   	
   		MainThread	
   			createEntrySpan
   			calls Runnable	
   				In the runnable's constructor I call prepareForAsync 
   				Pass the span in the EnhancedInstance's setSkyWalkingDynamicField
   			Do processing as the main thread has more job to do
   			stopSpan // I tried without stopping the span as well. Which approach is right?
   			
   		SubThread (this will start before or after the stopSpan according to the process jobs of the main thread)
   			In the run before method interceptor, I get the span from EnhancedInstance's getSkyWalkingDynamicField
   				//I can see that the span is active here	
   			Do processes
   				Static calls are made. I have interceptors for the static method as well. - At this point, I am unable to get the reference of the span in the static interceptor. How should I achive it as I have the span in getSkyWalkingDynamicField which is not available in the static interceptors.
   			asyncFinish
   			
   	Do we need to pass the spans to different interceptors in the subThreads? If so how from the second thread to the staticmethod interceptors?
   	
   Thanks in advance!


-- 
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 #6576: Will ContextManager.continued merge spans?

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


   


----------------------------------------------------------------
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 #6576: Will ContextManager.continued merge spans?

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


   Capture and continue have nothing related to tags. They link 2 spans as parent and child only


----------------------------------------------------------------
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 #6576: Will ContextManager.continued merge spans?

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


   > I meant the entry in the collector. I am trying to capture the details in ElasticSearch. So I can see the span name 1 (entry span) only. Not the entry with span name 2(localspan) - I expected both
   
   Sorry, hard to follow what do you mean by this.
   
   > Yes I tried to stop it in the main thread and asyncFinish in the second thread. So how can I pass the span to the static method interceptor of the second thread?
   
   How to propagate is your case, you could choose parameters or anything 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.

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