in src/Telemetry/Telemetry.cs [68:98]
private void InitializeTelemetry(string productVersion, IConfiguration config)
{
try
{
var telemetryConfig = new TelemetryConfiguration
{
ConnectionString = $"InstrumentationKey={InstrumentationKey};"
};
this._client = new TelemetryClient(telemetryConfig);
this._client.Context.Session.Id = CurrentSessionId;
this._client.Context.Device.OperatingSystem = RuntimeInformation.OSDescription;
// Filter out sensitive information that we don't need. Empty values are ignored so just set some default string for each.
// RoleInstance - It can contain information such as the machine and domain name of the client
// NodeName - It can contain information such as the machine and domain name of the client
// Ip - We don't need any location info
this._client.Context.Cloud.RoleInstance = "-";
this._client.Context.GetInternalContext().NodeName = "-";
this._client.Context.Location.Ip = "0.0.0.0";
this._commonProperties = new TelemetryCommonProperties(productVersion, this._client, config).GetTelemetryCommonProperties();
this._commonMeasurements = new Dictionary<string, double>();
this._logger.LogDebug($"Telemetry Initialized. Session={CurrentSessionId}");
}
catch (Exception e)
{
this._client?.TrackException(e);
this._client = null;
// we don't want to fail the tool if telemetry fails.
this._logger.LogError($"Error initializing telemetry. Telemetry will be disabled. Message={e.Message}");
}
}