-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add AWSSDK.DynamoDBv2 instrumentation (#2858)
* Bring initial POC to feature branch (#2836) * First pass at DynamoDB support * db.system attribute was not being set correctly --------- Co-authored-by: chynesNR <chynes@newrelic.com> * Clean up POC (#2839) * Remove datastore vendor name from ConnectionInfo in MemcachedHelpers * Get operation name from request type by converting PascalCaseRequest to snake_case * Make operation name cache thread safe (#2841) * Make operation name cache thread safe * Cleaner implementation based on PR feedback * Update src/Agent/NewRelic/Agent/Extensions/Providers/Wrapper/AwsSdk/DynamoDbRequestHandler.cs Co-authored-by: Chris Ventura <45495992+nrcventura@users.noreply.github.com> --------- Co-authored-by: Chris Ventura <45495992+nrcventura@users.noreply.github.com> * DynamoDB integration tests (#2854) * Rename things in preparation to add another AWS SDK test type * Add project dependencies * More renaming * Initial plumbing created * More cleanup * Forklift exerciser methods from standalone test app * Working tests * Cleanup * Fix port assignment issue seen in CI * Only wait up to two minutes for table to become active * List ports in use in container tests host For temporary troubleshooting * Update tests/Agent/IntegrationTests/ContainerApplications/AwsSdkTestApp/AwsSdkExercisers/AwsSdkDynamoDBExerciser.cs Co-authored-by: Marty T <120425148+tippmar-nr@users.noreply.github.com> * Fix port conflict issue plus PR feedback --------- Co-authored-by: Marty T <120425148+tippmar-nr@users.noreply.github.com> * Add unit tests for ToSnakeCase() (#2859) Unit tests for ToSnakeCase() --------- Co-authored-by: chynesNR <chynes@newrelic.com> Co-authored-by: Chris Ventura <45495992+nrcventura@users.noreply.github.com> Co-authored-by: Marty T <120425148+tippmar-nr@users.noreply.github.com>
- Loading branch information
1 parent
ae1d422
commit 2460527
Showing
41 changed files
with
752 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,6 +80,7 @@ public enum DatastoreVendor | |
//SQLite, | ||
CosmosDB, | ||
Elasticsearch, | ||
DynamoDB, | ||
Other | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/Agent/NewRelic/Agent/Extensions/Providers/Wrapper/AwsSdk/DynamoDbRequestHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright 2020 New Relic, Inc. All rights reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
using System.Collections.Concurrent; | ||
using System.Threading.Tasks; | ||
using NewRelic.Agent.Api; | ||
using NewRelic.Agent.Extensions.Parsing; | ||
using NewRelic.Agent.Extensions.Providers.Wrapper; | ||
|
||
namespace NewRelic.Providers.Wrapper.AwsSdk | ||
{ | ||
internal static class DynamoDbRequestHandler | ||
{ | ||
|
||
private static ConcurrentDictionary<string,string> _operationNameCache = new ConcurrentDictionary<string,string>(); | ||
|
||
public static AfterWrappedMethodDelegate HandleDynamoDbRequest(InstrumentedMethodCall instrumentedMethodCall, IAgent agent, ITransaction transaction, dynamic request, bool isAsync, dynamic executionContext) | ||
{ | ||
var requestType = request.GetType().Name as string; | ||
|
||
string model; | ||
string operation; | ||
|
||
// PutItemRequest => put_item, | ||
// CreateTableRequest => create_table, etc. | ||
operation = _operationNameCache.GetOrAdd(requestType, GetOperationNameFromRequestType); | ||
|
||
// Even though there is no common interface they all implement, every Request type I checked | ||
// has a TableName property | ||
model = request.TableName; | ||
|
||
var segment = transaction.StartDatastoreSegment(instrumentedMethodCall.MethodCall, new ParsedSqlStatement(DatastoreVendor.DynamoDB, model, operation), isLeaf: true); | ||
return isAsync ? | ||
Delegates.GetAsyncDelegateFor<Task>(agent, segment) | ||
: | ||
Delegates.GetDelegateFor(segment); | ||
} | ||
|
||
private static string GetOperationNameFromRequestType(string requestType) | ||
{ | ||
return requestType.Replace("Request", string.Empty).ToSnakeCase(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 0 additions & 12 deletions
12
...nt/IntegrationTests/ContainerApplications/AwsSdkTestApp/AwsSdkExerciser/AwsSdkTestType.cs
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.