public IHerculesSink Build(BuildContext context) { if (!enabled) { context.LogDisabled("HerculesSink"); return(null); } if (instance != null) { return(instance); } var cluster = clusterProviderBuilder?.Build(context); if (cluster == null) { context.LogDisabled("HerculesSink", "unconfigured cluster provider"); return(null); } var log = context.Log; if (!verboseLogging) { log = log.WithMinimumLevel(LogLevel.Warn); } log = log.DropEvents(evt => evt?.MessageTemplate != null && evt.MessageTemplate.Contains("put event to a disposed")); // Note(kungurtsev): allow null api key provider, streams can be configured later. var settings = new HerculesSinkSettings(cluster, apiKeyProvider ?? (() => null)) { AdditionalSetup = setup => { setup.ClientApplicationName = context.ApplicationIdentity.FormatServiceName(); setup.SetupDistributedTracing(context.Tracer); } }; settingsCustomization.Customize(settings); return(new HerculesSink(settings, log)); }
public IHerculesSink Build(BuildContext context) { if (!enabled) { context.LogDisabled("HerculesSink"); return(null); } if (instance != null) { context.ExternalComponents.Add(instance); return(instance); } var cluster = clusterProviderBuilder?.Build(context); if (cluster == null) { context.LogDisabled("HerculesSink", "unconfigured cluster provider"); return(null); } var log = context.Log; if (!verboseLogging) { log = log.WithMinimumLevel(LogLevel.Warn); } log = log.DropEvents(evt => evt?.MessageTemplate != null && evt.MessageTemplate.Contains("put event to a disposed")); var settings = BuildHerculesSettings(cluster, context); settingsCustomization.Customize(settings); return(new HerculesSink(settings, log)); }