초기커밋

This commit is contained in:
2025-05-01 07:20:41 +09:00
commit 98bb2e3c5c
2747 changed files with 646947 additions and 0 deletions

View File

@@ -0,0 +1,256 @@
using System.Diagnostics;
using Amazon.DynamoDBv2;
using Amazon.DynamoDBv2.DocumentModel;
using Amazon.DynamoDBv2.Model;
using ServerCore; using ServerBase;
namespace ServerBase;
public static class DynamoDbStopwatchHelper
{
public static Search queryWithStopwatch(this Table table, QueryOperationConfig queryOperationConfig, string eventTid)
{
Stopwatch? stopwatch = null;
var server_logic = ServerLogicApp.getServerLogicAppWithNull();
var server_config = server_logic?.getServerConfig();
if (true == server_config?.PerformanceCheckEnable)
{
eventTid = string.IsNullOrEmpty(eventTid) ? System.Guid.NewGuid().ToString("N") : eventTid;
stopwatch = Stopwatch.StartNew();
}
var search = table.Query(queryOperationConfig);
if (null != stopwatch)
{
var elapsed_msec = stopwatch.ElapsedMilliseconds;
stopwatch.Stop();
if (elapsed_msec > Constant.STOPWATCH_LOG_LIMIT_MSEC)
{
Log.getLogger().debug($"QueryBatch - Table Query Stopwatch Stop : ETID:{eventTid}, ElapsedMSec:{elapsed_msec} - {table.toBasicString()}");
}
Monitor.It.setDelayTimeForDBResponse(elapsed_msec);
}
return search;
}
public static async Task putItemAsyncWithStopwatch(this Table table, Document document, string eventTid)
{
Stopwatch? stopwatch = null;
var server_logic = ServerLogicApp.getServerLogicAppWithNull();
var server_config = server_logic?.getServerConfig();
if (true == server_config?.PerformanceCheckEnable)
{
eventTid = string.IsNullOrEmpty(eventTid) ? System.Guid.NewGuid().ToString("N") : eventTid;
stopwatch = Stopwatch.StartNew();
}
await table.PutItemAsync(document);
if (null != stopwatch)
{
var elapsed_msec = stopwatch.ElapsedMilliseconds;
stopwatch.Stop();
if (elapsed_msec > Constant.STOPWATCH_LOG_LIMIT_MSEC)
{
Log.getLogger().debug($"QueryBatch - Table PutItemAsync Stopwatch Stop : ETID:{eventTid}, ElapsedMSec:{elapsed_msec} - {table.toBasicString()}");
}
Monitor.It.setDelayTimeForDBResponse(elapsed_msec);
}
}
public static async Task<Document?> upsertItemAsyncWithStopwatch(this Table table, Document document, string eventTid)
{
Stopwatch? stopwatch = null;
var server_logic = ServerLogicApp.getServerLogicAppWithNull();
var server_config = server_logic?.getServerConfig();
if (true == server_config?.PerformanceCheckEnable)
{
eventTid = string.IsNullOrEmpty(eventTid) ? System.Guid.NewGuid().ToString("N") : eventTid;
stopwatch = Stopwatch.StartNew();
}
var updated_document = await table.UpdateItemAsync(document);
if (null != stopwatch)
{
var elapsed_msec = stopwatch.ElapsedMilliseconds;
stopwatch.Stop();
if (elapsed_msec > Constant.STOPWATCH_LOG_LIMIT_MSEC)
{
Log.getLogger().debug($"QueryBatch - Table UpsertItemAsync Stopwatch Stop : ETID:{eventTid}, ElapsedMSec:{elapsed_msec} - {table.toBasicString()}");
}
Monitor.It.setDelayTimeForDBResponse(elapsed_msec);
}
return updated_document;
}
public static async Task<Document?> updateItemAsyncWithStopwatch(this Table table, Document document, UpdateItemOperationConfig operationConfig, string eventTid)
{
Stopwatch? stopwatch = null;
var server_logic = ServerLogicApp.getServerLogicAppWithNull();
var server_config = server_logic?.getServerConfig();
if (true == server_config?.PerformanceCheckEnable)
{
eventTid = string.IsNullOrEmpty(eventTid) ? System.Guid.NewGuid().ToString("N") : eventTid;
stopwatch = Stopwatch.StartNew();
}
var updated_document = await table.UpdateItemAsync(document, operationConfig);
if (null != stopwatch)
{
var elapsed_msec = stopwatch.ElapsedMilliseconds;
stopwatch.Stop();
if (elapsed_msec > Constant.STOPWATCH_LOG_LIMIT_MSEC)
{
Log.getLogger().debug($"QueryBatch - Table UpdateItemAsync Stopwatch Stop : ETID:{eventTid}, ElapsedMSec:{elapsed_msec} - {table.toBasicString()}");
}
Monitor.It.setDelayTimeForDBResponse(elapsed_msec);
}
return updated_document;
}
public static async Task deleteItemAsyncWithStopwatch(this Table table, Document document, string eventTid)
{
Stopwatch? stopwatch = null;
var server_logic = ServerLogicApp.getServerLogicAppWithNull();
var server_config = server_logic?.getServerConfig();
if (true == server_config?.PerformanceCheckEnable)
{
eventTid = string.IsNullOrEmpty(eventTid) ? System.Guid.NewGuid().ToString("N") : eventTid;
stopwatch = Stopwatch.StartNew();
}
await table.DeleteItemAsync(document);
if (null != stopwatch)
{
var elapsed_msec = stopwatch.ElapsedMilliseconds;
stopwatch.Stop();
if (elapsed_msec > Constant.STOPWATCH_LOG_LIMIT_MSEC)
{
Log.getLogger().debug($"QueryBatch - Table DeleteItemAsync Stopwatch Stop : ETID:{eventTid}, ElapsedMSec:{elapsed_msec} - {table.toBasicString()}");
}
Monitor.It.setDelayTimeForDBResponse(elapsed_msec);
}
}
public static async Task executeAsyncWithStopwatch(this DocumentBatchWrite batch, string eventTid)
{
Stopwatch? stopwatch = null;
var server_logic = ServerLogicApp.getServerLogicAppWithNull();
var server_config = server_logic?.getServerConfig();
if (true == server_config?.PerformanceCheckEnable)
{
eventTid = string.IsNullOrEmpty(eventTid) ? System.Guid.NewGuid().ToString("N") : eventTid;
stopwatch = Stopwatch.StartNew();
}
await batch.ExecuteAsync();
if (null != stopwatch)
{
var elapsed_msec = stopwatch.ElapsedMilliseconds;
stopwatch.Stop();
if (elapsed_msec > Constant.STOPWATCH_LOG_LIMIT_MSEC)
{
Log.getLogger().debug($"QueryBatch - DocumentBatchWrite ExecuteAsync Stopwatch Stop : ETID:{eventTid}, ElapsedMSec:{elapsed_msec}");
}
Monitor.It.setDelayTimeForDBResponse(elapsed_msec);
}
}
public static async Task executeAsyncWithStopwatch(this DocumentTransactWrite transactWrite, string eventTid)
{
Stopwatch? stopwatch = null;
var server_logic = ServerLogicApp.getServerLogicAppWithNull();
var server_config = server_logic?.getServerConfig();
if (true == server_config?.PerformanceCheckEnable)
{
eventTid = string.IsNullOrEmpty(eventTid) ? System.Guid.NewGuid().ToString("N") : eventTid;
stopwatch = Stopwatch.StartNew();
}
await transactWrite.ExecuteAsync();
if (null != stopwatch)
{
var elapsed_msec = stopwatch.ElapsedMilliseconds;
stopwatch.Stop();
if (elapsed_msec > Constant.STOPWATCH_LOG_LIMIT_MSEC)
{
Log.getLogger().debug($"QueryBatch - DocumentTransactWrite ExecuteAsync Stopwatch Stop : ETID:{eventTid}, ElapsedMSec:{elapsed_msec}");
}
Monitor.It.setDelayTimeForDBResponse(elapsed_msec);
}
}
public static async Task<UpdateItemResponse> updateItemAsyncWithStopwatch(this AmazonDynamoDBClient dbClient, UpdateItemRequest updateItemRequest, string eventTid)
{
Stopwatch? stopwatch = null;
var server_logic = ServerLogicApp.getServerLogicAppWithNull();
var server_config = server_logic?.getServerConfig();
if (true == server_config?.PerformanceCheckEnable)
{
eventTid = string.IsNullOrEmpty(eventTid) ? System.Guid.NewGuid().ToString("N") : eventTid;
stopwatch = Stopwatch.StartNew();
}
var updated_item_response = await dbClient.UpdateItemAsync(updateItemRequest);
if (null != stopwatch)
{
var elapsed_msec = stopwatch.ElapsedMilliseconds;
stopwatch.Stop();
if (elapsed_msec > Constant.STOPWATCH_LOG_LIMIT_MSEC)
{
Log.getLogger().debug($"QueryBatch - DocumentTransactWrite ExecuteAsync Stopwatch Stop : ETID:{eventTid}, ElapsedMSec:{elapsed_msec} - {updateItemRequest.toBasicString()}");
}
Monitor.It.setDelayTimeForDBResponse(elapsed_msec);
}
return updated_item_response;
}
}