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

@@ -4,6 +4,7 @@ using MarketDataServer.Authorization;
using MarketData;
using LogLevel = MarketData.LogLevel;
using Microsoft.AspNetCore.Mvc;
using MarketData.Utils;
namespace MarketDataServer.Controllers
{
@@ -14,9 +15,10 @@ namespace MarketDataServer.Controllers
[HttpGet(Name = "GetLatestHeadlines")]
public IEnumerable<Headline> GetLatestHeadlines(String token)
{
Profiler profiler = new Profiler();
try
{
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][HeadlinesController::GetLatestHeadlines]", DateTime.Now));
MDTrace.WriteLine(LogLevel.DEBUG,$"Start");
if (!Authorizations.GetInstance().IsAuthorized(token)) return null;
return HeadlinesDA.GetLatestHeadlines();
}
@@ -25,14 +27,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 = "GetHeadlineDates")]
public IEnumerable<String> GetHeadlineDates(String token)
{
Profiler profiler = new Profiler();
try
{
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][HeadlinesController::GetHeadlineDates]", DateTime.Now));
MDTrace.WriteLine(LogLevel.DEBUG,$"Start");
if (!Authorizations.GetInstance().IsAuthorized(token)) return null;
List<string> headlineDates = HeadlinesDA.GetHeadlineDates();
if(headlineDates.Count>0)headlineDates=headlineDates.Take(252).ToList();
@@ -43,14 +50,18 @@ 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 = "GetHeadlines")]
public IEnumerable<Headline> GetHeadlines(String token,DateTime headlineDate)
{
Profiler profiler = new Profiler();
try
{
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][HeadlinesController::GetHeadliness(DateTime headlineDate)]", DateTime.Now));
MDTrace.WriteLine(LogLevel.DEBUG,$"Start");
if (!Authorizations.GetInstance().IsAuthorized(token)) return null;
return HeadlinesDA.GetHeadlines(headlineDate);
}
@@ -59,6 +70,9 @@ namespace MarketDataServer.Controllers
MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}");
return null;
}
}
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()} (ms)");
} }
}
}