Answer the question
In order to leave comments, you need to log in
How to collect time metrics correctly?
The question is related to the fact that this is my first experience of collecting metrics.
Do I correctly collect information about the time the request was executed by the server, for example, I have the following code:
// Один из методов контроллера
public IActionResult SomeMethod()
{
DateTime metricsStart = DateTime.Now;
try
{
// что то делаю и возвращаю клиенту результат
return Json( auctions );
}
catch ( Exception e )
{
logger.LogError( $"error! ip:{accessor.HttpContext.Connection.RemoteIpAddress.ToString()} Discription: {e}." );
return Json( "error" );
}
finally
{
string timeDifference= ( DateTime.Now - metricsStart ).TotalMilliseconds.ToString();
logger.LogInformation( $"Ok. ip: {accessor.HttpContext.Connection.RemoteIpAddress.ToString()} Time: {timeDifference}" );
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question