AppCenter to AppInsights migration. (#562)
* Remove AppCenter usage and libraries. * Remove redundant pacakges and add the app insights sink. * Diagnostic id support and manipulating telemetries. * Handling of appdomain unhandled exceptions. * Remove unused package identity package from mail project. * Fixing printing.
This commit is contained in:
38
Wino.Services/Misc/WinoTelemetryConverter.cs
Normal file
38
Wino.Services/Misc/WinoTelemetryConverter.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.ApplicationInsights.Channel;
|
||||
using Microsoft.ApplicationInsights.DataContracts;
|
||||
using Serilog.Events;
|
||||
using Serilog.Sinks.ApplicationInsights.TelemetryConverters;
|
||||
|
||||
namespace Wino.Services.Misc
|
||||
{
|
||||
internal class WinoTelemetryConverter : EventTelemetryConverter
|
||||
{
|
||||
private readonly string _userDiagnosticId;
|
||||
|
||||
public WinoTelemetryConverter(string userDiagnosticId)
|
||||
{
|
||||
_userDiagnosticId = userDiagnosticId;
|
||||
}
|
||||
|
||||
public override IEnumerable<ITelemetry> Convert(LogEvent logEvent, IFormatProvider formatProvider)
|
||||
{
|
||||
foreach (ITelemetry telemetry in base.Convert(logEvent, formatProvider))
|
||||
{
|
||||
// Assign diagnostic id as user id.
|
||||
telemetry.Context.User.Id = _userDiagnosticId;
|
||||
|
||||
yield return telemetry;
|
||||
}
|
||||
}
|
||||
|
||||
public override void ForwardPropertiesToTelemetryProperties(LogEvent logEvent, ISupportProperties telemetryProperties, IFormatProvider formatProvider)
|
||||
{
|
||||
ForwardPropertiesToTelemetryProperties(logEvent, telemetryProperties, formatProvider,
|
||||
includeLogLevel: true,
|
||||
includeRenderedMessage: true,
|
||||
includeMessageTemplate: false);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user