How to ignore localhost in Azure applications

I recently started posting my first application. I went ahead and activated application analysis, which, in my opinion, is of great value. However, I get statistics that come from the developer, for example, the logs write entries from localhost: xxxx. I am sure there is a way to disable this. Can someone give me some pointers please?

+5
source share
2 answers
  • You can filter the telemetry already collected, which you get with F5 in the user interface, since it has the property IsDeveloperMode = true
  • You can have a web.config conversion that removes the Insight module from Web.debug.config and leaves it only in the web.release.config file (if you only have automatic build properties)
  • You can remove the key from the configuration and set it only for the release version in the code: TelemetryConfiguration.Active.InsrumentationKey = "MyKey" (if you do not provide iKey for debugging, you can still see all the telemetry in the AI ​​center in VS 2015)
  • You can use different iKeys to debug and release again by setting it to code
  • You can completely disable ApplicationInsights in debugging by setting TelemetryConfiguration.Active.DisableTelemetry = true
+7
source

You can also filter localhost telemetry using the TelemetryProcessor (if you are using the latest (pre-release version of the Application Insights Web SDK). Here is an example. Add this class to your project:

public class LocalHostTelemetryFilter : ITelemetryProcessor { private ITelemetryProcessor next; public LocalHostTelemetryFilter(ITelemetryProcessor next) { this.next = next; } public void Process(ITelemetry item) { var requestTelemetry = item as RequestTelemetry; if (requestTelemetry != null && requestTelemetry.Url.Host.Equals("localhost", StringComparer.OrdinalIgnoreCase)) { return; } else { this.next.Process(item); } } } 

And then register it in ApplicationInsights.config:

 <TelemetryProcessors> <Add Type="LocalhostFilterSample.LocalHostTelemetryFilter, LocalHostFilterSample"/> </TelemetryProcessors> 
+9
source

Source: https://habr.com/ru/post/1242901/


All Articles