Linking telemetry in a .NET Framework Console App
I am using app insights in a .NET Framework Console app
It is not possible for me to use Microsoft.ApplicationInsights.WorkerService so instead I am following this documentation
https://docs.microsoft.com/en-us/azure/azure-monitor/app/console
I can not find any way to link telemetry using operationid/parentid etc
A simple version of the code is as follows
class Program
{
static void Main(string[] args)
{
TelemetryConfiguration configuration = TelemetryConfiguration.CreateDefault();
configuration.InstrumentationKey = "xxxxxxxxxxxxxxxxxxxxxxx";
var telemetryClient = new TelemetryClient(configuration);
telemetryClient.TrackEvent("Example event");
telemetryClient.TrackTrace("Example trace");
telemetryClient.Flush();
Task.Delay(5000).Wait();
}
}
I would like the custom event and the trace linked together. I have tried using OperationCorrelationTelemetryInitializer both from within code and from ApplicationInsights.config but the event and trace don't seem to be logged with any operationid or parentid.
Is telemetry linking possible in this scenario and if so can you provide sample code?
The events must be under a common operation to be correlated. One example of achieving it is shown below.
using (telemetryClient.StartOperation<RequestTelemetry>("operation"))
{
telemetryClient.TrackEvent("Event1");
telemetryClient.TrackEvent("Event2");
}
yes this works and looks promising, thankyou.