2025-02-05 18:38:29 +01:00
|
|
|
|
using Microsoft.ApplicationInsights.Channel;
|
|
|
|
|
|
|
2025-02-20 00:23:13 +01:00
|
|
|
|
namespace PlanTempus.Core.Telemetry
|
2025-02-05 18:38:29 +01:00
|
|
|
|
{
|
2025-02-18 16:23:08 +01:00
|
|
|
|
public class SeqLoggingTelemetryChannel : InMemoryChannel, ITelemetryChannel
|
2025-02-05 18:38:29 +01:00
|
|
|
|
{
|
2025-02-21 23:34:06 +01:00
|
|
|
|
private readonly IMessageChannel<ITelemetry> _messageChannel;
|
2025-02-05 18:38:29 +01:00
|
|
|
|
|
2025-02-21 23:34:06 +01:00
|
|
|
|
public SeqLoggingTelemetryChannel(IMessageChannel<ITelemetry> messageChannel)
|
2025-02-05 18:38:29 +01:00
|
|
|
|
{
|
2025-02-21 23:34:06 +01:00
|
|
|
|
_messageChannel = messageChannel;
|
2025-02-05 18:38:29 +01:00
|
|
|
|
}
|
2025-02-06 17:48:24 +01:00
|
|
|
|
public new void Send(ITelemetry telemetry)
|
2025-02-05 18:38:29 +01:00
|
|
|
|
{
|
2025-02-21 23:34:06 +01:00
|
|
|
|
var writeTask = _messageChannel.Writer.WriteAsync(telemetry).AsTask();
|
|
|
|
|
|
writeTask.ContinueWith(t =>
|
|
|
|
|
|
{
|
|
|
|
|
|
if (t.Exception != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw t.Exception;
|
|
|
|
|
|
}
|
|
|
|
|
|
}, TaskContinuationOptions.OnlyOnFaulted);
|
2025-02-06 17:48:24 +01:00
|
|
|
|
|
|
|
|
|
|
base.Send(telemetry);
|
2025-02-05 18:38:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|