Skip to content
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

[BUG] BlobBaseClient.Exists always logs exceptions to App Insights when the blob does not exist. #18592

Closed
mrpmorris opened this issue Feb 9, 2021 · 16 comments · Fixed by #33639
Assignees
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved. 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. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team Service Attention Workflow: This issue is responsible by Azure service team. Storage Storage Service (Queues, Blobs, Files)
Milestone

Comments

@mrpmorris
Copy link

Describe the bug
BlobBaseClient.Exists files lots of false exceptions in App Insights when the blob does not exist.

Expected behavior
Checking if a blob exists should simply return false, not log an exception in App Insights.

Actual behavior (include Exception or Stack Trace)
App Insights is littered with false-positive exceptions due to a 404 response code to a HEAD request.

To Reproduce
Steps to reproduce the behavior (include a code snippet, screenshot, or any additional information that might help us reproduce the issue)

  1. Create an app that connects to a valid blob storage
  2. Enable AppInsights
  3. Access BlobBaseClient.Exists for a blob you know does not exist
  4. Look in AppInsights

Environment:

  • Name and version of the Library package used: Azure.Storage.Blobs 12.4.4
  • Hosting platform or OS and .NET runtime version: Azure Function app (net core 3.1)

The problem seems to be here

throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);

The code throws an exception for anything other than a 200 response - but 404 is not an exceptional response, it is very much expected - in fact, I expect to call it for non-existent blobs more often than any other blob scenario.

Ultimately, the exception is swallowed here
https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/storage/Azure.Storage.Blobs/src/BlobBaseClient.cs#L2952

But, by this point in time, the exception has already been logged to App Insights.

@ghost ghost added needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Feb 9, 2021
@jsquire jsquire added Client This issue points to a problem in the data-plane of the library. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team Service Attention Workflow: This issue is responsible by Azure service team. Storage Storage Service (Queues, Blobs, Files) labels Feb 9, 2021
@ghost ghost removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Feb 9, 2021
@ghost
Copy link

ghost commented Feb 9, 2021

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @xgithubtriage.

Issue Details

Describe the bug
BlobBaseClient.Exists files lots of false exceptions in App Insights when the blob does not exist.

Expected behavior
Checking if a blob exists should simply return false, not log an exception in App Insights.

Actual behavior (include Exception or Stack Trace)
App Insights is littered with false-positive exceptions due to a 404 response code to a HEAD request.

To Reproduce
Steps to reproduce the behavior (include a code snippet, screenshot, or any additional information that might help us reproduce the issue)

  1. Create an app that connects to a valid blob storage
  2. Enable AppInsights
  3. Access BlobBaseClient.Exists for a blob you know does not exist
  4. Look in AppInsights

Environment:

  • Name and version of the Library package used: Azure.Storage.Blobs 12.4.4
  • Hosting platform or OS and .NET runtime version: Azure Function app (net core 3.1)

The problem seems to be here

throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);

The code throws an exception for anything other than a 200 response - but 404 is not an exceptional response, it is very much expected - in fact, I expect to call it for non-existent blobs more often than any other blob scenario.

Ultimately, the exception is swallowed here
https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/storage/Azure.Storage.Blobs/src/BlobBaseClient.cs#L2952

But, by this point in time, the exception has already been logged to App Insights.

Author: mrpmorris
Assignees: -
Labels:

Client, Service Attention, Storage, customer-reported, needs-team-attention, needs-triage, question

Milestone: -

@jsquire
Copy link
Member

jsquire commented Feb 9, 2021

//cc: @tg-msft, as he was involved in an earlier discussion on this topic.

@jsquire
Copy link
Member

jsquire commented Feb 9, 2021

Thank you for your feedback. Tagging and routing to the team best able to assist.

@tg-msft
Copy link
Member

tg-msft commented Feb 9, 2021

This is waiting on #9934.

@janid1967
Copy link

I am experiencing the same problem and looking forward to a fix of this

@seanmcc-msft
Copy link
Member

@tg-msft, what is the status of #9934 ?

@tg-msft
Copy link
Member

tg-msft commented Apr 7, 2021

Last I heard, we're still officially waiting for an answer from the Observability folks. +@pakrym who recently removed some noise for CreateIfNotExists calls and can comment further. I don't think his recent change would help with BlobBaseClient.Exists though because we don't add any conditional headers to the request.

@pakrym
Copy link
Contributor

pakrym commented Apr 7, 2021

We haven't gotten clear guidance but I think we can still make progress on our own. We are going to start with fixing the CreateIfNotExists and then look into adding support to pass ResponseClassifier to the code-generated methods. That way we can create and pass custom classifiers to calls that return expected 404s.

@amishra-dev amishra-dev added bug This issue requires a change to an existing behavior in the product in order to be resolved. and removed question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Jun 2, 2021
@jsquire jsquire added this to the Backlog milestone Jun 7, 2021
@amnguye
Copy link
Member

amnguye commented Jul 8, 2021

@tg-msft @pakrym was there an update on #9934 yet ?
Also did CreateIfNotExists get fixed in regards to this issue?

@bruckGT1
Copy link

bruckGT1 commented Sep 1, 2021

I am also seeing this behavior. Any updates?

@amishra-dev
Copy link
Contributor

@pakrym Pavel will we be accepting the fix for #9934?

@tg-msft
Copy link
Member

tg-msft commented Dec 1, 2021

We don't want the fix at #9934 - we want to enable this via the work being done as part of #25626 that will be the standard pattern across the Azure SDK for .NET.

@amishra-dev
Copy link
Contributor

@tg-msft Ted any update on this? @jaschrep-msft can you please track this from our side?

@tg-msft
Copy link
Member

tg-msft commented Mar 1, 2022

Yes, the basic Azure.Core features are now in (but not shipped yet) and the generator has been updated to produce LLC protocol methods with a flag. That means you could start enabling this with a package reference, though it won't fully light up until a fix for Azure/autorest.csharp#2006 is committed and deployed.

@older
Copy link

older commented Sep 7, 2022

@tg-msft It looks like that AutoRest issue was fixed in March. Is this one going to be fixed as well?

@annelo-msft
Copy link
Member

The required APIs should be available now in Azure.Core to be able to implement this feature. In order to suppress distributed tracing for a given status code, AddClassifier() should be called on RequestContext prior to passing it to the method in question. An example can be found in the TableServiceClient here.

Please reach out with any remaining questions on implementation.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved. 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. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team Service Attention Workflow: This issue is responsible by Azure service team. Storage Storage Service (Queues, Blobs, Files)
Projects
None yet
Development

Successfully merging a pull request may close this issue.