From eeba8a5beac2eb79a1e2d80a1390464992c910e9 Mon Sep 17 00:00:00 2001 From: Christopher Scott Date: Mon, 8 Jun 2020 17:54:18 -0500 Subject: [PATCH 1/2] Fixup diagnostic scopes --- .../Azure.Data.Tables/src/AssemblyInfo.cs | 1 + .../src/Azure.Data.Tables.csproj | 1 + .../Azure.Data.Tables/src/TableClient.cs | 400 +++++++++++++++--- .../src/TableServiceClient.cs | 97 ++++- 4 files changed, 410 insertions(+), 89 deletions(-) diff --git a/sdk/tables/Azure.Data.Tables/src/AssemblyInfo.cs b/sdk/tables/Azure.Data.Tables/src/AssemblyInfo.cs index 5eb57e8bb3394..17218ca5a1684 100644 --- a/sdk/tables/Azure.Data.Tables/src/AssemblyInfo.cs +++ b/sdk/tables/Azure.Data.Tables/src/AssemblyInfo.cs @@ -16,3 +16,4 @@ "753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46" + "ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484c" + "f7045cc7")] +[assembly: Azure.Core.AzureResourceProviderNamespace("Microsoft.Tables")] diff --git a/sdk/tables/Azure.Data.Tables/src/Azure.Data.Tables.csproj b/sdk/tables/Azure.Data.Tables/src/Azure.Data.Tables.csproj index 7111cde88b05a..9b50e6dd97176 100644 --- a/sdk/tables/Azure.Data.Tables/src/Azure.Data.Tables.csproj +++ b/sdk/tables/Azure.Data.Tables/src/Azure.Data.Tables.csproj @@ -21,6 +21,7 @@ + diff --git a/sdk/tables/Azure.Data.Tables/src/TableClient.cs b/sdk/tables/Azure.Data.Tables/src/TableClient.cs index 78f68ac805a3d..e0ae3dbd0807b 100644 --- a/sdk/tables/Azure.Data.Tables/src/TableClient.cs +++ b/sdk/tables/Azure.Data.Tables/src/TableClient.cs @@ -8,6 +8,7 @@ using System.Threading; using System.Threading.Tasks; using Azure.Core; +using Azure.Core.Pipeline; using Azure.Data.Tables.Models; using Azure.Data.Tables.Queryable; using Azure.Data.Tables.Sas; @@ -22,16 +23,18 @@ public class TableClient { private readonly string _table; private readonly OdataMetadataFormat _format; + private readonly ClientDiagnostics _diagnostics; private readonly TableRestClient _tableOperations; private readonly string _version; private readonly bool _isPremiumEndpoint; - internal TableClient(string table, TableRestClient tableOperations, string version, bool isPremiumEndpoint) + internal TableClient(string table, TableRestClient tableOperations, string version, ClientDiagnostics diagnostics, bool isPremiumEndpoint) { _tableOperations = tableOperations; _version = version; _table = table; _format = OdataMetadataFormat.ApplicationJsonOdataFullmetadata; + _diagnostics = diagnostics; _isPremiumEndpoint = isPremiumEndpoint; } @@ -70,11 +73,20 @@ public virtual TableSasBuilder GetSasBuilder(string rawPermissions, DateTimeOffs /// /// A controlling the request lifetime. /// - [ForwardsClientCalls] public virtual Response Create(CancellationToken cancellationToken = default) { - var response = _tableOperations.Create(new TableProperties(_table), null, queryOptions: new QueryOptions() { Format = _format }, cancellationToken: cancellationToken); + using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableClient)}.{nameof(Create)}"); + scope.Start(); + try + { + var response = _tableOperations.Create(new TableProperties(_table), null, queryOptions: new QueryOptions() { Format = _format }, cancellationToken: cancellationToken); return Response.FromValue(response.Value as TableItem, response.GetRawResponse()); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } } /// @@ -82,11 +94,20 @@ public virtual Response Create(CancellationToken cancellationToken = /// /// A controlling the request lifetime. /// - [ForwardsClientCalls] public virtual async Task> CreateAsync(CancellationToken cancellationToken = default) { - var response = await _tableOperations.CreateAsync(new TableProperties(_table), null, queryOptions: new QueryOptions() { Format = _format }, cancellationToken: cancellationToken).ConfigureAwait(false); + using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableClient)}.{nameof(Create)}"); + scope.Start(); + try + { + var response = await _tableOperations.CreateAsync(new TableProperties(_table), null, queryOptions: new QueryOptions() { Format = _format }, cancellationToken: cancellationToken).ConfigureAwait(false); return Response.FromValue(response.Value as TableItem, response.GetRawResponse()); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } } /// @@ -95,12 +116,14 @@ public virtual async Task> CreateAsync(CancellationToken can /// The entity to insert. /// A controlling the request lifetime. /// The inserted Table entity. - [ForwardsClientCalls] public virtual async Task>> InsertAsync(IDictionary entity, CancellationToken cancellationToken = default) { Argument.AssertNotNull(entity, nameof(entity)); - - var response = await _tableOperations.InsertEntityAsync(_table, + using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableClient)}.{nameof(Insert)}"); + scope.Start(); + try + { + var response = await _tableOperations.InsertEntityAsync(_table, tableEntityProperties: entity.ToOdataAnnotatedDictionary(), queryOptions: new QueryOptions() { Format = _format }, cancellationToken: cancellationToken).ConfigureAwait(false); @@ -109,6 +132,12 @@ public virtual async Task>> InsertAs dict.CastAndRemoveAnnotations(); return Response.FromValue(new ReadOnlyDictionary(dict), response.GetRawResponse()); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } } /// @@ -117,12 +146,14 @@ public virtual async Task>> InsertAs /// The entity to insert. /// A controlling the request lifetime. /// The inserted Table entity. - [ForwardsClientCalls] public virtual Response> Insert(IDictionary entity, CancellationToken cancellationToken = default) { Argument.AssertNotNull(entity, nameof(entity)); - - var response = _tableOperations.InsertEntity(_table, + using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableClient)}.{nameof(Insert)}"); + scope.Start(); + try + { + var response = _tableOperations.InsertEntity(_table, tableEntityProperties: entity.ToOdataAnnotatedDictionary(), queryOptions: new QueryOptions() { Format = _format }, cancellationToken: cancellationToken); @@ -131,6 +162,12 @@ public virtual Response> Insert(IDictionary(dict), response.GetRawResponse()); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } } /// @@ -139,18 +176,26 @@ public virtual Response> Insert(IDictionaryThe entity to insert. /// A controlling the request lifetime. /// The inserted Table entity. - [ForwardsClientCalls] public virtual async Task> InsertAsync(T entity, CancellationToken cancellationToken = default) where T : TableEntity, new() { Argument.AssertNotNull(entity, nameof(entity)); - - var response = await _tableOperations.InsertEntityAsync(_table, + using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableClient)}.{nameof(Insert)}"); + scope.Start(); + try + { + var response = await _tableOperations.InsertEntityAsync(_table, tableEntityProperties: entity.ToOdataAnnotatedDictionary(), queryOptions: new QueryOptions() { Format = _format }, cancellationToken: cancellationToken).ConfigureAwait(false); var result = ((Dictionary)response.Value).ToTableEntity(); return Response.FromValue(result, response.GetRawResponse()); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } } /// @@ -159,18 +204,26 @@ public virtual Response> Insert(IDictionaryThe entity to insert. /// A controlling the request lifetime. /// The inserted Table entity. - [ForwardsClientCalls] public virtual Response Insert(T entity, CancellationToken cancellationToken = default) where T : TableEntity, new() { Argument.AssertNotNull(entity, nameof(entity)); - - var response = _tableOperations.InsertEntity(_table, + using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableClient)}.{nameof(Insert)}"); + scope.Start(); + try + { + var response = _tableOperations.InsertEntity(_table, tableEntityProperties: entity.ToOdataAnnotatedDictionary(), queryOptions: new QueryOptions() { Format = _format }, cancellationToken: cancellationToken); var result = ((Dictionary)response.Value).ToTableEntity(); return Response.FromValue(result, response.GetRawResponse()); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } } @@ -181,7 +234,6 @@ public virtual Response> Insert(IDictionaryThe entity to upsert. /// A controlling the request lifetime. /// The indicating the result of the operation. - [ForwardsClientCalls] public virtual async Task UpsertAsync(IDictionary entity, CancellationToken cancellationToken = default) { Argument.AssertNotNull(entity, nameof(entity)); @@ -197,12 +249,22 @@ public virtual async Task UpsertAsync(IDictionary enti throw new ArgumentException("The entity must contain a RowKey value", nameof(entity)); } - return await _tableOperations.UpdateEntityAsync(_table, + using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableClient)}.{nameof(Upsert)}"); + scope.Start(); + try + { + return await _tableOperations.UpdateEntityAsync(_table, partitionKey as string, rowKey as string, tableEntityProperties: entity.ToOdataAnnotatedDictionary(), queryOptions: new QueryOptions() { Format = _format }, cancellationToken: cancellationToken).ConfigureAwait(false); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } } /// @@ -211,7 +273,6 @@ public virtual async Task UpsertAsync(IDictionary enti /// The entity to upsert. /// A controlling the request lifetime. /// The indicating the result of the operation. - [ForwardsClientCalls] public virtual Response Upsert(IDictionary entity, CancellationToken cancellationToken = default) { Argument.AssertNotNull(entity, nameof(entity)); @@ -227,12 +288,22 @@ public virtual Response Upsert(IDictionary entity, CancellationT throw new ArgumentException("The entity must contain a RowKey value", nameof(entity)); } - return _tableOperations.UpdateEntity(_table, + using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableClient)}.{nameof(Upsert)}"); + scope.Start(); + try + { + return _tableOperations.UpdateEntity(_table, partitionKey as string, rowKey as string, tableEntityProperties: entity.ToOdataAnnotatedDictionary(), queryOptions: new QueryOptions() { Format = _format }, cancellationToken: cancellationToken); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } } /// @@ -241,18 +312,26 @@ public virtual Response Upsert(IDictionary entity, CancellationT /// The entity to upsert. /// A controlling the request lifetime. /// The indicating the result of the operation. - [ForwardsClientCalls] public virtual async Task UpsertAsync(T entity, CancellationToken cancellationToken = default) where T : TableEntity, new() { Argument.AssertNotNull(entity?.PartitionKey, nameof(entity.PartitionKey)); Argument.AssertNotNull(entity?.RowKey, nameof(entity.RowKey)); - - return await _tableOperations.UpdateEntityAsync(_table, + using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableClient)}.{nameof(Upsert)}"); + scope.Start(); + try + { + return await _tableOperations.UpdateEntityAsync(_table, entity.PartitionKey, entity.RowKey, tableEntityProperties: entity.ToOdataAnnotatedDictionary(), queryOptions: new QueryOptions() { Format = _format }, cancellationToken: cancellationToken).ConfigureAwait(false); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } } /// @@ -261,18 +340,26 @@ public virtual Response Upsert(IDictionary entity, CancellationT /// The entity to upsert. /// A controlling the request lifetime. /// The indicating the result of the operation. - [ForwardsClientCalls] public virtual Response Upsert(T entity, CancellationToken cancellationToken = default) where T : TableEntity, new() { Argument.AssertNotNull(entity?.PartitionKey, nameof(entity.PartitionKey)); Argument.AssertNotNull(entity?.RowKey, nameof(entity.RowKey)); - - return _tableOperations.UpdateEntity(_table, + using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableClient)}.{nameof(Upsert)}"); + scope.Start(); + try + { + return _tableOperations.UpdateEntity(_table, entity.PartitionKey, entity.RowKey, tableEntityProperties: entity.ToOdataAnnotatedDictionary(), queryOptions: new QueryOptions() { Format = _format }, cancellationToken: cancellationToken); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } } /// @@ -282,7 +369,6 @@ public virtual Response Upsert(IDictionary entity, CancellationT /// The ETag value to be used for optimistic concurrency. /// A controlling the request lifetime. /// The indicating the result of the operation. - [ForwardsClientCalls] public virtual async Task UpdateAsync(IDictionary entity, string eTag, CancellationToken cancellationToken = default) { Argument.AssertNotNull(entity, nameof(entity)); @@ -299,13 +385,23 @@ public virtual async Task UpdateAsync(IDictionary enti throw new ArgumentException("The entity must contain a RowKey value", nameof(entity)); } - return await _tableOperations.UpdateEntityAsync(_table, + using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableClient)}.{nameof(Update)}"); + scope.Start(); + try + { + return await _tableOperations.UpdateEntityAsync(_table, partitionKey as string, rowKey as string, tableEntityProperties: entity.ToOdataAnnotatedDictionary(), ifMatch: eTag, queryOptions: new QueryOptions() { Format = _format }, cancellationToken: cancellationToken).ConfigureAwait(false); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } } /// @@ -315,7 +411,6 @@ public virtual async Task UpdateAsync(IDictionary enti /// The ETag value to be used for optimistic concurrency. /// A controlling the request lifetime. /// The indicating the result of the operation. - [ForwardsClientCalls] public virtual Response Update(IDictionary entity, string eTag, CancellationToken cancellationToken = default) { Argument.AssertNotNull(entity, nameof(entity)); @@ -332,13 +427,23 @@ public virtual Response Update(IDictionary entity, string eTag, throw new ArgumentException("The entity must contain a RowKey value", nameof(entity)); } - return _tableOperations.UpdateEntity(_table, + using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableClient)}.{nameof(Update)}"); + scope.Start(); + try + { + return _tableOperations.UpdateEntity(_table, partitionKey as string, rowKey as string, tableEntityProperties: entity.ToOdataAnnotatedDictionary(), ifMatch: eTag, queryOptions: new QueryOptions() { Format = _format }, cancellationToken: cancellationToken); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } } /// @@ -348,7 +453,6 @@ public virtual Response Update(IDictionary entity, string eTag, /// The ETag value to be used for optimistic concurrency. /// A controlling the request lifetime. /// The indicating the result of the operation. - [ForwardsClientCalls] public virtual async Task MergeAsync(IDictionary entity, string eTag = null, CancellationToken cancellationToken = default) { Argument.AssertNotNull(entity, nameof(entity)); @@ -364,13 +468,23 @@ public virtual async Task MergeAsync(IDictionary entit throw new ArgumentException("The entity must contain a RowKey value", nameof(entity)); } - return (await _tableOperations.MergeEntityAsync(_table, + using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableClient)}.{nameof(Merge)}"); + scope.Start(); + try + { + return (await _tableOperations.MergeEntityAsync(_table, partitionKey as string, rowKey as string, tableEntityProperties: entity.ToOdataAnnotatedDictionary(), ifMatch: eTag, queryOptions: new QueryOptions() { Format = _format }, cancellationToken: cancellationToken).ConfigureAwait(false)).GetRawResponse(); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } } /// @@ -380,7 +494,6 @@ public virtual async Task MergeAsync(IDictionary entit /// The ETag value to be used for optimistic concurrency. /// A controlling the request lifetime. /// The indicating the result of the operation. - [ForwardsClientCalls] public virtual Response Merge(IDictionary entity, string eTag = null, CancellationToken cancellationToken = default) { Argument.AssertNotNull(entity, nameof(entity)); @@ -396,13 +509,23 @@ public virtual Response Merge(IDictionary entity, string eTag = throw new ArgumentException("The entity must contain a RowKey value", nameof(entity)); } - return _tableOperations.MergeEntity(_table, + using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableClient)}.{nameof(Merge)}"); + scope.Start(); + try + { + return _tableOperations.MergeEntity(_table, partitionKey as string, rowKey as string, tableEntityProperties: entity.ToOdataAnnotatedDictionary(), ifMatch: eTag, queryOptions: new QueryOptions() { Format = _format }, cancellationToken: cancellationToken).GetRawResponse(); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } } /// @@ -413,10 +536,13 @@ public virtual Response Merge(IDictionary entity, string eTag = /// Returns the desired properties of an entity from the set. /// A controlling the request lifetime. /// - [ForwardsClientCalls] public virtual AsyncPageable> QueryAsync(string filter = null, int? top = null, string select = null, CancellationToken cancellationToken = default) { - return PageableHelpers.CreateAsyncEnumerable(async _ => + using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableClient)}.{nameof(Query)}"); + scope.Start(); + try + { + return PageableHelpers.CreateAsyncEnumerable(async _ => { var response = await _tableOperations.QueryEntitiesAsync( _table, @@ -445,6 +571,12 @@ public virtual AsyncPageable> QueryAsync(string filt CreateContinuationTokenFromHeaders(response.Headers), response.GetRawResponse()); }); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } } /// @@ -455,10 +587,13 @@ public virtual AsyncPageable> QueryAsync(string filt /// Returns the desired properties of an entity from the set. /// A controlling the request lifetime. - [ForwardsClientCalls] public virtual Pageable> Query(string filter = null, int? top = null, string select = null, CancellationToken cancellationToken = default) { - return PageableHelpers.CreateEnumerable(_ => + using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableClient)}.{nameof(Query)}"); + scope.Start(); + try + { + return PageableHelpers.CreateEnumerable(_ => { var response = _tableOperations.QueryEntities(_table, queryOptions: new QueryOptions() { Format = _format, Top = top, Filter = filter, Select = @select }, @@ -487,6 +622,12 @@ public virtual Pageable> Query(string filter = null, CreateContinuationTokenFromHeaders(response.Headers), response.GetRawResponse()); }); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } } /// @@ -497,12 +638,35 @@ public virtual Pageable> Query(string filter = null, /// Returns the desired properties of an entity from the set. /// A controlling the request lifetime. - [ForwardsClientCalls] - public virtual AsyncPageable> QueryAsync(Expression, bool>> filter, int? top = null, string select = null, CancellationToken cancellationToken = default) => - QueryAsync(Bind(filter), top, select, cancellationToken); + public virtual AsyncPageable> QueryAsync(Expression, bool>> filter, int? top = null, string select = null, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableClient)}.{nameof(Query)}"); + scope.Start(); + try + { + return QueryAsync(Bind(filter), top, select, cancellationToken); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } + } - public virtual Pageable> Query(Expression, bool>> filter, int? top = null, string select = null, CancellationToken cancellationToken = default) => - Query(Bind(filter), top, select, cancellationToken); + public virtual Pageable> Query(Expression, bool>> filter, int? top = null, string select = null, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableClient)}.{nameof(Query)}"); + scope.Start(); + try + { + return Query(Bind(filter), top, select, cancellationToken); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } + } /// /// Queries entities in the table. @@ -512,9 +676,20 @@ public virtual Pageable> Query(ExpressionReturns the desired properties of an entity from the set. /// A controlling the request lifetime. - [ForwardsClientCalls] - public virtual AsyncPageable QueryAsync(Expression> filter, int? top = null, string select = null, CancellationToken cancellationToken = default) where T : TableEntity, new() => - QueryAsync(Bind(filter), top, select, cancellationToken); + public virtual AsyncPageable QueryAsync(Expression> filter, int? top = null, string select = null, CancellationToken cancellationToken = default) where T : TableEntity, new() + { + using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableClient)}.{nameof(Query)}"); + scope.Start(); + try + { + return QueryAsync(Bind(filter), top, select, cancellationToken); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } + } /// /// Queries entities in the table. @@ -524,10 +699,13 @@ public virtual Pageable> Query(ExpressionReturns the desired properties of an entity from the set. /// A controlling the request lifetime. /// - [ForwardsClientCalls] public virtual AsyncPageable QueryAsync(string filter = null, int? top = null, string select = null, CancellationToken cancellationToken = default) where T : TableEntity, new() { - return PageableHelpers.CreateAsyncEnumerable(async _ => + using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableClient)}.{nameof(Query)}"); + scope.Start(); + try + { + return PageableHelpers.CreateAsyncEnumerable(async _ => { var response = await _tableOperations.QueryEntitiesAsync( _table, @@ -552,6 +730,12 @@ public virtual Pageable> Query(Expression @@ -562,9 +746,20 @@ public virtual Pageable> Query(ExpressionReturns the desired properties of an entity from the set. /// A controlling the request lifetime. - [ForwardsClientCalls] - public virtual Pageable Query(Expression> filter, int? top = null, string select = null, CancellationToken cancellationToken = default) where T : TableEntity, new() => - Query(Bind(filter), top, select, cancellationToken); + public virtual Pageable Query(Expression> filter, int? top = null, string select = null, CancellationToken cancellationToken = default) where T : TableEntity, new() + { + using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableClient)}.{nameof(Query)}"); + scope.Start(); + try + { + return Query(Bind(filter), top, select, cancellationToken); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } + } /// /// Queries entities in the table. @@ -574,10 +769,13 @@ public virtual Pageable> Query(ExpressionReturns the desired properties of an entity from the set. /// A controlling the request lifetime. - [ForwardsClientCalls] public virtual Pageable Query(string filter = null, int? top = null, string select = null, CancellationToken cancellationToken = default) where T : TableEntity, new() { - return PageableHelpers.CreateEnumerable((int? _) => + using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableClient)}.{nameof(Query)}"); + scope.Start(); + try + { + return PageableHelpers.CreateEnumerable((int? _) => { var response = _tableOperations.QueryEntities(_table, queryOptions: new QueryOptions() { Format = _format, Top = top, Filter = filter, Select = @select }, @@ -602,6 +800,12 @@ public virtual Pageable> Query(Expression @@ -612,18 +816,26 @@ public virtual Pageable> Query(ExpressionThe ETag value to be used for optimistic concurrency. /// A controlling the request lifetime. /// The indicating the result of the operation. - [ForwardsClientCalls] public virtual async Task DeleteAsync(string partitionKey, string rowKey, string eTag = "*", CancellationToken cancellationToken = default) { Argument.AssertNotNull(partitionKey, nameof(partitionKey)); Argument.AssertNotNull(rowKey, nameof(rowKey)); - - return await _tableOperations.DeleteEntityAsync(_table, + using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableClient)}.{nameof(Delete)}"); + scope.Start(); + try + { + return await _tableOperations.DeleteEntityAsync(_table, partitionKey, rowKey, ifMatch: eTag, queryOptions: new QueryOptions() { Format = _format }, cancellationToken: cancellationToken).ConfigureAwait(false); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } } /// @@ -634,40 +846,66 @@ public virtual async Task DeleteAsync(string partitionKey, string rowK /// The ETag value to be used for optimistic concurrency. The default is to delete unconditionally. /// A controlling the request lifetime. /// The indicating the result of the operation. - [ForwardsClientCalls] public virtual Response Delete(string partitionKey, string rowKey, string eTag = "*", CancellationToken cancellationToken = default) { Argument.AssertNotNull(partitionKey, nameof(partitionKey)); Argument.AssertNotNull(rowKey, nameof(rowKey)); - - return _tableOperations.DeleteEntity(_table, + using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableClient)}.{nameof(Delete)}"); + scope.Start(); + try + { + return _tableOperations.DeleteEntity(_table, partitionKey, rowKey, ifMatch: eTag, queryOptions: new QueryOptions() { Format = _format }, cancellationToken: cancellationToken); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } } /// Retrieves details about any stored access policies specified on the table that may be used with Shared Access Signatures. /// The The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for Queue Service Operations.. /// Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage analytics logging is enabled. /// The cancellation token to use. - [ForwardsClientCalls] public virtual async Task>> GetAccessPolicyAsync(int? timeout = null, string requestId = null, CancellationToken cancellationToken = default) { - var response = await _tableOperations.GetAccessPolicyAsync(_table, timeout, requestId, cancellationToken).ConfigureAwait(false); + using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableClient)}.{nameof(GetAccessPolicy)}"); + scope.Start(); + try + { + var response = await _tableOperations.GetAccessPolicyAsync(_table, timeout, requestId, cancellationToken).ConfigureAwait(false); return Response.FromValue(response.Value, response.GetRawResponse()); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } } /// Retrieves details about any stored access policies specified on the table that may be used with Shared Access Signatures. /// The The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for Queue Service Operations.. /// Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage analytics logging is enabled. /// The cancellation token to use. - [ForwardsClientCalls] public virtual Response> GetAccessPolicy(int? timeout = null, string requestId = null, CancellationToken cancellationToken = default) { - var response = _tableOperations.GetAccessPolicy(_table, timeout, requestId, cancellationToken); + using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableClient)}.{nameof(GetAccessPolicy)}"); + scope.Start(); + try + { + var response = _tableOperations.GetAccessPolicy(_table, timeout, requestId, cancellationToken); return Response.FromValue(response.Value, response.GetRawResponse()); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } } /// sets stored access policies for the table that may be used with Shared Access Signatures. @@ -675,18 +913,40 @@ public virtual Response> GetAccessPolicy(int? ti /// The The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for Queue Service Operations.. /// Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage analytics logging is enabled. /// The cancellation token to use. - [ForwardsClientCalls] - public virtual async Task SetAccessPolicyAsync(IEnumerable tableAcl = null, int? timeout = null, string requestId = null, CancellationToken cancellationToken = default) => - await _tableOperations.SetAccessPolicyAsync(_table, timeout, requestId, tableAcl, cancellationToken).ConfigureAwait(false); + public virtual async Task SetAccessPolicyAsync(IEnumerable tableAcl = null, int? timeout = null, string requestId = null, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableClient)}.{nameof(SetAccessPolicy)}"); + scope.Start(); + try + { + return await _tableOperations.SetAccessPolicyAsync(_table, timeout, requestId, tableAcl, cancellationToken).ConfigureAwait(false); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } + } /// sets stored access policies for the table that may be used with Shared Access Signatures. /// the access policies for the table. /// The The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for Queue Service Operations.. /// Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage analytics logging is enabled. /// The cancellation token to use. - [ForwardsClientCalls] - public virtual Response SetAccessPolicy(IEnumerable tableAcl, int? timeout = null, string requestId = null, CancellationToken cancellationToken = default) => - _tableOperations.SetAccessPolicy(_table, timeout, requestId, tableAcl, cancellationToken); + public virtual Response SetAccessPolicy(IEnumerable tableAcl, int? timeout = null, string requestId = null, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableClient)}.{nameof(SetAccessPolicy)}"); + scope.Start(); + try + { + return _tableOperations.SetAccessPolicy(_table, timeout, requestId, tableAcl, cancellationToken); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } + } internal ExpressionParser GetExpressionParser() { diff --git a/sdk/tables/Azure.Data.Tables/src/TableServiceClient.cs b/sdk/tables/Azure.Data.Tables/src/TableServiceClient.cs index 2a826302c57f4..8aa7e026e6979 100644 --- a/sdk/tables/Azure.Data.Tables/src/TableServiceClient.cs +++ b/sdk/tables/Azure.Data.Tables/src/TableServiceClient.cs @@ -13,6 +13,7 @@ namespace Azure.Data.Tables { public class TableServiceClient { + private readonly ClientDiagnostics _diagnostics; private readonly TableRestClient _tableOperations; private readonly OdataMetadataFormat _format = OdataMetadataFormat.ApplicationJsonOdataFullmetadata; private readonly string _version; @@ -60,8 +61,8 @@ internal TableServiceClient(Uri endpoint, TableSharedKeyPipelinePolicy policy, T pipeline = HttpPipelineBuilder.Build(options, policy); } - var diagnostics = new ClientDiagnostics(options); - _tableOperations = new TableRestClient(diagnostics, pipeline, endpointString); + _diagnostics = new ClientDiagnostics(options); + _tableOperations = new TableRestClient(_diagnostics, pipeline, endpointString); _version = options.VersionString; string absoluteUri = endpoint.OriginalString.ToLowerInvariant(); @@ -89,7 +90,7 @@ public virtual TableClient GetTableClient(string tableName) { Argument.AssertNotNull(tableName, nameof(tableName)); - return new TableClient(tableName, _tableOperations, _version, _isPremiumEndpoint); + return new TableClient(tableName, _tableOperations, _version, _diagnostics, _isPremiumEndpoint); } /// @@ -102,7 +103,11 @@ public virtual TableClient GetTableClient(string tableName) /// public virtual AsyncPageable GetTablesAsync(string select = null, string filter = null, int? top = null, CancellationToken cancellationToken = default) { - return PageableHelpers.CreateAsyncEnumerable(async _ => + using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableServiceClient)}.{nameof(GetTables)}"); + scope.Start(); + try + { + return PageableHelpers.CreateAsyncEnumerable(async _ => { var response = await _tableOperations.QueryAsync( null, @@ -119,6 +124,12 @@ public virtual AsyncPageable GetTablesAsync(string select = null, str cancellationToken).ConfigureAwait(false); return Page.FromValues(response.Value.Value, response.Headers.XMsContinuationNextTableName, response.GetRawResponse()); }); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } } /// @@ -131,7 +142,11 @@ public virtual AsyncPageable GetTablesAsync(string select = null, str /// public virtual Pageable GetTables(string select = null, string filter = null, int? top = null, CancellationToken cancellationToken = default) { - return PageableHelpers.CreateEnumerable(_ => + using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableServiceClient)}.{nameof(GetTables)}"); + scope.Start(); + try + { + return PageableHelpers.CreateEnumerable(_ => { var response = _tableOperations.Query( null, @@ -148,6 +163,12 @@ public virtual Pageable GetTables(string select = null, string filter cancellationToken); return Page.FromValues(response.Value.Value, response.Headers.XMsContinuationNextTableName, response.GetRawResponse()); }); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } } /// @@ -156,13 +177,21 @@ public virtual Pageable GetTables(string select = null, string filter /// The table name to create. /// A controlling the request lifetime. /// - [ForwardsClientCalls] public virtual Response CreateTable(string tableName, CancellationToken cancellationToken = default) { Argument.AssertNotNull(tableName, nameof(tableName)); - - var response = _tableOperations.Create(new TableProperties(tableName), null, queryOptions: new QueryOptions { Format = _format }, cancellationToken: cancellationToken); - return Response.FromValue(response.Value as TableItem, response.GetRawResponse()); + using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableServiceClient)}.{nameof(CreateTable)}"); + scope.Start(); + try + { + var response = _tableOperations.Create(new TableProperties(tableName), null, queryOptions: new QueryOptions { Format = _format }, cancellationToken: cancellationToken); + return Response.FromValue(response.Value as TableItem, response.GetRawResponse()); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } } /// @@ -171,13 +200,21 @@ public virtual Response CreateTable(string tableName, CancellationTok /// The table name to create. /// A controlling the request lifetime. /// - [ForwardsClientCalls] public virtual async Task> CreateTableAsync(string tableName, CancellationToken cancellationToken = default) { Argument.AssertNotNull(tableName, nameof(tableName)); - - var response = await _tableOperations.CreateAsync(new TableProperties(tableName), null, queryOptions: new QueryOptions { Format = _format }, cancellationToken: cancellationToken).ConfigureAwait(false); - return Response.FromValue(response.Value as TableItem, response.GetRawResponse()); + using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableServiceClient)}.{nameof(CreateTable)}"); + scope.Start(); + try + { + var response = await _tableOperations.CreateAsync(new TableProperties(tableName), null, queryOptions: new QueryOptions { Format = _format }, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(response.Value as TableItem, response.GetRawResponse()); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } } /// @@ -186,9 +223,20 @@ public virtual async Task> CreateTableAsync(string tableName /// The table name to create. /// A controlling the request lifetime. /// - [ForwardsClientCalls] - public virtual Response DeleteTable(string tableName, CancellationToken cancellationToken = default) => - _tableOperations.Delete(tableName, null, cancellationToken: cancellationToken); + public virtual Response DeleteTable(string tableName, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableServiceClient)}.{nameof(DeleteTable)}"); + scope.Start(); + try + { + return _tableOperations.Delete(tableName, null, cancellationToken: cancellationToken); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } + } /// /// Deletes a table in the storage account. @@ -196,8 +244,19 @@ public virtual Response DeleteTable(string tableName, CancellationToken cancella /// The table name to create. /// A controlling the request lifetime. /// - [ForwardsClientCalls] - public virtual async Task DeleteTableAsync(string tableName, CancellationToken cancellationToken = default) => - await _tableOperations.DeleteAsync(tableName, null, cancellationToken: cancellationToken).ConfigureAwait(false); + public virtual async Task DeleteTableAsync(string tableName, CancellationToken cancellationToken = default) + { + using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableServiceClient)}.{nameof(DeleteTable)}"); + scope.Start(); + try + { + return await _tableOperations.DeleteAsync(tableName, null, cancellationToken: cancellationToken).ConfigureAwait(false); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } + } } } From 4f3a52d4574e541cfc7153d4720b0576bc81919e Mon Sep 17 00:00:00 2001 From: Christopher Scott Date: Mon, 8 Jun 2020 18:08:12 -0500 Subject: [PATCH 2/2] fix lambda scopes --- .../Azure.Data.Tables/src/TableClient.cs | 183 ++++++++++-------- .../src/TableServiceClient.cs | 57 +++--- 2 files changed, 137 insertions(+), 103 deletions(-) diff --git a/sdk/tables/Azure.Data.Tables/src/TableClient.cs b/sdk/tables/Azure.Data.Tables/src/TableClient.cs index e0ae3dbd0807b..01bc4141be4f3 100644 --- a/sdk/tables/Azure.Data.Tables/src/TableClient.cs +++ b/sdk/tables/Azure.Data.Tables/src/TableClient.cs @@ -80,7 +80,7 @@ public virtual Response Create(CancellationToken cancellationToken = try { var response = _tableOperations.Create(new TableProperties(_table), null, queryOptions: new QueryOptions() { Format = _format }, cancellationToken: cancellationToken); - return Response.FromValue(response.Value as TableItem, response.GetRawResponse()); + return Response.FromValue(response.Value as TableItem, response.GetRawResponse()); } catch (Exception ex) { @@ -101,7 +101,7 @@ public virtual async Task> CreateAsync(CancellationToken can try { var response = await _tableOperations.CreateAsync(new TableProperties(_table), null, queryOptions: new QueryOptions() { Format = _format }, cancellationToken: cancellationToken).ConfigureAwait(false); - return Response.FromValue(response.Value as TableItem, response.GetRawResponse()); + return Response.FromValue(response.Value as TableItem, response.GetRawResponse()); } catch (Exception ex) { @@ -128,10 +128,10 @@ public virtual async Task>> InsertAs queryOptions: new QueryOptions() { Format = _format }, cancellationToken: cancellationToken).ConfigureAwait(false); - var dict = new Dictionary((IDictionary)response.Value); - dict.CastAndRemoveAnnotations(); + var dict = new Dictionary((IDictionary)response.Value); + dict.CastAndRemoveAnnotations(); - return Response.FromValue(new ReadOnlyDictionary(dict), response.GetRawResponse()); + return Response.FromValue(new ReadOnlyDictionary(dict), response.GetRawResponse()); } catch (Exception ex) { @@ -158,10 +158,10 @@ public virtual Response> Insert(IDictionary((IDictionary)response.Value); - dict.CastAndRemoveAnnotations(); + var dict = new Dictionary((IDictionary)response.Value); + dict.CastAndRemoveAnnotations(); - return Response.FromValue(new ReadOnlyDictionary(dict), response.GetRawResponse()); + return Response.FromValue(new ReadOnlyDictionary(dict), response.GetRawResponse()); } catch (Exception ex) { @@ -188,8 +188,8 @@ public virtual Response> Insert(IDictionary)response.Value).ToTableEntity(); - return Response.FromValue(result, response.GetRawResponse()); + var result = ((Dictionary)response.Value).ToTableEntity(); + return Response.FromValue(result, response.GetRawResponse()); } catch (Exception ex) { @@ -216,8 +216,8 @@ public virtual Response> Insert(IDictionary)response.Value).ToTableEntity(); - return Response.FromValue(result, response.GetRawResponse()); + var result = ((Dictionary)response.Value).ToTableEntity(); + return Response.FromValue(result, response.GetRawResponse()); } catch (Exception ex) { @@ -589,45 +589,57 @@ public virtual AsyncPageable> QueryAsync(string filt public virtual Pageable> Query(string filter = null, int? top = null, string select = null, CancellationToken cancellationToken = default) { - using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableClient)}.{nameof(Query)}"); - scope.Start(); - try - { - return PageableHelpers.CreateEnumerable(_ => - { - var response = _tableOperations.QueryEntities(_table, - queryOptions: new QueryOptions() { Format = _format, Top = top, Filter = filter, Select = @select }, - cancellationToken: cancellationToken); - response.Value.Value.CastAndRemoveAnnotations(); - - return Page.FromValues( - response.Value.Value, - CreateContinuationTokenFromHeaders(response.Headers), - response.GetRawResponse()); + return PageableHelpers.CreateEnumerable(_ => + { + using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableClient)}.{nameof(Query)}"); + scope.Start(); + try + { + var response = _tableOperations.QueryEntities(_table, + queryOptions: new QueryOptions() { Format = _format, Top = top, Filter = filter, Select = @select }, + cancellationToken: cancellationToken); + + response.Value.Value.CastAndRemoveAnnotations(); + + return Page.FromValues( + response.Value.Value, + CreateContinuationTokenFromHeaders(response.Headers), + response.GetRawResponse()); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } }, (continuationToken, _) => { - var (NextPartitionKey, NextRowKey) = ParseContinuationToken(continuationToken); - - var response = _tableOperations.QueryEntities( - _table, - queryOptions: new QueryOptions() { Format = _format, Top = top, Filter = filter, Select = @select }, - nextPartitionKey: NextPartitionKey, - nextRowKey: NextRowKey, - cancellationToken: cancellationToken); - - response.Value.Value.CastAndRemoveAnnotations(); - - return Page.FromValues(response.Value.Value, - CreateContinuationTokenFromHeaders(response.Headers), - response.GetRawResponse()); + using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableClient)}.{nameof(Query)}"); + scope.Start(); + try + { + var (NextPartitionKey, NextRowKey) = ParseContinuationToken(continuationToken); + + var response = _tableOperations.QueryEntities( + _table, + queryOptions: new QueryOptions() { Format = _format, Top = top, Filter = filter, Select = @select }, + nextPartitionKey: NextPartitionKey, + nextRowKey: NextRowKey, + cancellationToken: cancellationToken); + + response.Value.Value.CastAndRemoveAnnotations(); + + return Page.FromValues(response.Value.Value, + CreateContinuationTokenFromHeaders(response.Headers), + response.GetRawResponse()); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } }); - } - catch (Exception ex) - { - scope.Failed(ex); - throw; - } + } /// @@ -771,41 +783,52 @@ public virtual Pageable> Query(Expression Query(string filter = null, int? top = null, string select = null, CancellationToken cancellationToken = default) where T : TableEntity, new() { - using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableClient)}.{nameof(Query)}"); - scope.Start(); - try - { - return PageableHelpers.CreateEnumerable((int? _) => - { - var response = _tableOperations.QueryEntities(_table, - queryOptions: new QueryOptions() { Format = _format, Top = top, Filter = filter, Select = @select }, - cancellationToken: cancellationToken); - return Page.FromValues( - response.Value.Value.ToTableEntityList(), - CreateContinuationTokenFromHeaders(response.Headers), - response.GetRawResponse()); + return PageableHelpers.CreateEnumerable((int? _) => + { + using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableClient)}.{nameof(Query)}"); + scope.Start(); + try + { + var response = _tableOperations.QueryEntities(_table, + queryOptions: new QueryOptions() { Format = _format, Top = top, Filter = filter, Select = @select }, + cancellationToken: cancellationToken); + + return Page.FromValues( + response.Value.Value.ToTableEntityList(), + CreateContinuationTokenFromHeaders(response.Headers), + response.GetRawResponse()); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } }, (continuationToken, _) => { - var (NextPartitionKey, NextRowKey) = ParseContinuationToken(continuationToken); - - var response = _tableOperations.QueryEntities( - _table, - queryOptions: new QueryOptions() { Format = _format, Top = top, Filter = filter, Select = @select }, - nextPartitionKey: NextPartitionKey, - nextRowKey: NextRowKey, - cancellationToken: cancellationToken); - - return Page.FromValues(response.Value.Value.ToTableEntityList(), - CreateContinuationTokenFromHeaders(response.Headers), - response.GetRawResponse()); + using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableClient)}.{nameof(Query)}"); + scope.Start(); + try + { + var (NextPartitionKey, NextRowKey) = ParseContinuationToken(continuationToken); + + var response = _tableOperations.QueryEntities( + _table, + queryOptions: new QueryOptions() { Format = _format, Top = top, Filter = filter, Select = @select }, + nextPartitionKey: NextPartitionKey, + nextRowKey: NextRowKey, + cancellationToken: cancellationToken); + + return Page.FromValues(response.Value.Value.ToTableEntityList(), + CreateContinuationTokenFromHeaders(response.Headers), + response.GetRawResponse()); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } }); - } - catch (Exception ex) - { - scope.Failed(ex); - throw; - } } /// @@ -879,7 +902,7 @@ public virtual async Task>> GetAccessPo try { var response = await _tableOperations.GetAccessPolicyAsync(_table, timeout, requestId, cancellationToken).ConfigureAwait(false); - return Response.FromValue(response.Value, response.GetRawResponse()); + return Response.FromValue(response.Value, response.GetRawResponse()); } catch (Exception ex) { @@ -899,7 +922,7 @@ public virtual Response> GetAccessPolicy(int? ti try { var response = _tableOperations.GetAccessPolicy(_table, timeout, requestId, cancellationToken); - return Response.FromValue(response.Value, response.GetRawResponse()); + return Response.FromValue(response.Value, response.GetRawResponse()); } catch (Exception ex) { diff --git a/sdk/tables/Azure.Data.Tables/src/TableServiceClient.cs b/sdk/tables/Azure.Data.Tables/src/TableServiceClient.cs index 8aa7e026e6979..33af668da954a 100644 --- a/sdk/tables/Azure.Data.Tables/src/TableServiceClient.cs +++ b/sdk/tables/Azure.Data.Tables/src/TableServiceClient.cs @@ -142,33 +142,44 @@ public virtual AsyncPageable GetTablesAsync(string select = null, str /// public virtual Pageable GetTables(string select = null, string filter = null, int? top = null, CancellationToken cancellationToken = default) { - using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableServiceClient)}.{nameof(GetTables)}"); - scope.Start(); - try - { - return PageableHelpers.CreateEnumerable(_ => + + return PageableHelpers.CreateEnumerable(_ => { - var response = _tableOperations.Query( - null, - null, - new QueryOptions() { Filter = filter, Select = select, Top = top, Format = _format }, - cancellationToken); - return Page.FromValues(response.Value.Value, response.Headers.XMsContinuationNextTableName, response.GetRawResponse()); + using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableServiceClient)}.{nameof(GetTables)}"); + scope.Start(); + try + { + var response = _tableOperations.Query( + null, + null, + new QueryOptions() { Filter = filter, Select = select, Top = top, Format = _format }, + cancellationToken); + return Page.FromValues(response.Value.Value, response.Headers.XMsContinuationNextTableName, response.GetRawResponse()); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } }, (nextLink, _) => { - var response = _tableOperations.Query( - null, - nextTableName: nextLink, - new QueryOptions() { Filter = filter, Select = select, Top = top, Format = _format }, - cancellationToken); - return Page.FromValues(response.Value.Value, response.Headers.XMsContinuationNextTableName, response.GetRawResponse()); + using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableServiceClient)}.{nameof(GetTables)}"); + scope.Start(); + try + { + var response = _tableOperations.Query( + null, + nextTableName: nextLink, + new QueryOptions() { Filter = filter, Select = select, Top = top, Format = _format }, + cancellationToken); + return Page.FromValues(response.Value.Value, response.Headers.XMsContinuationNextTableName, response.GetRawResponse()); + } + catch (Exception ex) + { + scope.Failed(ex); + throw; + } }); - } - catch (Exception ex) - { - scope.Failed(ex); - throw; - } } ///