Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set cloud_RoleName in app insight from Angular

In services of asp.net we can set cloud_rolename for app insight. Using this our services team tracks error in app insight. How can i set it from angular. This is how i am running app insight in angular:

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();

}

like image 455
winterishere Avatar asked Oct 23 '25 02:10

winterishere


1 Answers

You can use Telemetry Initializers, the sample code:

var telemetryInitializer = (envelope) => {
  envelope.tags["ai.cloud.role"] = "your role name";
  envelope.tags["ai.cloud.roleInstance"] = "your role instance";
}
appInsights.addTelemetryInitializer(telemetryInitializer);
like image 68
Ivan Yang Avatar answered Oct 25 '25 15:10

Ivan Yang