Is it possible to provide a working JAVA example like the one in this post? View POST request body in Application Insights
Thanks for support
Is it possible to provide a working JAVA example like the one in this post? View POST request body in Application Insights
Thanks for support
TelemetryModules track various data w.r.t HTTP request and send the same to AI servers as RequestTelemetry. In order to track any custom HTTP parameters one has to create a new TelemetryModule by Implementing WebTelemetryModule and TelemetryModule interface that comes part of app insight sdk.
Here is the sample implementation.
WebTelemetry modules are the ones that has access to the HttpRequest and HttpResponse objects in the Request lifecycle. Basically AI collects the request telemetry by registering a Servlet fitler and onBeginRequest gets called before the actual request is processed and onEndRequest gets called after the request is processed.
Now register the module in ApplicationInsights.xml file
<TelemetryModules>
<Add type="com.ai.demo.CustomHttpTelemetryModule"/>
<Add type="com.microsoft.applicationinsights.web.extensibility.modules.WebRequestTrackingTelemetryModule"/>
<Add type="com.microsoft.applicationinsights.web.extensibility.modules.WebSessionTrackingTelemetryModule"/>
<Add type="com.microsoft.applicationinsights.web.extensibility.modules.WebUserTrackingTelemetryModule"/>
</TelemetryModules>
Please note that, i have registered my TelemetryModule before all the default telemetries, because if you register your telemetry after WebRequestTelemetryModule then anything that you set in OnEndRequest will not be passed upon because WebRequestTelemetryModule makes trackRequest in its onEndRequest method. Any changes made post the trackRequest() call will not be reflected in AI portal.
TelemetryModules are executed in the order they are defined in the ApplicationInsights.xml file.
Integrating App Insights is pretty straight forward and the relevant documentation about the same can be found here.
https://learn.microsoft.com/en-us/azure/azure-monitor/app/java-get-started
Hope it helps.