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

@@ -20,9 +20,10 @@ namespace MarketDataServer.Controllers
[HttpGet(Name = "GetPrices")]
public IEnumerable<Price> GetPrices(String token, String symbol, int days)
{
Profiler profiler = new Profiler();
try
{
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][PriceController::GetPrices]", DateTime.Now));
MDTrace.WriteLine(LogLevel.DEBUG,$"Start");
if (!Authorizations.GetInstance().IsAuthorized(token)) return null;
return PricingDA.GetPrices(symbol, days);
}
@@ -31,14 +32,19 @@ namespace MarketDataServer.Controllers
MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}");
return null;
}
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()} (ms)");
}
}
[HttpGet(Name = "GetBollingerBands")]
public BollingerBands GetBollingerBands(String token,String symbol,int dayCount)
{
Profiler profiler = new Profiler();
try
{
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][PriceController::GetBollingerBands]", DateTime.Now));
MDTrace.WriteLine(LogLevel.DEBUG,$"Start");
if (!Authorizations.GetInstance().IsAuthorized(token)) return null;
Prices prices=PricingDA.GetPrices(symbol,dayCount);
BollingerBands bollingerBands=BollingerBandGenerator.GenerateBollingerBands(prices);
@@ -49,14 +55,19 @@ namespace MarketDataServer.Controllers
MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}");
return null;
}
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()} (ms)");
}
}
[HttpGet(Name = "GetLatestPricingDate")]
public DateTime GetLatestPricingDate(String token)
{
Profiler profiler = new Profiler();
try
{
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][PriceController::GetLatestPricingDate]", DateTime.Now));
MDTrace.WriteLine(LogLevel.DEBUG,$"Start");
if (!Authorizations.GetInstance().IsAuthorized(token)) return DateTime.MinValue;
DateTime latestPricingDate=PricingDA.GetLatestDate();
return latestPricingDate;
@@ -66,14 +77,19 @@ namespace MarketDataServer.Controllers
MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}");
return Utility.Epoch;
}
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()} (ms)");
}
}
[HttpGet(Name = "GetCompanyNameForSymbol")]
public String GetCompanyNameForSymbol(String token, String symbol)
{
Profiler profiler = new Profiler();
try
{
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][PortfolioController::GetCompanyNameForSymbol]", DateTime.Now));
MDTrace.WriteLine(LogLevel.DEBUG,$"Start");
if (!Authorizations.GetInstance().IsAuthorized(token)) return null;
String companyName=PricingDA.GetNameForSymbol(symbol);
return companyName;
@@ -83,6 +99,10 @@ namespace MarketDataServer.Controllers
MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}");
return null;
}
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()} (ms)");
}
}
}
}