-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
[Feature] About support multi threads and auto finalize for skywalking-rust. #9297
Comments
I think the new api design is (fake code): use skywalking_rust::context::trace_context::TracingContext;
use skywalking_rust::reporter::grpc::Reporter;
use tokio;
static TRACING_MANAGER: Lazy<TracingManager> = Lazy::new(|| TracingManager::default("svc", "ins"));
async fn handle_request(reporter: ContextReporter) {
let mut ctx = TRACING_MANAGER.create_context();
{
// Generate an Entry Span when a request
// is received. An Entry Span is generated only once per context.
let span = ctx.create_entry_span("operation1").unwrap();
// Something...
{
// Generates an Exit Span when executing an RPC.
let span2 = ctx.create_exit_span("operation2").unwrap();
// Something...
// Drop span2 and finalize to ctx.
}
// Drop span and finalize to ctx.
}
// Create coroutine to handle async task.
spawn(async move {
let mut ctx2 = TRACING_MANAGER.create_context();
{
let span3 = ctx2.create_entry_span("operation3").unwrap();
// Something...
// Drop span2 and finalize to ctx2.
}
// Drop ctx2 and send to TRACING_MANAGER.
});
// Drop ctx and send to TRACING_MANAGER.
}
#[tokio::main]
async fn main() {
let tx = Reporter::start("http://0.0.0.0:11800").await;
// Start server...
// Block to report.
loop {
let context = TRACING_MANAGER.receive_context();
reporter.send(context).await;
}
} Add the |
Do you want to implement |
OK, let me think about the design of API. |
What is the purpose of |
Every
You may refer to java impl, https://github.com/apache/skywalking-java/blob/main/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/ContextManager.java#L157 |
The parent segment is not a very accurate concept, as there are many spans in current and parent context, you can't know which span of ctx is referring another span in ctx2. This doc may help you understanding this concept, https://skywalking.apache.org/docs/skywalking-java/latest/en/setup/service-agent/java-agent/java-plugin-development-guide/#contextsnapshot. In the protocol, the span's reference doesn't only represent the peer of an RPC/MQ, it also could represent a cross-thread reference. |
Maybe some visualization bug? I am not sure about this. If you purely want to check capture and continuous, all async HTTP call or callback should include this case. |
Yes, I switch to using the old 8.x UI, and the |
FYI @Fine0830 We may miss mutiple references in the span page in 9.x |
I've confirmed the issue with both 9.0.0 and 9.1.0. The issue is caused by
|
@lujiajing1126 Could you be more specific what causes the NPE? |
Here
I suppose, we miss a line here, We have to add |
Could you send a pull request to fix this? |
Hi @jmjoy, the bugfix has been merged to the master branch. You may have a try. |
I just tested it and found it to be fixed.
I just tested it and found it to be fixed. |
Add Tracer: apache/skywalking-rust#26 |
Auto finalize context and span when dropped. apache/skywalking-rust#28 |
We only have cross threads left for this issue, right? |
Yes. |
Add context capture and continued methods. through apache/skywalking-rust#29 |
@jmjoy Should we consider a 0.3.0 release? Any other things you may add? In the future, I think log collecting and meter(Metrics) reports are good choices. |
No problem, future changes can be put into 0.4.0. |
@jmjoy I could start the release, could you update the version declare with e2e dependency? |
OK. |
Search before asking
Description
Now the
skywalking-rust
only support one thread tracing, but usually there are some scenes that require multi threads/coroutines tracing.Use case
Rust application requires multi threads and coroutines tracing.
Related issues
apache/skywalking-rust#20 (comment)
apache/skywalking-rust#26
apache/skywalking-rust#28
apache/skywalking-rust#29
Are you willing to submit a PR?
Code of Conduct
The text was updated successfully, but these errors were encountered: