-
Notifications
You must be signed in to change notification settings - Fork 20
Enhance Trace Context machenism. #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
jmjoy
commented
Jun 5, 2022
- Get current time as milliseconds rather than seconds.
- Fix parent span id.
- Add method to modify internal span object.
src/context/trace_context.rs
Outdated
|
|
||
| let mut span = Box::new(Span::new( | ||
| self.next_span_id, | ||
| -1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why hard code the span parent Span ID? Parent span ID should be the previous unfinished span in this tracing context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If /status/500 fails, and retry /status/400 again, then yes, the right is correct.
But this example seems not relative to why hardcode parent span ID? The right logic is, parent span ID should be the latest unfinished span ID in this context/thread.
I don't mean the original codes are correct, I don't check so carefully. But the new one seems not correct at least.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I understand what you mean. In this case, the parent span ID should be set to the Span ID of the previous span that has not set end time. The code will change a lot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you just need to add a current span ref in TracingContext, and always use it as parent span ID, unless a parent Span ref is given as new span's parameter.
The current span in TracingContext should be set to its parent when it is closed.
In the Java agent, we use a stack(implement through a LinkedList) to push/pop the active span.
You could take this as a good reference,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see you did a lot of work on making rust-sdk in PHP ecosystem, and also helped our php-agent in skyapm org.
If you are willing to take more responsibility to this repo, this would be a very good start.
@Shikugawa implemented this for the first time, we have a lot to do to polish.
src/context/trace_context.rs
Outdated
|
|
||
| let span = Box::new(Span::new( | ||
| self.next_span_id, | ||
| 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why initial as 0?
|
Any update? |
No. |
|
Is this solution OK? If possible, I will fix CI. |
What solution? I left comments days ago. Wait for your reply. |
Sorry, I found that my comment is pending and I have to submit it. 😅 |
Codecov Report
@@ Coverage Diff @@
## master #20 +/- ##
==========================================
+ Coverage 84.94% 86.86% +1.92%
==========================================
Files 9 9
Lines 279 297 +18
==========================================
+ Hits 237 258 +21
+ Misses 42 39 -3
Continue to review full report at Codecov.
|
|
I rewrite the logic of get the parent span id, please review. |
tests/trace_context.rs
Outdated
| // pub mod skywalking_proto { | ||
| // pub mod v3 { | ||
| // tonic::include_proto!("skywalking.v3"); | ||
| // } | ||
| // } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you comment these lines?
|
The new one looks better, one questions Please fix e2e test. |
Fixed.
|
|
Both are making sense. About (1), let's talk in a discussion/issue in the main repo about the details, to make you easier. |

