-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deserialization policy consider 304 as an error leading to a telemetry exception being recorded #32454
Comments
My understanding is that 304 gets modeled as an error since the spec for downloadBlob only specifies responses for 200 and 206: https://github.com/Azure/azure-rest-api-specs/blob/b478dcdabacb37945ff89daa0eda1ae1afc98db4/specification/storage/data-plane/Microsoft.BlobStorage/stable/2025-01-05/blob.json#L2698 Since the default response is a |
Sorry, GitHub helpfully sent my response while I was in the middle of typing it. I don't think we can change the API contract for Storage methods that use conditional requests, but I am curious how AppInsights is hooking this, if it's on exceptions being created/thrown that's going to cause problems whenever exceptions are used for control flow |
@xirzec @Apokalypt If a REST error is thrown and bubbles up to the top level of the application, I'd expect OpenTelemetry to create an exception record that we then export to Application Insights the same way as any unhandled exception. This seems like it'd be expected in the event of a "real" REST error. So apart for some special logic for 304s, I'm not sure if this would be considered "unexpected" behavior. Should be solvable by catching 304s on the client side for now, but strange to have that response code count as an "exception" at all. |
@JacksonWeber when you are talking about "client side" is it on Azure's SDK code using your internal library or on my code when I use the library ? |
@Apokalypt Just as an interim solution to avoid the unwanted exception telemetry, I was suggesting implementing a catch statement here in your code. |
This is exactly what is done, but in fact the exception is added to the span from the library code itself (before I can catch it). To add more detail to what's going on, because I was able to dig a little today |
@maorleger Any thoughts on this? I think we ended up in this place because Storage didn't originally have support for conditional requests and when they added it after the fact, we didn't have a non-breaking way to describe the result without throwing an exception. |
I don't have a lot of context for the history here but if I understand correctly:
Is that right? If so (and please correct anything I was mistaken on) I can think of a few options (just brainstorming any and all ideas no matter how silly):
Out of these I think:
IMO if this is truly a unique case due to needing to maintain backwards compatibility in storage-blob's |
@maorleger we do not have the same problem with Here is a screenshots of all spans created by Azure SDK (the last one is created by http-instrumentation) while trying to get a key in the App Configuration with the SDK |
Got it, thanks @Apokalypt ! In that case, what we can do in const { span, updatedOptions } = tracingClient.startSpan("BlobClient-download", options);
return tracingClient.withContext(updatedOptions.tracingOptions.tracingContext, async () => {
try {
const result = undefined as any; // TODO: to be replaced with the current `download` implementation
span.setStatus({ status: "success" });
return result;
} catch (err: any) {
if (isActualError(err)) { // TODO: to be implemented
span.setStatus({
status: "error",
error: err,
});
}
throw err;
} finally {
span.end();
}
}) This allows some customization and control over the span's status. @xirzec curious if this resonates with you or if I missed something obvious? Any other places where 304's bubble up for backwards compat or other reasons? If we have a wider need for this customization we can consider adding an |
Describe the bug
The deserialization policy implemented in @azure/core-client considers any request with a status code not between 200 and 300 as an error which seems to be a good option. However, due to this behaviour each time an API answers 304 we are seing in Application Insights an exception which is not an expected behavior as a 304 is clearly expected
To Reproduce
ifNoneMatch
in order to receive 304Expected behavior
HTTP calls with status code equals to 304 should not generate a telemetry exception
Screenshots
Additional context
N/A
The text was updated successfully, but these errors were encountered: