When you use the default configuration in Application Insights, the default role name (on-premise) used is the name of your Application Insights resource:
This is not that meaningful especially because right now our frontend and backend telemetry is shown together. Let’s fix this by introducing a TelemetryInitializer. In this TelemetryInitializer we update the RoleName:
- Create an initializer in both the frontend and backend project:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ServiceNameInitializer : ITelemetryInitializer | |
{ | |
public void Initialize(ITelemetry telemetry) | |
{ | |
telemetry.Context.Cloud.RoleName = "FrontEndApp"; | |
} | |
} |
- Don’t forget to change the role name accordingly.
- Load this initializer in your global.asax:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TelemetryConfiguration.Active.TelemetryInitializers | |
.Add(new ServiceNameInitializer()); |
· Run the application again
Remark: You’ll have to wait some time before the updated names show up on the Application map