/// <summary> /// Set a config instance to be used by epsagon, /// config values are merged with current values /// so you can omit options you don't want to change /// </summary> /// <param name="config">new config to use</param> public void SetConfig(IEpsagonConfiguration config) { _config.Token = this.SelectProp(config.Token, _config.Token); _config.AppName = this.SelectProp(config.AppName, _config.AppName); _config.MetadataOnly = this.SelectProp(config.MetadataOnly, _config.MetadataOnly); _config.UseSSL = this.SelectProp(config.UseSSL, _config.UseSSL); _config.TraceCollectorURL = this.SelectProp(config.TraceCollectorURL, _config.TraceCollectorURL); _config.IsEpsagonDisabled = this.SelectProp(config.IsEpsagonDisabled, _config.IsEpsagonDisabled); }
public static void Bootstrap(bool useOpenTracingCollector = false, IEpsagonConfiguration configuration = null) { var levelSwitch = new LoggingLevelSwitch(LogEventLevel.Error); if ((Environment.GetEnvironmentVariable("EPSAGON_DEBUG") ?? "").ToLower() == "true") { levelSwitch.MinimumLevel = LogEventLevel.Debug; } var loggerConfig = new LoggerConfiguration() .MinimumLevel.ControlledBy(levelSwitch) .Enrich.FromLogContext() .WriteTo.Console(); if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { loggerConfig.WriteTo.EventLog("Epsagon"); } var logConfig = configuration?.LogFile ?? Environment.GetEnvironmentVariable("EPSAGON_LOG_FILE"); if (!string.IsNullOrWhiteSpace(logConfig)) { loggerConfig.WriteTo.File(logConfig); } Log.Logger = loggerConfig.CreateLogger(); if ((Environment.GetEnvironmentVariable("DISABLE_EPSAGON") ?? "").ToUpper() != "TRUE") { if (configuration != null) { Utils.RegisterConfiguration(configuration); } else { Utils.RegisterConfiguration(LoadConfiguration()); } CustomizePipeline(); // Use either legacy tracer or opentracing tracer if (useOpenTracingCollector) { Utils.DebugLogIfEnabled("remote"); JaegerTracer.CreateRemoteTracer(); } else { JaegerTracer.CreateTracer(); } Utils.DebugLogIfEnabled("finished bootstraping epsagon"); } }
public static void RegisterConfiguration(IEpsagonConfiguration configuration) { _config = configuration; }