-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
For build-from-source builds of .NET, opt-out of Microsoft telemetry #25935
Conversation
This isn't quite what I was expecting. Disable telemetry is still relying on setting an ENV. Don't we want something much more fundamental, where no ENVs are set by default AND telemetry is not enabled? |
There are two ways to implement this:
I've opted for the first because that was simplest to implement. |
It feels like the other option is the "right" architectural choice. That approach would mean there is a literal guarantee that telemetry can never be enabled through some accidental gesture. |
this is also needed in src/WebSdk/Publish/Tasks/WebConfigTelemetry.cs? |
Yes, this is needed everywhere where something reads the envvar. And why I mentioned MSBuild Tasks in the initial message. Imo the safest is to set the envvar at startup to ensure every location that checks it (which maybe does not live in this repo?) is aware telemetry is disabled. @richlander indicates he expects the PR to update locations that check to envvar in this repo to be updated. If the repo owners confirm this is their preference also, I'll update the PR to use that approach. |
I thought you could have a test that searches for "DOTNET_CLI_TELEMETRY_OPTOUT" in the binaries after a source build, but:
|
@KalleOlaviNiemitalo for this PR I'd like to scope to make the behavior opt-in rather than exclude it. If excluding gets implemented, that can be a useful test. |
@dsplaisted @baronfel question: do you prefer this being implemented as:
|
Is the environment variable read by any tools that are published to NuGet.org? Perhaps, even if a user installs a source-built SDK and does not expect it to send telemetry, the user might not expect this SDK to tell separately-installed tools not to send telemetry either. |
We are typically hesitant for the SDK to set ENVs automatically (for any scenario). It can have unexpected consequences across process boundaries. I'm unaware of any scenario where tools would still have telemetry enabled that we need to worry about. My understanding is that telemetry is solely enabled by the system we're looking at in this PR. |
For the test failure on the Darwin leg, you can cherry pick this commit or wait for this PR to go in which includes that commit. |
Directory.Build.props
Outdated
@@ -21,6 +21,7 @@ | |||
<!-- <ArtifactsShippingSymbolsDir>$(ArtifactsDir)symbols\$(Configuration)\Shipping</ArtifactsShippingSymbolsDir> --> | |||
|
|||
<DefineConstants Condition="'$(ContinuousIntegrationBuild)' == 'true'">$(DefineConstants);CI_BUILD</DefineConstants> | |||
<DefineConstants Condition="'$(DotNetBuildFromSource)' != 'true'">$(DefineConstants);MICROSOFT_ENABLE_TELEMETRY</DefineConstants> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per my understanding, with the naive build of the product, MICROSOFT_ENABLE_TELEMETRY
will be set. Isn't that not what we want?
How about the follow?
<DefineConstants Condition="'$(DotNetBuildFromSource)' != 'true'">$(DefineConstants);MICROSOFT_ENABLE_TELEMETRY</DefineConstants> | |
<DefineConstants Condition="'$(MicrosoftOfficialBuild)' == 'true'">$(DefineConstants);MICROSOFT_ENABLE_TELEMETRY</DefineConstants> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is there works to opt-out of telemetry for open-source builds of .NET.
DotNetBuildFromSource
is used throughout the different repositories to detect that.
I'm not familiar with MicrosoftOfficialBuild
. It's not used in this repo yet.
I'll apply the suggestion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MicrosoftOfficialBuild
is something I made up. We would just need the official build to set that condition and then everything would be perfect.
Can we do that @marcpopMSFT, for the official SDK build?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's more of an engineering system question as items like ContinuousIntegrationBuild are set in the scripts that live in the eng\common folder it looks like. @mmitche do you know where MicrosoftOfficialBuild would need to be set so that our official builds would include that? that probably needs to be set before this PR can go in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would need to be set in the YAML files in this repo, similar to how we enable other Microsoft specific switches in our build. e.g. https://github.com/dotnet/sdk/blob/main/.vsts-ci.yml#L34-L35
I think this will end up being a common pattern with potentially other organizations having their own logic in shared code. Perhaps we change this to something like OfficialBuilder
, setting it to Microsoft
for us, or perhaps BuildOrganization
?
Thoughts @richlander?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not particularl on the name, but something like that sounds good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's go for OfficialBuilder
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can always change it later if someone has a better name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would need to be set in the YAML files in this repo, similar to how we enable other Microsoft specific switches in our build. e.g. https://github.com/dotnet/sdk/blob/main/.vsts-ci.yml#L34-L35
I've added it to this location.
Let's go for OfficialBuilder
My personal preference was to use the existing DotNetBuildFromSource
rather than introduce something new.
@marcpopMSFT can you review the PR, and give your input here: #25935 (comment)? |
Is this ready to merge? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Needs a rebase to incorporate changes from main
in the meantime though.
Can we make this PR land this week? That'd would be really excellent for ensuring we make .NET 7. |
Merged in the CI fix from main, let's see if we can get to green now. |
…by default. We opt-out by setting DOTNET_CLI_TELEMETRY_OPTOUT at 'dotnet' Main to ensure that anything that checks the variable later, including MSBuild Tasks, will see the value.
Co-authored-by: Rich Lander <[email protected]>
Use 'Microsoft' as 'OfficialBuilder' value. Co-authored-by: Jan Kotas <[email protected]>
f0fcad7
to
2cd0f13
Compare
We opt-out by setting DOTNET_CLI_TELEMETRY_OPTOUT at 'dotnet' Main
to ensure that anything that checks the variable later, including MSBuild Tasks,
will see the value.
Fixes #24474
cc @omajid @richlander @baronfel @jkotas