WIP
This commit is contained in:
parent
54b057886c
commit
7fc1ae0650
204 changed files with 4345 additions and 134 deletions
38
PlanTempus.Core/Telemetry/SeqTelemetryChannel.cs
Normal file
38
PlanTempus.Core/Telemetry/SeqTelemetryChannel.cs
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
using Microsoft.ApplicationInsights;
|
||||
using Microsoft.ApplicationInsights.Channel;
|
||||
|
||||
namespace PlanTempus.Core.Telemetry
|
||||
{
|
||||
public class SeqTelemetryChannel(IMessageChannel<ITelemetry> messageChannel, TelemetryClient telemetryClient)
|
||||
: InMemoryChannel, ITelemetryChannel
|
||||
{
|
||||
public new void Send(ITelemetry telemetry)
|
||||
{
|
||||
if (telemetry.Context.GlobalProperties.TryGetValue("OmitSeqTelemetryChannel", out var value))
|
||||
if (value == "true")
|
||||
{
|
||||
base.Send(telemetry);
|
||||
return;
|
||||
}
|
||||
|
||||
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