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 ContextManager APIs and context stack-style auto propagation. #3

Merged
merged 5 commits into from
Mar 4, 2020

Conversation

wu-sheng
Copy link
Member

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

High-level APIs introduced in this PR. By leveraging the thread local, it will be better easy to use.

APIs

High-Level APIs

High level APIs are targeting convenient usages. These APIs use the ThreadLocal to propagate the context, so users could create span at any moment, and the context will finish automatically once the first created span of this thread stopped.

ContextManager::tracing_entry("op1", Some(&injector), |mut span| {
    // Use span freely in this closure
    // Span's start/end time is set automatically with this closure start/end(s).
    span.tag(Tag::new(String::from("tag1"), String::from("value1")));

    ContextManager::tracing_exit("op2", "127.0.0.1:8080", Some(&extractor), |mut span| {
        span.set_component_id(33);
    });

    ContextManager::tracing_local("op3", |mut span| {});
});

@wu-sheng wu-sheng added the enhancement New feature or request label Mar 3, 2020
@wu-sheng wu-sheng added this to the 0.1.0 milestone Mar 3, 2020
@wu-sheng wu-sheng requested a review from hanahmily March 3, 2020 08:35
Copy link

@hanahmily hanahmily left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@wu-sheng wu-sheng merged commit cc1c371 into master Mar 4, 2020
@wu-sheng wu-sheng deleted the context-manager branch March 4, 2020 05:58
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.

2 participants