ApplicationInsights-dotnet icon indicating copy to clipboard operation
ApplicationInsights-dotnet copied to clipboard

Setting OperationTelemetry.Success to false without setting ResponseCode causes the service to silently drop your events

Open nerdile opened this issue 3 years ago • 3 comments

  • 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();

nerdile avatar May 01 '21 00:05 nerdile

https://github.com/microsoft/ApplicationInsights-dotnet/issues/2082 possible duplicate

cijothomas avatar May 05 '21 04:05 cijothomas

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.

DJ4ddi avatar Nov 25 '21 15:11 DJ4ddi

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.

github-actions[bot] avatar Sep 22 '22 00:09 github-actions[bot]