0
votes

I am adding few custom properties to the RequestTelemetry object as below

Java Web app

RequestTelemetry.getProperties.put(key,value);

But the same doesn't reflect in the portal.

So i created a new telemetryClient and invoked telemettyClient.trackRequest() but it creates a duplicate request entry in portal.

Is there a way to achieve the same without duplicating the telemetry object.

TIA

2

2 Answers

2
votes

Telemetry Modules are the only place where we get access to http requests response objects in AI Java Sdk. Here's a blog I wrote that explains how to send custom http data via request telemetry

https://dtechonline.wordpress.com

1
votes

There's a HttpContext extension method that gets you the current request telemetry:

System.Web.HttpContextExtension.GetRequestTelemetry

https://github.com/Microsoft/ApplicationInsights-dotnet-server/blob/master/Src/Web/Web.Shared.Net/HttpContextExtension.cs

you could use that to set properties on that specific request.

Or, you could implement a TelemetryInitializer that allows you to attach more properties/etc to any and all telemetry being generated, and just look at the RequestTelemetry items that go by.