在 Angular 的应用洞察中设置 cloud_RoleName

win*_*ere 4 azure azure-application-insights angular

在asp.net的服务中,我们可以为应用程序洞察设置cloud_rolename。使用此功能,我们的服务团队可以跟踪应用程序洞察中的错误。我如何从角度设置它。这就是我以角度运行应用程序洞察的方式:

export class MonitoringService {
private appInsights: ApplicationInsights;
 constructor(private router: Router) {
  this.appInsights = new ApplicationInsights({
   config: {
     instrumentationKey: environment.appInsights.instrumentationKey,
  },
});
this.appInsights.loadAppInsights();
this.loadCustomTelemetryProperties();
this.createRouterSubscription();
Run Code Online (Sandbox Code Playgroud)

}

Iva*_*ang 5

您可以使用Telemetry Initializers,示例代码:

var telemetryInitializer = (envelope) => {
  envelope.tags["ai.cloud.role"] = "your role name";
  envelope.tags["ai.cloud.roleInstance"] = "your role instance";
}
appInsights.addTelemetryInitializer(telemetryInitializer);
Run Code Online (Sandbox Code Playgroud)