Initialization code and entry point for Self Diagnostics Module
This commit is contained in:
Родитель
2b19327fc5
Коммит
3b1807800c
|
@ -57,6 +57,7 @@
|
|||
try
|
||||
{
|
||||
SdkInternalOperationsMonitor.Enter();
|
||||
SelfDiagnosticsModule.EnsureInitialized();
|
||||
|
||||
if (modules != null && !modules.Modules.Any(module => module is DiagnosticsTelemetryModule))
|
||||
{
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
namespace Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing
|
||||
{
|
||||
using System;
|
||||
|
||||
/// <summary>
|
||||
/// Self diagnostics class captures the EventSource events sent by Application Insights
|
||||
/// modules and writes them to local file for internal troubleshooting.
|
||||
/// </summary>
|
||||
class SelfDiagnosticsModule : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Long-living object that hold relevant resources.
|
||||
/// </summary>
|
||||
private static readonly SelfDiagnosticsModule Instance = new SelfDiagnosticsModule();
|
||||
|
||||
// Long-living object that holds a refresher which checks whether the configuration file was updated
|
||||
// every 10 seconds.
|
||||
// private readonly SelfDiagnosticsConfigRefresher configRefresher;
|
||||
|
||||
static SelfDiagnosticsModule()
|
||||
{
|
||||
AppDomain.CurrentDomain.ProcessExit += (sender, eventArgs) =>
|
||||
{
|
||||
Instance.Dispose();
|
||||
};
|
||||
}
|
||||
|
||||
private SelfDiagnosticsModule()
|
||||
{
|
||||
// this.configRefresher = new SelfDiagnosticsConfigRefresher();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Trigger CLR to initialize static fields and static constructors of SelfDiagnosticsModule.
|
||||
/// No member of SelfDiagnosticsModule class is explicitly called when an EventSource class, say
|
||||
/// AspNetCoreEventSource, is invoked to send an event.
|
||||
/// This method needs to be called in order to capture any EventSource event.
|
||||
/// </summary>
|
||||
public static void EnsureInitialized()
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Dispose()
|
||||
{
|
||||
this.Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
// this.configRefresher.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче