wip
This commit is contained in:
parent
ddb6abc14e
commit
f3ab94eff1
6 changed files with 59 additions and 92 deletions
|
|
@ -3,20 +3,12 @@ using Microsoft.ApplicationInsights.Extensibility;
|
|||
|
||||
namespace PlanTempus.Core.Telemetry.Enrichers
|
||||
{
|
||||
|
||||
public class EnrichWithMetaTelemetry : ITelemetryProcessor
|
||||
public class EnrichWithMetaTelemetry(ITelemetryProcessor next) : ITelemetryProcessor
|
||||
{
|
||||
private readonly ITelemetryProcessor _next;
|
||||
|
||||
public EnrichWithMetaTelemetry(ITelemetryProcessor next)
|
||||
{
|
||||
_next = next;
|
||||
}
|
||||
|
||||
public void Process(ITelemetry item)
|
||||
{
|
||||
//nothing going on here yet :)
|
||||
_next.Process(item);
|
||||
next.Process(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3,20 +3,12 @@ using Microsoft.ApplicationInsights.Channel;
|
|||
|
||||
namespace PlanTempus.Core.Telemetry
|
||||
{
|
||||
public class SeqTelemetryChannel : InMemoryChannel, ITelemetryChannel
|
||||
public class SeqTelemetryChannel(IMessageChannel<ITelemetry> messageChannel, TelemetryClient telemetryClient)
|
||||
: 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.TryGetValue("OmitSeqTelemetryChannel", out string value))
|
||||
if (telemetry.Context.GlobalProperties.TryGetValue("OmitSeqTelemetryChannel", out var value))
|
||||
if (value == "true")
|
||||
{
|
||||
base.Send(telemetry);
|
||||
|
|
@ -25,7 +17,7 @@ namespace PlanTempus.Core.Telemetry
|
|||
|
||||
try
|
||||
{
|
||||
var writeTask = _messageChannel.Writer.WriteAsync(telemetry).AsTask();
|
||||
var writeTask = messageChannel.Writer.WriteAsync(telemetry).AsTask();
|
||||
writeTask.ContinueWith(t =>
|
||||
{
|
||||
if (t.Exception != null)
|
||||
|
|
@ -36,9 +28,11 @@ namespace PlanTempus.Core.Telemetry
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_telemetryClient.TrackException(e, new Dictionary<string, string> { { "OmitSeqTelemetryChannel", "true" } });
|
||||
telemetryClient.TrackException(e,
|
||||
new Dictionary<string, string> { { "OmitSeqTelemetryChannel", "true" } });
|
||||
}
|
||||
|
||||
base.Send(telemetry);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue