diff --git a/sdk/src/Services/DynamoDBv2/Custom/DocumentModel/_bcl/DocumentBatchGet.Sync.cs b/sdk/src/Services/DynamoDBv2/Custom/DocumentModel/_bcl/DocumentBatchGet.Sync.cs index f43592e50f76..ab0482226f5f 100644 --- a/sdk/src/Services/DynamoDBv2/Custom/DocumentModel/_bcl/DocumentBatchGet.Sync.cs +++ b/sdk/src/Services/DynamoDBv2/Custom/DocumentModel/_bcl/DocumentBatchGet.Sync.cs @@ -13,6 +13,8 @@ * permissions and limitations under the License. */ +using Amazon.Runtime.Telemetry.Tracing; + namespace Amazon.DynamoDBv2.DocumentModel { public partial interface IDocumentBatchGet @@ -29,7 +31,11 @@ public partial class DocumentBatchGet : IDocumentBatchGet /// public void Execute() { - ExecuteHelper(); + var operationName = DynamoDBTelemetry.ExtractOperationName(nameof(DocumentBatchGet), nameof(Execute)); + using (DynamoDBTelemetry.CreateSpan(TracerProvider, operationName, spanKind: SpanKind.CLIENT)) + { + ExecuteHelper(); + } } } @@ -47,7 +53,11 @@ public partial class MultiTableDocumentBatchGet : IMultiTableDocumentBatchGet /// public void Execute() { - ExecuteHelper(); + var operationName = DynamoDBTelemetry.ExtractOperationName(nameof(MultiTableDocumentBatchGet), nameof(Execute)); + using (DynamoDBTelemetry.CreateSpan(TracerProvider, operationName, spanKind: SpanKind.CLIENT)) + { + ExecuteHelper(); + } } } } diff --git a/sdk/src/Services/DynamoDBv2/Custom/DocumentModel/_bcl/DocumentBatchWrite.Sync.cs b/sdk/src/Services/DynamoDBv2/Custom/DocumentModel/_bcl/DocumentBatchWrite.Sync.cs index 826e73d584b4..bd0ecf556b92 100644 --- a/sdk/src/Services/DynamoDBv2/Custom/DocumentModel/_bcl/DocumentBatchWrite.Sync.cs +++ b/sdk/src/Services/DynamoDBv2/Custom/DocumentModel/_bcl/DocumentBatchWrite.Sync.cs @@ -13,6 +13,8 @@ * permissions and limitations under the License. */ +using Amazon.Runtime.Telemetry.Tracing; + namespace Amazon.DynamoDBv2.DocumentModel { public partial interface IDocumentBatchWrite @@ -31,7 +33,11 @@ public partial class DocumentBatchWrite : IDocumentBatchWrite /// public void Execute() { - ExecuteHelper(); + var operationName = DynamoDBTelemetry.ExtractOperationName(nameof(DocumentBatchWrite), nameof(Execute)); + using (DynamoDBTelemetry.CreateSpan(TracerProvider, operationName, spanKind: SpanKind.CLIENT)) + { + ExecuteHelper(); + } } } @@ -51,7 +57,11 @@ public partial class MultiTableDocumentBatchWrite : IMultiTableDocumentBatchWrit /// public void Execute() { - ExecuteHelper(); + var operationName = DynamoDBTelemetry.ExtractOperationName(nameof(MultiTableDocumentBatchWrite), nameof(Execute)); + using (DynamoDBTelemetry.CreateSpan(TracerProvider, operationName, spanKind: SpanKind.CLIENT)) + { + ExecuteHelper(); + } } } } diff --git a/sdk/src/Services/DynamoDBv2/Custom/DocumentModel/_bcl/DocumentTransactGet.Sync.cs b/sdk/src/Services/DynamoDBv2/Custom/DocumentModel/_bcl/DocumentTransactGet.Sync.cs index 2827a4660611..aca9de5c2956 100644 --- a/sdk/src/Services/DynamoDBv2/Custom/DocumentModel/_bcl/DocumentTransactGet.Sync.cs +++ b/sdk/src/Services/DynamoDBv2/Custom/DocumentModel/_bcl/DocumentTransactGet.Sync.cs @@ -13,6 +13,8 @@ * permissions and limitations under the License. */ +using Amazon.Runtime.Telemetry.Tracing; + namespace Amazon.DynamoDBv2.DocumentModel { public partial interface IDocumentTransactGet @@ -29,7 +31,11 @@ public partial class DocumentTransactGet : IDocumentTransactGet /// public void Execute() { - ExecuteHelper(); + var operationName = DynamoDBTelemetry.ExtractOperationName(nameof(DocumentTransactGet), nameof(Execute)); + using (DynamoDBTelemetry.CreateSpan(TracerProvider, operationName, spanKind: SpanKind.CLIENT)) + { + ExecuteHelper(); + } } } @@ -47,7 +53,11 @@ public partial class MultiTableDocumentTransactGet : IMultiTableDocumentTransact /// public void Execute() { - ExecuteHelper(); + var operationName = DynamoDBTelemetry.ExtractOperationName(nameof(MultiTableDocumentTransactGet), nameof(Execute)); + using (DynamoDBTelemetry.CreateSpan(TracerProvider, operationName, spanKind: SpanKind.CLIENT)) + { + ExecuteHelper(); + } } } } diff --git a/sdk/src/Services/DynamoDBv2/Custom/DocumentModel/_bcl/DocumentTransactWrite.Sync.cs b/sdk/src/Services/DynamoDBv2/Custom/DocumentModel/_bcl/DocumentTransactWrite.Sync.cs index 8054342804e5..a56018c41034 100644 --- a/sdk/src/Services/DynamoDBv2/Custom/DocumentModel/_bcl/DocumentTransactWrite.Sync.cs +++ b/sdk/src/Services/DynamoDBv2/Custom/DocumentModel/_bcl/DocumentTransactWrite.Sync.cs @@ -13,6 +13,8 @@ * permissions and limitations under the License. */ +using Amazon.Runtime.Telemetry.Tracing; + namespace Amazon.DynamoDBv2.DocumentModel { public partial interface IDocumentTransactWrite @@ -28,7 +30,11 @@ public partial class DocumentTransactWrite : IDocumentTransactWrite /// public void Execute() { - ExecuteHelper(); + var operationName = DynamoDBTelemetry.ExtractOperationName(nameof(DocumentTransactWrite), nameof(Execute)); + using (DynamoDBTelemetry.CreateSpan(TracerProvider, operationName, spanKind: SpanKind.CLIENT)) + { + ExecuteHelper(); + } } } @@ -49,7 +55,11 @@ public partial class MultiTableDocumentTransactWrite : IMultiTableDocumentTransa /// public void Execute() { - ExecuteHelper(); + var operationName = DynamoDBTelemetry.ExtractOperationName(nameof(MultiTableDocumentTransactWrite), nameof(Execute)); + using (DynamoDBTelemetry.CreateSpan(TracerProvider, operationName, spanKind: SpanKind.CLIENT)) + { + ExecuteHelper(); + } } } } diff --git a/sdk/src/Services/DynamoDBv2/Custom/DocumentModel/_bcl/Search.Sync.cs b/sdk/src/Services/DynamoDBv2/Custom/DocumentModel/_bcl/Search.Sync.cs index b2a916ccdb54..f63fa3be9475 100644 --- a/sdk/src/Services/DynamoDBv2/Custom/DocumentModel/_bcl/Search.Sync.cs +++ b/sdk/src/Services/DynamoDBv2/Custom/DocumentModel/_bcl/Search.Sync.cs @@ -13,6 +13,7 @@ * permissions and limitations under the License. */ +using Amazon.Runtime.Telemetry.Tracing; using System.Collections.Generic; namespace Amazon.DynamoDBv2.DocumentModel @@ -41,13 +42,21 @@ public partial class Search : ISearch /// public List GetNextSet() { - return GetNextSetHelper(); + var operationName = DynamoDBTelemetry.ExtractOperationName(nameof(Search), nameof(GetNextSet)); + using (DynamoDBTelemetry.CreateSpan(TracerProvider, operationName, spanKind: SpanKind.CLIENT)) + { + return GetNextSetHelper(); + } } /// public List GetRemaining() { - return GetRemainingHelper(); + var operationName = DynamoDBTelemetry.ExtractOperationName(nameof(Search), nameof(GetRemaining)); + using (DynamoDBTelemetry.CreateSpan(TracerProvider, operationName, spanKind: SpanKind.CLIENT)) + { + return GetRemainingHelper(); + } } } } diff --git a/sdk/src/Services/DynamoDBv2/Custom/DocumentModel/_bcl/Table.Sync.cs b/sdk/src/Services/DynamoDBv2/Custom/DocumentModel/_bcl/Table.Sync.cs index 31a26baa6bdf..e5deb5cc0352 100644 --- a/sdk/src/Services/DynamoDBv2/Custom/DocumentModel/_bcl/Table.Sync.cs +++ b/sdk/src/Services/DynamoDBv2/Custom/DocumentModel/_bcl/Table.Sync.cs @@ -14,6 +14,7 @@ */ using Amazon.DynamoDBv2.Model; +using Amazon.Runtime.Telemetry.Tracing; using System.Collections.Generic; namespace Amazon.DynamoDBv2.DocumentModel @@ -246,20 +247,28 @@ public partial class Table : ITable /// public Document PutItem(Document doc, PutItemOperationConfig config = null) { - return PutItemHelper(doc, config); + var operationName = DynamoDBTelemetry.ExtractOperationName(nameof(Table), nameof(PutItem)); + using (DynamoDBTelemetry.CreateSpan(TracerProvider, operationName, spanKind: SpanKind.CLIENT)) + { + return PutItemHelper(doc, config); + } } /// public bool TryPutItem(Document doc, PutItemOperationConfig config = null) { - try - { - PutItemHelper(doc, config); - return true; - } - catch (ConditionalCheckFailedException) + var operationName = DynamoDBTelemetry.ExtractOperationName(nameof(Table), nameof(TryPutItem)); + using (DynamoDBTelemetry.CreateSpan(TracerProvider, operationName, spanKind: SpanKind.CLIENT)) { - return false; + try + { + PutItemHelper(doc, config); + return true; + } + catch (ConditionalCheckFailedException) + { + return false; + } } } @@ -271,19 +280,32 @@ public bool TryPutItem(Document doc, PutItemOperationConfig config = null) /// public Document GetItem(Primitive hashKey, GetItemOperationConfig config = null) { - return GetItem(hashKey, null, config); + var operationName = DynamoDBTelemetry.ExtractOperationName(nameof(Table), nameof(GetItem)); + using (DynamoDBTelemetry.CreateSpan(TracerProvider, operationName, spanKind: SpanKind.CLIENT)) + { + return GetItem(hashKey, null, config); + } } /// public Document GetItem(Primitive hashKey, Primitive rangeKey, GetItemOperationConfig config = null) { - return GetItemHelper(MakeKey(hashKey, rangeKey), config); + var operationName = DynamoDBTelemetry.ExtractOperationName(nameof(Table), nameof(GetItem)); + using (DynamoDBTelemetry.CreateSpan(TracerProvider, operationName, spanKind: SpanKind.CLIENT)) + { + return GetItemHelper(MakeKey(hashKey, rangeKey), config); + } } /// public Document GetItem(IDictionary key, GetItemOperationConfig config = null) { - return GetItemHelper(MakeKey(key), config); + var operationName = DynamoDBTelemetry.ExtractOperationName(nameof(Table), nameof(GetItem)); + using (DynamoDBTelemetry.CreateSpan(TracerProvider, operationName, spanKind: SpanKind.CLIENT)) + { + return GetItemHelper(MakeKey(key), config); + } + } #endregion @@ -294,80 +316,112 @@ public Document GetItem(IDictionary key, GetItemOperation /// public Document UpdateItem(Document doc, UpdateItemOperationConfig config = null) { - return UpdateHelper(doc, MakeKey(doc), config); + var operationName = DynamoDBTelemetry.ExtractOperationName(nameof(Table), nameof(UpdateItem)); + using (DynamoDBTelemetry.CreateSpan(TracerProvider, operationName, spanKind: SpanKind.CLIENT)) + { + return UpdateHelper(doc, MakeKey(doc), config); + } } /// public bool TryUpdateItem(Document doc, UpdateItemOperationConfig config = null) { - try - { - UpdateHelper(doc, MakeKey(doc), config); - return true; - } - catch (ConditionalCheckFailedException) + var operationName = DynamoDBTelemetry.ExtractOperationName(nameof(Table), nameof(TryUpdateItem)); + using (DynamoDBTelemetry.CreateSpan(TracerProvider, operationName, spanKind: SpanKind.CLIENT)) { - return false; + try + { + UpdateHelper(doc, MakeKey(doc), config); + return true; + } + catch (ConditionalCheckFailedException) + { + return false; + } } } /// public Document UpdateItem(Document doc, IDictionary key, UpdateItemOperationConfig config = null) { - return UpdateHelper(doc, MakeKey(key), config); + var operationName = DynamoDBTelemetry.ExtractOperationName(nameof(Table), nameof(UpdateItem)); + using (DynamoDBTelemetry.CreateSpan(TracerProvider, operationName, spanKind: SpanKind.CLIENT)) + { + return UpdateHelper(doc, MakeKey(key), config); + } } /// public bool TryUpdateItem(Document doc, IDictionary key, UpdateItemOperationConfig config = null) { - try + var operationName = DynamoDBTelemetry.ExtractOperationName(nameof(Table), nameof(TryUpdateItem)); + using (DynamoDBTelemetry.CreateSpan(TracerProvider, operationName, spanKind: SpanKind.CLIENT)) { - UpdateHelper(doc, MakeKey(key), config); - return true; - } - catch (ConditionalCheckFailedException) - { - return false; + try + { + UpdateHelper(doc, MakeKey(key), config); + return true; + } + catch (ConditionalCheckFailedException) + { + return false; + } } } /// public Document UpdateItem(Document doc, Primitive hashKey, UpdateItemOperationConfig config = null) { - return UpdateHelper(doc, MakeKey(hashKey, null), config); + var operationName = DynamoDBTelemetry.ExtractOperationName(nameof(Table), nameof(UpdateItem)); + using (DynamoDBTelemetry.CreateSpan(TracerProvider, operationName, spanKind: SpanKind.CLIENT)) + { + return UpdateHelper(doc, MakeKey(hashKey, null), config); + } } /// public bool TryUpdateItem(Document doc, Primitive hashKey, UpdateItemOperationConfig config = null) { - try + var operationName = DynamoDBTelemetry.ExtractOperationName(nameof(Table), nameof(TryUpdateItem)); + using (DynamoDBTelemetry.CreateSpan(TracerProvider, operationName, spanKind: SpanKind.CLIENT)) { - UpdateHelper(doc, MakeKey(hashKey, null), config); - return true; - } - catch (ConditionalCheckFailedException) - { - return false; + try + { + UpdateHelper(doc, MakeKey(hashKey, null), config); + return true; + } + catch (ConditionalCheckFailedException) + { + return false; + } } } /// public Document UpdateItem(Document doc, Primitive hashKey, Primitive rangeKey, UpdateItemOperationConfig config = null) { - return UpdateHelper(doc, MakeKey(hashKey, rangeKey), config); + var operationName = DynamoDBTelemetry.ExtractOperationName(nameof(Table), nameof(UpdateItem)); + using (DynamoDBTelemetry.CreateSpan(TracerProvider, operationName, spanKind: SpanKind.CLIENT)) + { + return UpdateHelper(doc, MakeKey(hashKey, rangeKey), config); + } } /// public bool TryUpdateItem(Document doc, Primitive hashKey, Primitive rangeKey, UpdateItemOperationConfig config = null) { - try + var operationName = DynamoDBTelemetry.ExtractOperationName(nameof(Table), nameof(TryUpdateItem)); + using (DynamoDBTelemetry.CreateSpan(TracerProvider, operationName, spanKind: SpanKind.CLIENT)) { - UpdateHelper(doc, MakeKey(hashKey, rangeKey), config); - return true; - } - catch (ConditionalCheckFailedException) - { - return false; + try + { + UpdateHelper(doc, MakeKey(hashKey, rangeKey), config); + return true; + } + catch (ConditionalCheckFailedException) + { + return false; + } } } @@ -379,80 +433,112 @@ public bool TryUpdateItem(Document doc, Primitive hashKey, Primitive rangeKey, U /// public Document DeleteItem(Document document, DeleteItemOperationConfig config = null) { - return DeleteHelper(MakeKey(document), config); + var operationName = DynamoDBTelemetry.ExtractOperationName(nameof(Table), nameof(DeleteItem)); + using (DynamoDBTelemetry.CreateSpan(TracerProvider, operationName, spanKind: SpanKind.CLIENT)) + { + return DeleteHelper(MakeKey(document), config); + } } /// public bool TryDeleteItem(Document document, DeleteItemOperationConfig config = null) { - try - { - DeleteItem(document, config); - return true; - } - catch (ConditionalCheckFailedException) + var operationName = DynamoDBTelemetry.ExtractOperationName(nameof(Table), nameof(TryDeleteItem)); + using (DynamoDBTelemetry.CreateSpan(TracerProvider, operationName, spanKind: SpanKind.CLIENT)) { - return false; + try + { + DeleteItem(document, config); + return true; + } + catch (ConditionalCheckFailedException) + { + return false; + } } } /// public Document DeleteItem(Primitive hashKey, DeleteItemOperationConfig config = null) { - return DeleteHelper(MakeKey(hashKey, null), config); + var operationName = DynamoDBTelemetry.ExtractOperationName(nameof(Table), nameof(DeleteItem)); + using (DynamoDBTelemetry.CreateSpan(TracerProvider, operationName, spanKind: SpanKind.CLIENT)) + { + return DeleteHelper(MakeKey(hashKey, null), config); + } } /// public bool TryDeleteItem(Primitive hashKey, DeleteItemOperationConfig config = null) { - try + var operationName = DynamoDBTelemetry.ExtractOperationName(nameof(Table), nameof(TryDeleteItem)); + using (DynamoDBTelemetry.CreateSpan(TracerProvider, operationName, spanKind: SpanKind.CLIENT)) { - DeleteItem(hashKey, config); - return true; - } - catch (ConditionalCheckFailedException) - { - return false; + try + { + DeleteItem(hashKey, config); + return true; + } + catch (ConditionalCheckFailedException) + { + return false; + } } } /// public Document DeleteItem(Primitive hashKey, Primitive rangeKey, DeleteItemOperationConfig config = null) { - return DeleteHelper(MakeKey(hashKey, rangeKey), config); + var operationName = DynamoDBTelemetry.ExtractOperationName(nameof(Table), nameof(DeleteItem)); + using (DynamoDBTelemetry.CreateSpan(TracerProvider, operationName, spanKind: SpanKind.CLIENT)) + { + return DeleteHelper(MakeKey(hashKey, rangeKey), config); + } } /// public bool TryDeleteItem(Primitive hashKey, Primitive rangeKey, DeleteItemOperationConfig config = null) { - try - { - DeleteItem(hashKey, rangeKey, config); - return true; - } - catch (ConditionalCheckFailedException) + var operationName = DynamoDBTelemetry.ExtractOperationName(nameof(Table), nameof(TryDeleteItem)); + using (DynamoDBTelemetry.CreateSpan(TracerProvider, operationName, spanKind: SpanKind.CLIENT)) { - return false; + try + { + DeleteItem(hashKey, rangeKey, config); + return true; + } + catch (ConditionalCheckFailedException) + { + return false; + } } } /// public Document DeleteItem(IDictionary key, DeleteItemOperationConfig config = null) { - return DeleteHelper(MakeKey(key), config); + var operationName = DynamoDBTelemetry.ExtractOperationName(nameof(Table), nameof(DeleteItem)); + using (DynamoDBTelemetry.CreateSpan(TracerProvider, operationName, spanKind: SpanKind.CLIENT)) + { + return DeleteHelper(MakeKey(key), config); + } } /// public bool TryDeleteItem(IDictionary key, DeleteItemOperationConfig config = null) { - try - { - DeleteHelper(MakeKey(key), config); - return true; - } - catch (ConditionalCheckFailedException) + var operationName = DynamoDBTelemetry.ExtractOperationName(nameof(Table), nameof(TryDeleteItem)); + using (DynamoDBTelemetry.CreateSpan(TracerProvider, operationName, spanKind: SpanKind.CLIENT)) { - return false; + try + { + DeleteHelper(MakeKey(key), config); + return true; + } + catch (ConditionalCheckFailedException) + { + return false; + } } }