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

Allow registering callbacks when propagating a ServiceInvocationConte… #125

Merged
merged 1 commit into from
Mar 24, 2016

Conversation

anuraaga
Copy link
Collaborator

…xt and set them for tracing.

In fully asynchronous servers, it is common to jump in and out of the execution thread, and we need to restore ThreadLocal state every time this happens. We have the makeContextAware family of methods to restore ServiceInvocationContext, but for tracing we also need to restore the ServerSpan.

@anuraaga
Copy link
Collaborator Author

cc @synk

}
}
};
}

private static void resetContext(ServiceInvocationContext ctx) {
removeCurrent();
ctx.makeContextAwareHandlers.forEach(MakeContextAwareHandler::exit);
Copy link
Contributor

Choose a reason for hiding this comment

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

makeContextAwareHandlers seems nullable?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks - added test too.

return true;
});
}

public void addMakeContextAwareHandler(Runnable onContextEnter, Runnable onContextExit) {
if (makeContextAwareHandlers == null) {
makeContextAwareHandlers = new ArrayList<>();
Copy link
Member

Choose a reason for hiding this comment

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

initial capacity

@anuraaga
Copy link
Collaborator Author

Updated to use two lists

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants