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

Add Observability to Data Model Operations is DynamoDB HLL #3492

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions sdk/src/Services/DynamoDBv2/Custom/DataModel/AsyncSearch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

using Amazon.DynamoDBv2.DataModel;
using Amazon.DynamoDBv2.DocumentModel;
using Amazon.Runtime.Telemetry.Tracing;

namespace Amazon.DynamoDBv2.DataModel
{
Expand All @@ -39,6 +40,7 @@ internal AsyncSearch(DynamoDBContext source, DynamoDBContext.ContextSearch conte
SourceContext = source;
DocumentSearch = contextSearch.Search;
Config = contextSearch.FlatConfig;
TracerProvider = source.Client.Config.TelemetryProvider.TracerProvider;
}

#endregion
Expand All @@ -51,6 +53,8 @@ internal AsyncSearch(DynamoDBContext source, DynamoDBContext.ContextSearch conte

#endregion

internal TracerProvider TracerProvider { get; private set; }

#region Public properties

/// <summary>
Expand Down
12 changes: 12 additions & 0 deletions sdk/src/Services/DynamoDBv2/Custom/DataModel/BatchGet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
using System.Reflection;
using Amazon.DynamoDBv2.Model;
using Amazon.DynamoDBv2.DocumentModel;
using Amazon.Runtime.Telemetry.Tracing;
using System.Linq;


#if AWS_ASYNC_API
using System.Threading.Tasks;
#endif
Expand All @@ -43,6 +47,7 @@ public abstract partial class BatchGet
internal List<Key> Keys { get; set; }
internal DocumentBatchGet DocumentBatch { get; set; }
internal ItemStorageConfig ItemStorageConfig { get; set; }
internal TracerProvider TracerProvider { get; private set; }

#endregion

Expand All @@ -54,6 +59,7 @@ internal BatchGet(DynamoDBContext context, DynamoDBFlatConfig config)
Context = context;
Config = config;
Keys = new List<Key>();
TracerProvider = context.Client.Config.TelemetryProvider.TracerProvider;
}

#endregion
Expand Down Expand Up @@ -247,6 +253,8 @@ public partial class MultiTableBatchGet

#endregion

internal TracerProvider TracerProvider { get; private set; }


#region Constructor

Expand All @@ -258,13 +266,17 @@ public partial class MultiTableBatchGet
public MultiTableBatchGet(params BatchGet[] batches)
{
allBatches = new List<BatchGet>(batches);
TracerProvider = allBatches.Count > 0
? allBatches[0].TracerProvider
: AWSConfigs.TelemetryProvider.TracerProvider;
}

internal MultiTableBatchGet(BatchGet first, params BatchGet[] rest)
{
allBatches = new List<BatchGet>();
allBatches.Add(first);
allBatches.AddRange(rest);
TracerProvider = allBatches[0].TracerProvider;
96malhar marked this conversation as resolved.
Show resolved Hide resolved
}

#endregion
Expand Down
11 changes: 11 additions & 0 deletions sdk/src/Services/DynamoDBv2/Custom/DataModel/BatchWrite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
using Amazon.DynamoDBv2.Model;
using Amazon.DynamoDBv2.DocumentModel;
using System.Globalization;
using Amazon.Runtime.Telemetry.Tracing;

#if AWS_ASYNC_API
using System.Threading.Tasks;
#endif
Expand All @@ -38,6 +40,8 @@ public abstract partial class BatchWrite
internal DynamoDBContext Context { get; set; }
internal DynamoDBFlatConfig Config { get; set; }
internal DocumentBatchWrite DocumentBatch { get; set; }
internal TracerProvider TracerProvider { get; private set; }


#endregion

Expand All @@ -48,6 +52,7 @@ internal BatchWrite(DynamoDBContext context, DynamoDBFlatConfig config)
{
Context = context;
Config = config;
TracerProvider = context.Client.Config.TelemetryProvider.TracerProvider;
}

#endregion
Expand Down Expand Up @@ -244,6 +249,8 @@ public partial class MultiTableBatchWrite

#endregion

internal TracerProvider TracerProvider { get; private set; }


#region Constructor

Expand All @@ -255,13 +262,17 @@ public partial class MultiTableBatchWrite
public MultiTableBatchWrite(params BatchWrite[] batches)
{
allBatches = new List<BatchWrite>(batches);
TracerProvider = allBatches.Count > 0
? allBatches[0].TracerProvider
: AWSConfigs.TelemetryProvider.TracerProvider;
}

internal MultiTableBatchWrite(BatchWrite first, params BatchWrite[] rest)
{
allBatches = new List<BatchWrite>();
allBatches.Add(first);
allBatches.AddRange(rest);
TracerProvider = allBatches[0].TracerProvider;
96malhar marked this conversation as resolved.
Show resolved Hide resolved
}

#endregion
Expand Down
10 changes: 10 additions & 0 deletions sdk/src/Services/DynamoDBv2/Custom/DataModel/TransactGet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using System.Threading.Tasks;
#endif
using Amazon.DynamoDBv2.DocumentModel;
using Amazon.Runtime.Telemetry.Tracing;

namespace Amazon.DynamoDBv2.DataModel
{
Expand All @@ -37,6 +38,8 @@ public abstract partial class TransactGet
internal DynamoDBContext Context { get; set; }
internal DynamoDBFlatConfig Config { get; set; }
internal DocumentTransactGet DocumentTransaction { get; set; }
internal TracerProvider TracerProvider { get; private set; }


#endregion

Expand All @@ -58,6 +61,7 @@ internal TransactGet(DynamoDBContext context, DynamoDBFlatConfig config)
{
Context = context;
Config = config;
TracerProvider = context.Client.Config.TelemetryProvider.TracerProvider;
}

#endregion
Expand Down Expand Up @@ -237,6 +241,8 @@ public partial class MultiTableTransactGet

#endregion

internal TracerProvider TracerProvider { get; private set; }


#region Constructor

Expand All @@ -248,13 +254,17 @@ public partial class MultiTableTransactGet
public MultiTableTransactGet(params TransactGet[] transactionParts)
{
allTransactionParts = new List<TransactGet>(transactionParts);
TracerProvider = allTransactionParts.Count > 0
? allTransactionParts[0].TracerProvider
: AWSConfigs.TelemetryProvider.TracerProvider;
}

internal MultiTableTransactGet(TransactGet first, params TransactGet[] rest)
{
allTransactionParts = new List<TransactGet>();
allTransactionParts.Add(first);
allTransactionParts.AddRange(rest);
TracerProvider = allTransactionParts[0].TracerProvider;
96malhar marked this conversation as resolved.
Show resolved Hide resolved
}

#endregion
Expand Down
8 changes: 8 additions & 0 deletions sdk/src/Services/DynamoDBv2/Custom/DataModel/TransactWrite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
using System.Threading.Tasks;
#endif
using Amazon.DynamoDBv2.DocumentModel;
using Amazon.Runtime.Telemetry.Tracing;

namespace Amazon.DynamoDBv2.DataModel
{
Expand All @@ -35,6 +36,7 @@ public abstract partial class TransactWrite
internal DynamoDBContext Context { get; set; }
internal DynamoDBFlatConfig Config { get; set; }
internal DocumentTransactWrite DocumentTransaction { get; set; }
internal TracerProvider TracerProvider { get; private set; }

#endregion

Expand All @@ -45,6 +47,7 @@ internal TransactWrite(DynamoDBContext context, DynamoDBFlatConfig config)
{
Context = context;
Config = config;
TracerProvider = context.Client.Config.TelemetryProvider.TracerProvider;
}

#endregion
Expand Down Expand Up @@ -455,6 +458,7 @@ public partial class MultiTableTransactWrite

#endregion

internal TracerProvider TracerProvider { get; private set; }

#region Constructor

Expand All @@ -466,13 +470,17 @@ public partial class MultiTableTransactWrite
public MultiTableTransactWrite(params TransactWrite[] transactionParts)
{
allTransactionParts = new List<TransactWrite>(transactionParts);
TracerProvider = allTransactionParts.Count > 0
? allTransactionParts[0].TracerProvider
: AWSConfigs.TelemetryProvider.TracerProvider;
}

internal MultiTableTransactWrite(TransactWrite first, params TransactWrite[] rest)
{
allTransactionParts = new List<TransactWrite>();
allTransactionParts.Add(first);
allTransactionParts.AddRange(rest);
TracerProvider = allTransactionParts[0].TracerProvider;
96malhar marked this conversation as resolved.
Show resolved Hide resolved
}

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
using Amazon.Runtime.Internal;
using Amazon.DynamoDBv2.DocumentModel;
using Amazon.DynamoDBv2.DataModel;
using AWSSDK.DynamoDBv2;
using Amazon.Runtime.Telemetry.Tracing;

namespace Amazon.DynamoDBv2.DataModel
{
Expand All @@ -47,9 +49,13 @@ public partial class AsyncSearch<T>
/// </returns>
public virtual async Task<List<T>> GetNextSetAsync(CancellationToken cancellationToken = default(CancellationToken))
{
var documents = await DocumentSearch.GetNextSetHelperAsync(cancellationToken).ConfigureAwait(false);
List<T> items = SourceContext.FromDocumentsHelper<T>(documents, this.Config).ToList();
return items;
var operationName = DynamoDBTelemetry.ExtractOperationName(nameof(AsyncSearch<T>), nameof(GetNextSetAsync));
using (DynamoDBTelemetry.CreateSpan(TracerProvider, operationName, spanKind: SpanKind.CLIENT))
{
var documents = await DocumentSearch.GetNextSetHelperAsync(cancellationToken).ConfigureAwait(false);
List<T> items = SourceContext.FromDocumentsHelper<T>(documents, this.Config).ToList();
return items;
}
}

/// <summary>
Expand All @@ -62,9 +68,13 @@ public partial class AsyncSearch<T>
/// </returns>
public virtual async Task<List<T>> GetRemainingAsync(CancellationToken cancellationToken = default(CancellationToken))
{
var documents = await DocumentSearch.GetRemainingHelperAsync(cancellationToken).ConfigureAwait(false);
List<T> items = SourceContext.FromDocumentsHelper<T>(documents, this.Config).ToList();
return items;
var operationName = DynamoDBTelemetry.ExtractOperationName(nameof(AsyncSearch<T>), nameof(GetRemainingAsync));
using (DynamoDBTelemetry.CreateSpan(TracerProvider, operationName, spanKind: SpanKind.CLIENT))
{
var documents = await DocumentSearch.GetRemainingHelperAsync(cancellationToken).ConfigureAwait(false);
List<T> items = SourceContext.FromDocumentsHelper<T>(documents, this.Config).ToList();
return items;
}
}

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
using System.Threading;
using System.Threading.Tasks;
using Amazon.Runtime.Internal;
using AWSSDK.DynamoDBv2;
using Amazon.Runtime.Telemetry.Tracing;

namespace Amazon.DynamoDBv2.DataModel
{
Expand All @@ -40,9 +42,13 @@ public abstract partial class BatchGet
/// <param name="cancellationToken">Token which can be used to cancel the task.</param>
///
/// <returns>A Task that can be used to poll or wait for results, or both.</returns>
public Task ExecuteAsync(CancellationToken cancellationToken = default(CancellationToken))
public async Task ExecuteAsync(CancellationToken cancellationToken = default(CancellationToken))
{
return ExecuteHelperAsync(cancellationToken);
var operationName = DynamoDBTelemetry.ExtractOperationName(nameof(BatchGet), nameof(ExecuteAsync));
using (DynamoDBTelemetry.CreateSpan(TracerProvider, operationName, spanKind: SpanKind.CLIENT))
{
await ExecuteHelperAsync(cancellationToken).ConfigureAwait(false);
}
}

#endregion
Expand All @@ -63,9 +69,13 @@ public partial class MultiTableBatchGet
/// <param name="cancellationToken">Token which can be used to cancel the task.</param>
///
/// <returns>A Task that can be used to poll or wait for results, or both.</returns>
public Task ExecuteAsync(CancellationToken cancellationToken = default(CancellationToken))
public async Task ExecuteAsync(CancellationToken cancellationToken = default(CancellationToken))
{
return ExecuteHelperAsync(cancellationToken);
var operationName = DynamoDBTelemetry.ExtractOperationName(nameof(MultiTableBatchGet), nameof(ExecuteAsync));
using (DynamoDBTelemetry.CreateSpan(TracerProvider, operationName, spanKind: SpanKind.CLIENT))
{
await ExecuteHelperAsync(cancellationToken).ConfigureAwait(false);
}
}

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
using System.Threading.Tasks;
using Amazon.Runtime.Internal;
using System.Threading;
using AWSSDK.DynamoDBv2;
using Amazon.Runtime.Telemetry.Tracing;

namespace Amazon.DynamoDBv2.DataModel
{
Expand All @@ -43,9 +45,13 @@ public abstract partial class BatchWrite
/// <param name="cancellationToken">Token which can be used to cancel the task.</param>
///
/// <returns>A Task that can be used to poll or wait for results, or both.</returns>
public Task ExecuteAsync(CancellationToken cancellationToken = default(CancellationToken))
public async Task ExecuteAsync(CancellationToken cancellationToken = default(CancellationToken))
{
return ExecuteHelperAsync(cancellationToken);
var operationName = DynamoDBTelemetry.ExtractOperationName(nameof(BatchWrite), nameof(ExecuteAsync));
using (DynamoDBTelemetry.CreateSpan(TracerProvider, operationName, spanKind: SpanKind.CLIENT))
{
await ExecuteHelperAsync(cancellationToken).ConfigureAwait(false);
}
}

#endregion
Expand All @@ -68,9 +74,13 @@ public partial class MultiTableBatchWrite
/// <param name="cancellationToken">Token which can be used to cancel the task.</param>
///
/// <returns>A Task that can be used to poll or wait for results, or both.</returns>
public Task ExecuteAsync(CancellationToken cancellationToken = default(CancellationToken))
public async Task ExecuteAsync(CancellationToken cancellationToken = default(CancellationToken))
{
return ExecuteHelperAsync(cancellationToken);
var operationName = DynamoDBTelemetry.ExtractOperationName(nameof(MultiTableBatchWrite), nameof(ExecuteAsync));
using (DynamoDBTelemetry.CreateSpan(TracerProvider, operationName, spanKind: SpanKind.CLIENT))
{
await ExecuteHelperAsync(cancellationToken).ConfigureAwait(false);
}
}

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* permissions and limitations under the License.
*/

using Amazon.Runtime.Telemetry.Tracing;
using AWSSDK.DynamoDBv2;
using System.Threading;
using System.Threading.Tasks;

Expand All @@ -31,9 +33,13 @@ public abstract partial class TransactGet
/// </summary>
/// <param name="cancellationToken">Token which can be used to cancel the task.</param>
/// <returns>A Task that can be used to poll or wait for results, or both.</returns>
public Task ExecuteAsync(CancellationToken cancellationToken = default(CancellationToken))
public async Task ExecuteAsync(CancellationToken cancellationToken = default(CancellationToken))
{
return ExecuteHelperAsync(cancellationToken);
var operationName = DynamoDBTelemetry.ExtractOperationName(nameof(TransactGet), nameof(ExecuteAsync));
using (DynamoDBTelemetry.CreateSpan(TracerProvider, operationName, spanKind: SpanKind.CLIENT))
{
await ExecuteHelperAsync(cancellationToken).ConfigureAwait(false);
}
}

#endregion
Expand All @@ -54,9 +60,13 @@ public partial class MultiTableTransactGet
/// <param name="cancellationToken">Token which can be used to cancel the task.</param>
///
/// <returns>A Task that can be used to poll or wait for results, or both.</returns>
public Task ExecuteAsync(CancellationToken cancellationToken = default(CancellationToken))
public async Task ExecuteAsync(CancellationToken cancellationToken = default(CancellationToken))
{
return ExecuteHelperAsync(cancellationToken);
var operationName = DynamoDBTelemetry.ExtractOperationName(nameof(MultiTableTransactGet), nameof(ExecuteAsync));
using (DynamoDBTelemetry.CreateSpan(TracerProvider, operationName, spanKind: SpanKind.CLIENT))
{
await ExecuteHelperAsync(cancellationToken).ConfigureAwait(false);
}
}

#endregion
Expand Down
Loading