2017-03-17 68 views
0

我们刚刚开始使用Application Insights。尽管主要针对在云中运行的应用程序构建,但我们也使用它来跟踪WPF客户端的一些使用统计信息。如何使用Application Insights覆盖或忽略cloud_RoleInstance

对于此安装,我们不想跟踪机器名称,因为它在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属性。

在此先感谢

回答

4

好吧,这是更容易比我想象:

telemetryClient.Context.Cloud.RoleInstance = CustomerId; 

希望这有助于有人...