[BUG] AzureMonitorExporter marks 404 response as errors, even if explicitly marked as successful in OpenTelemetry #41993
Labels
Client
This issue points to a problem in the data-plane of the library.
customer-reported
Issues that are reported by GitHub users external to the Azure organization.
Monitor - Exporter
Monitor OpenTelemetry Exporter
needs-team-attention
Workflow: This issue needs attention from Azure service team or SDK team
question
The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Service Attention
Workflow: This issue is responsible by Azure service team.
Library name and version
Azure.Monitor.OpenTelemetry.Exporter
Describe the bug
My webapi yields a 404 response when the requested data cannot be found. In my case, this is not supposed to be marked as an error when exporting the OpenTelemetry data to ApplicationInsights.
As suggested in various other places, I have added an
EnrichWithHttpResponse
to theAddAspNetCoreInstrumentation
to manually change the activity's status toActivityStatusCode.Ok
.However, I'm still getting my 404 responses marked as errors in ApplicationInsights, even though the console exporter clearly shows the status of the activity to be marked as successful.
Expected behavior
I would expect the manually set
activity.Status
to be respected here, rather than it being overridden by interpreting the response code. It would still make sense to look at the response code when the value ofactivity.Status
isActivityStatusCode.Unset
, but not when theactivity.Status
is set toAcitivityStatusCode.Ok
.Actual behavior
In the ApplicationInsights exporter, the
Activity
containing the 404 response is transformed into aRequestData
, where theSuccess
property is determined by theIsSuccess
function.azure-sdk-for-net/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Customizations/Models/RequestData.cs
Lines 54 to 67 in a18e701
Since the operationType is an http call and the response code is set to 404, the if-branch applies, evaluating the value for
isSuccessStatusCode
tofalse
and making the function returnfalse
, even thoughactivity.Status != ActivityStatusCode.Error
evaluates totrue
.In this
IsSuccess
function is where I would expect the predeterminedactivity.Status
to be respected. Perhaps the function should be something likeReproduction Steps
See bug description
Environment
No response
The text was updated successfully, but these errors were encountered: