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:
@@ -9,5 +9,7 @@ namespace Wino.Services
|
||||
public string ApplicationDataFolderPath { get; set; }
|
||||
public string PublisherSharedFolderPath { get; set; }
|
||||
public string ApplicationTempFolderPath { get; set; }
|
||||
|
||||
public string ApplicationInsightsInstrumentationKey => "a5a07c2f-6e24-4055-bfc9-88e87eef873a";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using Serilog;
|
||||
using Microsoft.ApplicationInsights.Extensibility;
|
||||
using Serilog;
|
||||
using Serilog.Core;
|
||||
using Serilog.Exceptions;
|
||||
using Wino.Core.Domain.Interfaces;
|
||||
using Wino.Services.Misc;
|
||||
|
||||
namespace Wino.Services
|
||||
{
|
||||
@@ -9,10 +11,15 @@ namespace Wino.Services
|
||||
{
|
||||
private readonly LoggingLevelSwitch _levelSwitch = new LoggingLevelSwitch();
|
||||
private readonly IPreferencesService _preferencesService;
|
||||
private readonly IApplicationConfiguration _applicationConfiguration;
|
||||
private readonly TelemetryConfiguration _telemetryConfiguration;
|
||||
|
||||
public LogInitializer(IPreferencesService preferencesService)
|
||||
public LogInitializer(IPreferencesService preferencesService, IApplicationConfiguration applicationConfiguration)
|
||||
{
|
||||
_preferencesService = preferencesService;
|
||||
_applicationConfiguration = applicationConfiguration;
|
||||
|
||||
_telemetryConfiguration = new TelemetryConfiguration(applicationConfiguration.ApplicationInsightsInstrumentationKey);
|
||||
|
||||
RefreshLoggingLevel();
|
||||
}
|
||||
@@ -28,10 +35,13 @@ namespace Wino.Services
|
||||
|
||||
public void SetupLogger(string fullLogFilePath)
|
||||
{
|
||||
var insightsTelemetryConverter = new WinoTelemetryConverter(_preferencesService.DiagnosticId);
|
||||
|
||||
Log.Logger = new LoggerConfiguration()
|
||||
.MinimumLevel.ControlledBy(_levelSwitch)
|
||||
.WriteTo.File(fullLogFilePath, retainedFileCountLimit: 3, rollOnFileSizeLimit: true, rollingInterval: RollingInterval.Day)
|
||||
.WriteTo.Debug()
|
||||
.WriteTo.ApplicationInsights(_telemetryConfiguration, insightsTelemetryConverter, restrictedToMinimumLevel: Serilog.Events.LogEventLevel.Error)
|
||||
.Enrich.FromLogContext()
|
||||
.Enrich.WithExceptionDetails()
|
||||
.CreateLogger();
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,8 @@ namespace Wino.Services
|
||||
services.AddTransient<IOutlookThreadingStrategy, OutlookThreadingStrategy>();
|
||||
services.AddTransient<IGmailThreadingStrategy, GmailThreadingStrategy>();
|
||||
services.AddTransient<IImapThreadingStrategy, ImapThreadingStrategy>();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,12 +7,13 @@
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="HtmlAgilityPack" />
|
||||
<PackageReference Include="Ical.Net" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" />
|
||||
<PackageReference Include="Serilog" />
|
||||
<PackageReference Include="Serilog.Sinks.Debug" />
|
||||
<PackageReference Include="Serilog.Sinks.File" />
|
||||
<PackageReference Include="Serilog.Exceptions" />
|
||||
<PackageReference Include="Ical.Net" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" />
|
||||
<PackageReference Include="Serilog" />
|
||||
<PackageReference Include="Serilog.Sinks.Debug" />
|
||||
<PackageReference Include="Serilog.Sinks.File" />
|
||||
<PackageReference Include="Serilog.Exceptions" />
|
||||
<PackageReference Include="Serilog.Sinks.ApplicationInsights" />
|
||||
<PackageReference Include="SqlKata" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user