Add profiling to MarketDataServer controllers

This commit is contained in:
2025-04-27 10:55:25 -04:00
parent cebf9f63e6
commit 1c1c0c35f4
9 changed files with 161 additions and 32 deletions

View File

@@ -1,4 +1,5 @@
using MarketData;
using MarketData.Utils;
using MarketDataServer.Authorization;
using Microsoft.AspNetCore.Mvc;
using LogLevel = MarketData.LogLevel;
@@ -12,20 +13,21 @@ namespace MarketDataServer.Controllers
[HttpGet(Name = "GetToken")]
public String GetToken(String user, String password)
{
Profiler profiler = new Profiler();
try
{
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][AuthorizationController::Authorize]",DateTime.Now));
MDTrace.WriteLine(LogLevel.DEBUG,$"Start");
if(null==user)return null;
user=Authorizations.Xor(user,5);
password=Authorizations.Xor(password,5);
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][Login requested for user '{1}']",DateTime.Now, user));
MDTrace.WriteLine(LogLevel.DEBUG,$"Login requested for user '{user}'");
if(!Authorizations.GetInstance().IsValidUser(user, password))
{
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][User '{1}' is not authorized]", DateTime.Now,user));
MDTrace.WriteLine(LogLevel.DEBUG,$"User '{user}' is not authorized.");
return null;
}
String accessToken= Authorizations.GetInstance().GetAuthenticationToken();
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][Access token granted for user {1} : {2}]",DateTime.Now ,user, accessToken));
MDTrace.WriteLine(LogLevel.DEBUG,$"Access token granted for user {user} : {accessToken}.");
return accessToken;
}
catch(Exception exception)
@@ -33,6 +35,10 @@ namespace MarketDataServer.Controllers
MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}");
return null;
}
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()} (ms)");
}
}
}
}