This is near the end of this Seq Logging Implementation
This commit is contained in:
parent
78d49a9829
commit
099f6467d2
9 changed files with 212 additions and 123 deletions
|
|
@ -1,27 +0,0 @@
|
|||
using Microsoft.ApplicationInsights.Channel;
|
||||
|
||||
namespace PlanTempus.Core.Telemetry
|
||||
{
|
||||
public class SeqLoggingTelemetryChannel : InMemoryChannel, ITelemetryChannel
|
||||
{
|
||||
private readonly IMessageChannel<ITelemetry> _messageChannel;
|
||||
|
||||
public SeqLoggingTelemetryChannel(IMessageChannel<ITelemetry> messageChannel)
|
||||
{
|
||||
_messageChannel = messageChannel;
|
||||
}
|
||||
public new void Send(ITelemetry telemetry)
|
||||
{
|
||||
var writeTask = _messageChannel.Writer.WriteAsync(telemetry).AsTask();
|
||||
writeTask.ContinueWith(t =>
|
||||
{
|
||||
if (t.Exception != null)
|
||||
{
|
||||
throw t.Exception;
|
||||
}
|
||||
}, TaskContinuationOptions.OnlyOnFaulted);
|
||||
|
||||
base.Send(telemetry);
|
||||
}
|
||||
}
|
||||
}
|
||||
37
Core/Telemetry/SeqTelemetryChannel.cs
Normal file
37
Core/Telemetry/SeqTelemetryChannel.cs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
using Microsoft.ApplicationInsights;
|
||||
using Microsoft.ApplicationInsights.Channel;
|
||||
|
||||
namespace PlanTempus.Core.Telemetry
|
||||
{
|
||||
public class SeqTelemetryChannel : InMemoryChannel, ITelemetryChannel
|
||||
{
|
||||
private readonly IMessageChannel<ITelemetry> _messageChannel;
|
||||
private readonly TelemetryClient _telemetryClient;
|
||||
|
||||
public SeqTelemetryChannel(IMessageChannel<ITelemetry> messageChannel, TelemetryClient telemetryClient)
|
||||
{
|
||||
_messageChannel = messageChannel;
|
||||
_telemetryClient = telemetryClient;
|
||||
}
|
||||
public new void Send(ITelemetry telemetry)
|
||||
{
|
||||
if (telemetry.Context.GlobalProperties["OmitSeqTelemetryChannel"] != "true")
|
||||
try
|
||||
{
|
||||
var writeTask = _messageChannel.Writer.WriteAsync(telemetry).AsTask();
|
||||
writeTask.ContinueWith(t =>
|
||||
{
|
||||
if (t.Exception != null)
|
||||
{
|
||||
throw t.Exception;
|
||||
}
|
||||
}, TaskContinuationOptions.OnlyOnFaulted);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_telemetryClient.TrackException(e, new Dictionary<string, string> { { "OmitSeqTelemetryChannel", "true" } });
|
||||
}
|
||||
base.Send(telemetry);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue