Enhancing telemetry in Seq and fixes namespaces
This commit is contained in:
parent
5568007237
commit
9f4996bc8f
65 changed files with 1122 additions and 1139 deletions
|
|
@ -1,71 +1,48 @@
|
|||
using Autofac;
|
||||
using Microsoft.ApplicationInsights;
|
||||
using Microsoft.ApplicationInsights.Channel;
|
||||
using Microsoft.ApplicationInsights.Extensibility;
|
||||
using Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel;
|
||||
|
||||
namespace Core.ModuleRegistry
|
||||
namespace PlanTempus.Core.ModuleRegistry
|
||||
{
|
||||
public class TelemetryModule : Module
|
||||
{
|
||||
public TelemetryConfig TelemetryConfig { get; set; }
|
||||
protected override void Load(ContainerBuilder builder)
|
||||
{
|
||||
if (TelemetryConfig == null)
|
||||
throw new Exceptions.ConfigurationException("TelemetryConfig is missing");
|
||||
public class TelemetryModule : Module
|
||||
{
|
||||
public TelemetryConfig TelemetryConfig { get; set; }
|
||||
|
||||
//builder.Register(c =>
|
||||
//{
|
||||
// var channel = new Telemetry.DualTelemetryChannel("C:\\logs\\telemetry.log");
|
||||
// channel.DeveloperMode = true;
|
||||
// var config = new TelemetryConfiguration
|
||||
// {
|
||||
|
||||
// ConnectionString = TelemetryConfig.ConnectionString,
|
||||
// TelemetryChannel = channel
|
||||
// };
|
||||
// return new TelemetryClient(config);
|
||||
//}).InstancePerLifetimeScope();
|
||||
|
||||
var telemetryChannel = new InMemoryChannel
|
||||
{
|
||||
DeveloperMode = true
|
||||
};
|
||||
|
||||
//var configuration = new TelemetryConfiguration
|
||||
//{
|
||||
// ConnectionString = TelemetryConfig.ConnectionString,
|
||||
// TelemetryChannel = telemetryChannel
|
||||
//};
|
||||
|
||||
//telemetryChannel.Initialize(configuration);
|
||||
protected override void Load(ContainerBuilder builder)
|
||||
{
|
||||
if (TelemetryConfig == null)
|
||||
throw new Exceptions.ConfigurationException("TelemetryConfig is missing");
|
||||
|
||||
|
||||
var tmc = Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.CreateDefault();
|
||||
tmc.ConnectionString = TelemetryConfig.ConnectionString;
|
||||
tmc.TelemetryChannel.DeveloperMode = true;
|
||||
var channel = new Telemetry.SeqLoggingTelemetryChannel("C:\\logs\\telemetry.log");
|
||||
var configuration = TelemetryConfiguration.CreateDefault();
|
||||
configuration.ConnectionString = TelemetryConfig.ConnectionString;
|
||||
configuration.TelemetryChannel.DeveloperMode = true;
|
||||
|
||||
tmc.TelemetryChannel = channel;
|
||||
if (TelemetryConfig.UseSeqLoggingTelemetryChannel)
|
||||
configuration.TelemetryChannel = new Telemetry.SeqLoggingTelemetryChannel(); ;
|
||||
|
||||
////var r = new Microsoft.ApplicationInsights.Extensibility.Implementation.TelemetryProcessorChainBuilder(tmc);
|
||||
////r.Use(next => new Domain.EventTelemetryEnrichers.EnrichWithMetaTelemetry(next));
|
||||
////r.Build();
|
||||
var r = new Microsoft.ApplicationInsights.Extensibility.Implementation.TelemetryProcessorChainBuilder(configuration);
|
||||
r.Use(next => new Telemetry.Enrichers.EnrichWithMetaTelemetry(next));
|
||||
r.Build();
|
||||
|
||||
//builder.RegisterInstance(configuration);
|
||||
builder.Register(c => new TelemetryClient(tmc)).InstancePerLifetimeScope();
|
||||
//builder.RegisterInstance(configuration);
|
||||
|
||||
//builder.RegisterType<Microsoft.ApplicationInsights.TelemetryClient>()
|
||||
// .InstancePerLifetimeScope();
|
||||
//builder.RegisterType<Microsoft.ApplicationInsights.TelemetryClient>()
|
||||
// .InstancePerLifetimeScope();
|
||||
|
||||
//builder.RegisterType<Microsoft.ApplicationInsights.TelemetryClient>()
|
||||
// .As<Telemetry.ITelemetryClient>()
|
||||
// .InstancePerLifetimeScope();
|
||||
}
|
||||
}
|
||||
var client = new Microsoft.ApplicationInsights.TelemetryClient(configuration);
|
||||
client.Context.GlobalProperties["Application"] = GetType().Namespace.Split('.')[0];
|
||||
client.Context.GlobalProperties["MachineName"] = Environment.MachineName;
|
||||
client.Context.GlobalProperties["Version"] = Environment.Version.ToString();
|
||||
client.Context.GlobalProperties["ProcessorCount"] = Environment.ProcessorCount.ToString();
|
||||
|
||||
public class TelemetryConfig
|
||||
{
|
||||
public string ConnectionString { get; set; }
|
||||
}
|
||||
builder.Register(c => client).InstancePerLifetimeScope();
|
||||
}
|
||||
}
|
||||
|
||||
public class TelemetryConfig
|
||||
{
|
||||
public string ConnectionString { get; set; }
|
||||
public bool UseSeqLoggingTelemetryChannel { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue