More server logging

This commit is contained in:
Timothy Baldridge 2022-03-31 10:22:38 -06:00
parent 099afa3e2e
commit f21b4569a2
3 changed files with 5 additions and 1 deletions

View File

@ -58,6 +58,7 @@ public class ApiKeyAuthenticationHandler : AuthenticationHandler<ApiKeyAuthentic
var metricsKey = Request.Headers[_settings.MetricsKeyHeader].FirstOrDefault();
// Never needed this, disabled for now
//await LogRequest(metricsKey);
var ip = Request.HttpContext.Connection.RemoteIpAddress?.ToString() ?? "";
if (metricsKey != default)
{
if (await _tarLog.Contains(metricsKey))
@ -67,7 +68,8 @@ public class ApiKeyAuthenticationHandler : AuthenticationHandler<ApiKeyAuthentic
Subject = metricsKey,
Action = "tarlog",
MetricsKey = metricsKey,
UserAgent = Request.Headers.UserAgent
UserAgent = Request.Headers.UserAgent,
Ip = ip
});
await Task.Delay(TimeSpan.FromSeconds(20));
throw new Exception("Error, lipsum timeout of the cross distant cloud.");

View File

@ -79,6 +79,7 @@ public class MetricsController : ControllerBase
Subject = value,
MetricsKey = metricsKey,
UserAgent = Request.Headers.UserAgent.FirstOrDefault() ?? "<unknown>",
Ip = Request.HttpContext.Connection.RemoteIpAddress?.ToString() ?? ""
});
return new Result {Timestamp = date};
}

View File

@ -10,4 +10,5 @@ public class Metric
public string Subject { get; set; }
public string MetricsKey { get; set; }
public string UserAgent { get; set; }
public string Ip { get; set; }
}