Reputation: 99
We are hosting a SaaS application and enabled the app Insight Telemetry in the Portal to track the runtime logs. It is simple configuration from Visual studio and works fine.
We need to enable App insight telemetry data capture based on the Tenant. Ex. My application is a multi tenant application and will be hosted once with different host names.So, I want to enable App insight for few tenants only. How to control this through code.
I have added this code in my appStart and it worked fine. But I want to enable/disable based on the host name in the URL
`
[Conditional("DEBUG")]
private static void DisableApplicationInsightsOnDebug()
{
TelemetryConfiguration.Active.DisableTelemetry = true;
}
`
Upvotes: 0
Views: 72
Reputation: 2456
It appears what you would like to do is to enable Application Insights conditionally on some instances of your application. This is best handled with a configuration setting, either by using web.config transform or by configuration settings for cloud roles.
You can do it in runtime, however you can only determine the host name once you have your first request. Example. I wouldn't recommend this because your application may likely by issuing a lot of telemetry before the first request and you would like to have your ON/OFF rule apply to this telemetry as well. So deployment configuration setting would be the best approach.
Upvotes: 1