ApplicationInsights-dotnet
ApplicationInsights-dotnet copied to clipboard
Setting OperationTelemetry.Success to false without setting ResponseCode causes the service to silently drop your events
- Runtime version netcoreapp3.1, however this appears to be service-side
- Hosting environment: Windows
Describe the bug
When using the TelemetryClient.StartOperation/StopOperation() pattern, if you set the operationTelemetry.Success = false, without setting operationTelemetry.ResponseCode, the event is successfully uploaded to Azure Application Insights, but then it is silently dropped from metrics and log analytics. If you set operationTelemetry.ResponseCode to a non-null value, then the events are available.
This is problematic because many of the code samples show setting Success == false without setting any ResponseCode, and this requirement is not called out in the SDK documentation.
Perhaps the SDK could automatically set this to a non-null value when Success is set to false.
Note: Using _telemetry.TrackException() does not set Success or ResponseCode. Perhaps operation should have its own TrackException, or there should be a StopOperation(Operation op, Exception ex) overload?
To Reproduce
using var operation = telemetryClient.StartOperation<RequestTelemetry>("Example"); operation.Telemetry.Success = false; telemetryClient.StopOperation(operation); telemetryClient.Flush();
https://github.com/microsoft/ApplicationInsights-dotnet/issues/2082 possible duplicate
Seeing the same issue in a similar pipeline with .NET 4.7.2 (AI 2.19.0).
In my case, I'm using a telemetry initializer to set the success property of RequestTelemetry
items to false based on context information. For the local pipeline (console tracing), the request shows up correctly and with the correct result. For the remote pipeline (server telemetry channel), the request disappears (its children can still be found under the parent operation).
Setting a response code, e.g. "500", appears to resolve the problem.
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.