Skip to content

Prevent circular dependency in global telemetry logger creation - #1674

Merged
yao-msft merged 3 commits into
microsoft:masterfrom
yao-msft:telemetrycirculardependency
Nov 10, 2021
Merged

yao-msft merged 3 commits into
microsoft:masterfrom
yao-msft:telemetrycirculardependency

Conversation

@yao-msft

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

Copy link
Copy Markdown
Contributor

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

@JohnMcPMS JohnMcPMS left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
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