Skip to content
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

Support context extract. #1

Merged
1 commit merged into from
Mar 1, 2020
Merged

Support context extract. #1

1 commit merged into from
Mar 1, 2020

Conversation

wu-sheng
Copy link
Member

@wu-sheng wu-sheng commented Mar 1, 2020

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

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

The header carrier is

    struct MockerHeader {}

    impl Extractable for MockerHeader {
        fn extract(&self, key: String) -> &str {
            "1-My40LjU=-MS4yLjM=-4-1-1-IzEyNy4wLjAuMTo4MDgw-Iy9wb3J0YWw=-MTIz"
        }
    }

@wu-sheng wu-sheng added the enhancement New feature or request label Mar 1, 2020
@wu-sheng wu-sheng added this to the 0.1.0 milestone Mar 1, 2020
@ghost ghost merged commit 6cc61f1 into master Mar 1, 2020
@wu-sheng wu-sheng deleted the ref branch March 1, 2020 09:18
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant