-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[Draft] Minimize noisy Storage exceptions via DPG methods #27645
Conversation
// Get the blob properties, but don't throw any exceptions | ||
RequestContext context = new() | ||
{ | ||
ErrorOptions = ErrorOptions.NoThrow, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will suppress an exception from being thrown from within GetProperties, but error logging and tracing will still occur in the pipeline. In order to suppress those as well, you'll need to add classifiers using context.AddClassifier(...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sigh... That's what I get for rushing and only checking the Storage tests. I updated and verified that distributed tracing is clean too.
#define Fixed
using Azure;
using Azure.Core;
using Azure.Monitor.OpenTelemetry.Exporter;
using Azure.Storage.Blobs;
using Azure.Storage.Blobs.Models;
using Azure.Storage.Blobs.Specialized;
using OpenTelemetry.Trace;
using System.Diagnostics;
// Settings
const string StorageConnStr = "...";
const string AppInsightsConnStr = "...";
const string Name =
#if !Fixed
"Current";
#else
"Fixed";
#endif
// Collect telemetry in Azure Monitor
AppContext.SetSwitch("Azure.Experimental.EnableActivitySource", true);
using TracerProvider telemetry =
OpenTelemetry.Sdk
.CreateTracerProviderBuilder()
.AddSource(Name, "Azure.*")
.AddAzureMonitorTraceExporter(options => options.ConnectionString = AppInsightsConnStr)
.Build();
using ActivitySource source = new(Name);
using Activity? group = source.StartActivity(Name)!;
// Check if a fake blob exists
BlobClient fake = new BlobClient(StorageConnStr, "fakecontainer", "fakeblob");
Console.WriteLine($"Exists: {fake.Exists().Value}");
// Try acquiring a lease from a fake blob
#if !Fixed
try
{
BlobLease lease = fake.GetBlobLeaseClient().Acquire(TimeSpan.FromSeconds(15));
Console.WriteLine($"Lease: {lease.LeaseId}");
}
catch (RequestFailedException ex)
{
Console.WriteLine($"Failed to obtain lease!\n{ex}");
}
#else
RequestContext context =
new RequestContext() { ErrorOptions = ErrorOptions.NoThrow }
.AddClassifier(404, BlobErrorCode.BlobNotFound.ToString(), false)
.AddClassifier(404, BlobErrorCode.ContainerNotFound.ToString(), false)
.AddClassifier(409, BlobErrorCode.LeaseAlreadyPresent.ToString(), false);
Response<BlobLease> response =
fake.GetBlobLeaseClient().Acquire(
TimeSpan.FromSeconds(15),
conditions: null,
context);
Response raw = response.GetRawResponse();
if (raw.Status == 201)
{
Console.WriteLine($"Lease: {response.Value.LeaseId}");
}
else
{
Console.WriteLine($"Failed to obtain lease!\n{raw.Content.ToString()}");
}
#endif
@@ -1578,7 +1578,9 @@ public partial class BlobLeaseClient | |||
protected virtual Azure.Storage.Blobs.BlobContainerClient BlobContainerClient { get { throw null; } } | |||
public virtual string LeaseId { get { throw null; } } | |||
public System.Uri Uri { get { throw null; } } | |||
public virtual Azure.Response<Azure.Storage.Blobs.Models.BlobLease> Acquire(System.TimeSpan duration, Azure.RequestConditions conditions, Azure.RequestContext context) { throw null; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do we determine that we want to add RequestContext
to HLC methods vs using it internally.
I.e. why this instead of AcquireIfNotYetAcuired
API that uses RequestContext
internally?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it's not really doing AcquireIfNotYetAcquired
. It's doing AcquireIfBlobNotFoundOrContainerNotFoundOrLeaseAlreadyAcquired
and we don't want to add an overload for that specific, non-general scenario.
.AddClassifier(404, BlobErrorCode.ContainerNotFound.ToString(), false); | ||
Response<BlobLease> response = | ||
await blob.GetBlobLeaseClient() | ||
.AcquireAsync(LeasePeriod, conditions: null, context) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If BlockBlobClient is using ClientDiagnostics internally to create a RequestFailedException, adding these classifiers should be enough to suppress any unwanted errors while preserving correct exception creation.
Hi @tg-msft. Thank you for your interest in helping to improve the Azure SDK experience and for your contribution. We've noticed that there hasn't been recent engagement on this pull request. If this is still an active work stream, please let us know by pushing some changes or leaving a comment. Otherwise, we'll close this out in 7 days. |
Be gone from here, bot. |
Hi @tg-msft. Thank you for your interest in helping to improve the Azure SDK experience and for your contribution. We've noticed that there hasn't been recent engagement on this pull request. If this is still an active work stream, please let us know by pushing some changes or leaving a comment. Otherwise, we'll close this out in 7 days. |
Hi @tg-msft. Thank you for your contribution. Since there hasn't been recent engagement, we're going to close this out. Feel free to respond with a comment containing "/reopen" if you'd like to continue working on these changes. Please be sure to use the command to reopen or remove the "no-recent-activity" label; otherwise, this is likely to be closed again with the next cleanup pass. |
API change check APIView has identified API level changes in this PR and created following API reviews. |
Hi @tg-msft. Thank you for your interest in helping to improve the Azure SDK experience and for your contribution. We've noticed that there hasn't been recent engagement on this pull request. If this is still an active work stream, please let us know by pushing some changes or leaving a comment. Otherwise, we'll close this out in 7 days. |
Hi @tg-msft. Thank you for your contribution. Since there hasn't been recent engagement, we're going to close this out. Feel free to respond with a comment containing "/reopen" if you'd like to continue working on these changes. Please be sure to use the command to reopen or remove the "no-recent-activity" label; otherwise, this is likely to be closed again with the next cleanup pass. |
This shows how we can reduce logging noise for expected failures by using DPG methods from HLCs. #25626 is tracking the meta issue, but this is a proof of concept for both internal only (like BlobClient.Exists for #18592) and externally visible (like BlobLeaseClient.Acquire for #21511) cases.
This is currently blocked on #27614 before we can ship it.
There are also a few tests in DataLake like FileClientTest.ExistsAsync_CPK complaining about not matching the recordings, but it's difficult to debug at the moment because of a known issue in the test proxy. I'm ignoring those for the moment.