如何使用 Application Insights 覆盖或忽略 cloud_RoleInstance

How to overwrite or ignore cloud_RoleInstance with Application Insights

我们刚刚开始使用 Application Insights。尽管这主要是为云中的应用程序 运行 构建的,但我们也使用它来跟踪 WPF 客户端的一些使用情况统计信息。

对于此安装,我们不想跟踪 cloud_RoleInstance 中的机器名称。这是我们的隐私政策问题。在较小的公司中,存储机器名称甚至变得更加重要,机器名称可能是用户的名称。至少在我们的市场上,这是不行的。

这是为服务器和 WPF 客户端设置遥测客户端的方式。

TelemetryClient telemetryClient = new TelemetryClient() { InstrumentationKey = ApplicationInsightsHelper.InstrumentationKey };

//do not track username...
//telemetryClient.Context.User.Id = Environment.UserName;
telemetryClient.Context.Session.Id = SessionId.ToString();

telemetryClient.Context.Device.OperatingSystem = GetWindowsFriendlyName();

telemetryClient.Context.Component.Version = Version;
telemetryClient.Context.Properties.Add("ComponentName", ComponentName);
telemetryClient.Context.Properties.Add("CustomerId", CustomerId);

现在我的问题是如何设置遥测客户端以删除、混淆、覆盖 cloud_RoleInstance 属性。

提前致谢

好的,这比我想象的要容易:

telemetryClient.Context.Cloud.RoleInstance = CustomerId;

希望这对某人有所帮助...