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

Prevent circular dependency in global telemetry logger creation #1674

Merged
merged 3 commits into from
Nov 10, 2021

Conversation

yao-msft
Copy link
Contributor

@yao-msft yao-msft commented Nov 4, 2021

Currently there is a potential circular dependency between the telemetry object and the logger object due to the need to open settings to finish telemetry construction.

Microsoft Reviewers: Open in CodeFlow

@yao-msft yao-msft requested a review from a team as a code owner November 4, 2021 03:45
Copy link
Member

@JohnMcPMS JohnMcPMS left a comment

Choose a reason for hiding this comment

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

This does not solve the problem, which is telemetry > settings > failure > telemetry. The only solution that I see to that is disabling telemetry until settings are loaded in order to be able to respect the potential for the setting that disables telemetry.

@ghost ghost added the Needs-Author-Feedback Issue needs attention from issue or PR author label Nov 4, 2021
@ghost ghost removed the Needs-Author-Feedback Issue needs attention from issue or PR author label Nov 9, 2021
thread_local std::once_flag initLogging;

std::call_once(initLogging, []() {
std::unique_ptr<AppInstaller::ThreadLocalStorage::PreviousThreadGlobals> previous = threadGlobals.SetForCurrentThread();
Copy link
Member

Choose a reason for hiding this comment

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

While this may solve the problem when the code stays on one thread, it may make other problems that we are not aware of. I would rather we fix it completely by creating a set of APIs that give more explicit control over the thread globals so that callers can actually control what is happening.

@yao-msft yao-msft merged commit b4693b1 into microsoft:master Nov 10, 2021
@yao-msft yao-msft deleted the telemetrycirculardependency branch November 10, 2021 01:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants