Disable telemetry in `dotnet` core 3.0 cli util?

Viewed 2823

How is it possible fully disable (or firewall) telemetry of cli util dotnet in linux?

setting environment variable:

    echo "export DOTNET_CLI_TELEMETRY_OPTOUT=1"

helps only disable telemetry when starting dotnet with params:

    dotnet build
    dotnet pack
    dotnet run

but if for ex. call dotnet with params:

    dotnet new
    dotnet nuget
    ...

telemetry is sent anyway. (doc: https://docs.microsoft.com/en-us/dotnet/core/tools/telemetry#collected-options)

Any ides, options? White rules for nftables/proxychains?

1 Answers

I am reading and interpreting https://docs.microsoft.com/en-us/dotnet/core/tools/telemetry#collected-options differently:

Certain commands send additional data.

It sounds to me like this means "if telemetry is enabled, these commands send additional data. If telemetry is disabled, no data is sent anyway".

The Telemetry implementation seems to match my understanding:

First, the environment variable is used to enable (or disable, actually) telemetry:

        Enabled = !environmentProvider.GetEnvironmentVariableAsBool(TelemetryOptout, false) && PermissionExists(sentinel);

Then, the public API uses Enabled to decide to do anything at all:

    public void TrackEvent(string eventName, IDictionary<string, string> properties,
        IDictionary<string, double> measurements)
    {
        if (!Enabled)
        {
            return;
        }

        //continue the task in different threads
        _trackEventTask = _trackEventTask.ContinueWith(
            x => TrackEventTask(eventName, properties, measurements)
        );
    }

    public void Flush()
    {
        if (!Enabled || _trackEventTask == null)
        {
            return;
        }

        _trackEventTask.Wait();
    }

    public void ThreadBlockingTrackEvent(string eventName, IDictionary<string, string> properties, IDictionary<string, double> measurements)
    {
        if (!Enabled)
        {
            return;
        }
        TrackEventTask(eventName, properties, measurements);
    }

Sounds to me like everything should be a No-Op. If you can find any evidence to the contrary, please do what the page you linked suggests:

Protecting your privacy is important to us. If you suspect the telemetry is collecting sensitive data or the data is being insecurely or inappropriately handled, file an issue in the dotnet/cli repository or send an email to dotnet@microsoft.com for investigation.

I have used this script to check that tdcpdump doesn't show any telemetry data being sent to dc.services.visualstduio.com in previous release of .NET Core:

https://github.com/redhat-developer/dotnet-regular-tests/blob/master/telemetry-is-off-by-default/test-telemetry-tcpdump.sh

I haven't tested .NET Core 3.0.

Related