ApplicationInsights-dotnet
ApplicationInsights-dotnet copied to clipboard
AI (Internal): [Microsoft-ApplicationInsights-Core] Operation to stop does not match the current operation. Telemetry is not tracked.
I get the following in app insights:
AI (Internal): [Microsoft-ApplicationInsights-Core] Operation to stop does not match the current operation. Telemetry is not tracked.
This is documented as a known issue?:
https://docs.microsoft.com/en-us/azure/azure-monitor/app/custom-operations-tracking#parallel-operations-processing-and-tracking
The issue being that a second operationholder should call stopoperation before the firstoperation calls it. Why can't this be solved using AsyncLocal tracking the operation that is currently in scope?
In my setup I have a async operation (DoSomething) that needs to measure it's duration. For it to be measured I wrap it inside a measurement task (MeasureTask)
public Task MeasuredTask(Func<Task> task, IOperationHolder<DependencyTelemetry> operationHolder)
{
async Task result()
{
using (operationHolder)
{
await task();
}
}
return result();
}
public Task DoSomething()
{
var operationHolder = _telemetryClient.StartOperation("DoSomething");
// sync code that needs to be measured also.
async Task result()
{
await Task.Delay(1000);
}
return MeasuredTask(() => result(), operationHolder);
}
The DoSomething is called many times where Task.WhenAll(...do many somethings...)
Is it possible to fix? Should I change my setup such that startoperation is only called inside the measureTask method?
This issue is stale because it has been open 300 days with no activity. Remove stale label or this will be closed in 7 days. Commenting will instruct the bot to automatically remove the label.
Please remove the stale label.
This issue is stale because it has been open 300 days with no activity. Remove stale label or this will be closed in 7 days. Commenting will instruct the bot to automatically remove the label.
Why even bother.