Hi Dev Team, especially Gao and Jinlin Fu

I used this week to finish the 101 learning of Rust, and drop this tracing
API usage prototype.

let reporter = MockReporter::new();
let mut context = TracingContext::new(&reporter).unwrap();
let span1 = context.create_entry_span(String::from("op1"), None);
{
    assert_eq!(span1.span_id(), 0);
    let span2 = context.create_entry_span(String::from("op2"), Some(&span1));
    {
        assert_eq!(span2.span_id(), 1);
        let mut span3 = context.create_entry_span(String::from("op3"),
Some(&span2));
        assert_eq!(span3.span_id(), 2);

        context.finish_span(span3);
    }
    context.finish_span(span2);
}
context.finish_span(span1);

reporter.report_trace(context);
// context has moved into reporter. Can't be used again.

let received_context = reporter.recv.recv().unwrap();
assert_eq!(received_context.finished_spans.len(), 3);


You also could find the code linked here,
https://github.com/apache/skywalking-rust/blob/f9b7e815416df70e77a8b01e918d1f8b9ccb456a/tracing-core/src/context.rs#L90-L111

If you have any suggestion, please let me know or send pull request to the
repo.
I will continue to fill the details of APIs, and report implementation too.

Sheng Wu 吴晟
Twitter, wusheng1108

Reply via email to