Refactoring SetupConsole with DBFactory
This commit is contained in:
parent
8dd01d291d
commit
78d49a9829
20 changed files with 337 additions and 407 deletions
|
|
@ -11,9 +11,9 @@ namespace PlanTempus.Core.ModuleRegistry
|
|||
protected override void Load(ContainerBuilder builder)
|
||||
{
|
||||
|
||||
builder.RegisterType<MessageChannel>()
|
||||
.As<IMessageChannel<Microsoft.ApplicationInsights.Channel.ITelemetry>>()
|
||||
.SingleInstance();
|
||||
//builder.RegisterType<MessageChannel>()
|
||||
// .As<IMessageChannel<Microsoft.ApplicationInsights.Channel.ITelemetry>>()
|
||||
// .SingleInstance();
|
||||
|
||||
builder.RegisterType<SeqBackgroundService>()
|
||||
.As<Microsoft.Extensions.Hosting.IHostedService>()
|
||||
|
|
|
|||
|
|
@ -6,29 +6,30 @@ namespace PlanTempus.Core.ModuleRegistry
|
|||
{
|
||||
public class TelemetryModule : Module
|
||||
{
|
||||
public TelemetryConfig TelemetryConfig { get; set; }
|
||||
public required TelemetryConfig TelemetryConfig { get; set; }
|
||||
|
||||
protected override void Load(ContainerBuilder builder)
|
||||
{
|
||||
if (TelemetryConfig == null)
|
||||
throw new Exceptions.ConfigurationException("TelemetryConfig is missing");
|
||||
|
||||
|
||||
var configuration = TelemetryConfiguration.CreateDefault();
|
||||
configuration.ConnectionString = TelemetryConfig.ConnectionString;
|
||||
configuration.TelemetryChannel.DeveloperMode = true;
|
||||
|
||||
if (TelemetryConfig.UseSeqLoggingTelemetryChannel)
|
||||
configuration.TelemetryChannel = new Telemetry.SeqLoggingTelemetryChannel(); ;
|
||||
{
|
||||
var messageChannel = new Telemetry.MessageChannel();
|
||||
|
||||
var r = new Microsoft.ApplicationInsights.Extensibility.Implementation.TelemetryProcessorChainBuilder(configuration);
|
||||
r.Use(next => new Telemetry.Enrichers.EnrichWithMetaTelemetry(next));
|
||||
r.Build();
|
||||
builder.RegisterInstance(messageChannel)
|
||||
.As<Telemetry.IMessageChannel<ITelemetry>>()
|
||||
.SingleInstance();
|
||||
|
||||
//builder.RegisterInstance(configuration);
|
||||
configuration.TelemetryChannel = new Telemetry.SeqLoggingTelemetryChannel(messageChannel);
|
||||
}
|
||||
|
||||
var telemetryProcessorChain = new Microsoft.ApplicationInsights.Extensibility.Implementation.TelemetryProcessorChainBuilder(configuration);
|
||||
telemetryProcessorChain.Use(next => new Telemetry.Enrichers.EnrichWithMetaTelemetry(next));
|
||||
telemetryProcessorChain.Build();
|
||||
|
||||
//builder.RegisterType<Microsoft.ApplicationInsights.TelemetryClient>()
|
||||
// .InstancePerLifetimeScope();
|
||||
|
||||
var client = new Microsoft.ApplicationInsights.TelemetryClient(configuration);
|
||||
client.Context.GlobalProperties["Application"] = GetType().Namespace.Split('.')[0];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue