More work on SeqBackgroundService, next step is tests for it.
This commit is contained in:
parent
a139b1ad08
commit
67207cf90b
27 changed files with 237 additions and 190 deletions
|
|
@ -1,52 +0,0 @@
|
|||
using Microsoft.ApplicationInsights.Channel;
|
||||
using System.Net.Http.Headers;
|
||||
|
||||
namespace Core.Telemetry
|
||||
{
|
||||
public class DebugTelemetryChannel : InMemoryChannel, ITelemetryChannel
|
||||
{
|
||||
private readonly string _filePath;
|
||||
public ITelemetryChannel _defaultChannel;
|
||||
static HttpClient _client = new HttpClient();
|
||||
|
||||
static DebugTelemetryChannel()
|
||||
{
|
||||
_client = new HttpClient()
|
||||
{
|
||||
BaseAddress = new Uri("http://localhost:5341"),
|
||||
Timeout = TimeSpan.FromSeconds(30)
|
||||
};
|
||||
|
||||
_client.DefaultRequestHeaders.Accept.Clear();
|
||||
_client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||
}
|
||||
|
||||
|
||||
public DebugTelemetryChannel(string filePath)
|
||||
{
|
||||
_filePath = filePath;
|
||||
}
|
||||
public new void Send(ITelemetry telemetry)
|
||||
{
|
||||
//var l = new SeqLogger(_client, "", "");
|
||||
|
||||
//l.LogToSeq(
|
||||
// "Bruger {UserId} loggede ind",
|
||||
// "Debug",
|
||||
// new Dictionary<string, object> { { "UserId", "12345" }, { "Counter", "i++" } }
|
||||
// );
|
||||
|
||||
|
||||
//if (telemetry is Microsoft.ApplicationInsights.DataContracts.TraceTelemetry trace)
|
||||
//{
|
||||
// var severity = trace.SeverityLevel;
|
||||
// Console.WriteLine($"Trace severity: {severity}, Message: {trace.Message}");
|
||||
//}
|
||||
|
||||
|
||||
base.Send(telemetry);
|
||||
var logEntry = $"{DateTime.UtcNow:u}|{telemetry.Context.Operation.Name}|{telemetry.Context.Operation.Id}";
|
||||
//File.AppendAllText(_filePath, logEntry + Environment.NewLine);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue