public AgentMiddleware(RequestDelegate next, ILogger <AgentMiddleware> logger, IAgentSdk agentSdk, IOptions <NewRelicOptions> optionsAccessor, bool isEnabled = true) { this.next = next; this.logger = logger; this.agentSdk = agentSdk; this.isEnabled = isEnabled; this.options = optionsAccessor.Value; // New Relic agent is only compatible on Linux if (IsEnabledOnLinux()) { InitializeAgent(); } }
public static void Build_Basics_Logger() { // arrage LoggerBuilder builder = new LoggerBuilder(); SeqOptions seqOptions = new SeqOptions { Url = "http://localhost", ApiKey = "123456" }; SplunkOptions splunkOptions = new SplunkOptions { Url = "http://localhost", Token = "123456", Index = "my.index" }; NewRelicOptions newRelicOptions = new NewRelicOptions { AppName = "asd", LicenseKey = "123" }; DataDogOptions dataDogOptions = new DataDogOptions { ApiKey = "123", Service = "service", Host = "host", Tags = new string[] { "tags" }, Source = "source" }; Log.Logger = builder .UseSuggestedSetting("MyDomain", "MyApplication") .SetupSeq(seqOptions) .SetupSplunk(splunkOptions) .SetupNewRelic(newRelicOptions) .SetupDataDog(dataDogOptions) .BuildLogger(); // act var logger = builder.BuildLogger(); // assert Assert.NotNull(logger); }
/// <summary> /// Setup NewRelic /// </summary> /// <param name="options"></param> /// <returns></returns> public LoggerBuilder SetupNewRelic(NewRelicOptions options) { this.OutputConfiguration.NewRelic.Options = options ?? throw new ArgumentNullException(nameof(options)); if (string.IsNullOrWhiteSpace(options.AppName) == true && options.Enabled == true) { throw new ArgumentNullException(nameof(options.AppName)); } if (string.IsNullOrWhiteSpace(options.LicenseKey) == true && options.Enabled == true) { throw new ArgumentNullException(nameof(options.LicenseKey)); } this.OutputConfiguration.NewRelic.Enabled = options.Enabled; return(this); }
public AgentSdk(ILogger <AgentSdk> logger, IOptions <NewRelicOptions> optionsAccessor) { this.logger = logger; this.options = optionsAccessor.Value; }