Skip to content

Commit

Permalink
Cleaner implementation based on PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
nr-ahemsath committed Oct 21, 2024
1 parent 80d0d54 commit ceb7323
Showing 1 changed file with 2 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static AfterWrappedMethodDelegate HandleDynamoDbRequest(InstrumentedMetho

// PutItemRequest => put_item,
// CreateTableRequest => create_table, etc.
operation = GetOperationNameFromRequestType(requestType);
operation = _operationNameCache.GetOrAdd(requestType, GetOperationNameFromRequestType(requestType));

// Even though there is no common interface they all implement, every Request type I checked
// has a TableName property
Expand All @@ -38,19 +38,7 @@ public static AfterWrappedMethodDelegate HandleDynamoDbRequest(InstrumentedMetho

private static string GetOperationNameFromRequestType(string requestType)
{
if (_operationNameCache.ContainsKey(requestType))
{
return _operationNameCache[requestType];
}
var operationName = requestType.Replace("Request", string.Empty).ToSnakeCase();
if (_operationNameCache.TryAdd(requestType, operationName))
{
return operationName;
}
else
{
return _operationNameCache[requestType];
}
return requestType.Replace("Request", string.Empty).ToSnakeCase();
}
}
}

0 comments on commit ceb7323

Please sign in to comment.