/// <summary> /// Construct a sink that uses datadog with the specified details. /// </summary> /// <param name="datadogConfiguration">Connection information used to construct the Datadog client.</param> /// <param name="batchSizeLimit">The maximum number of events to post in a single batch.</param> /// <param name="period">The time to wait between checking for event batches.</param> /// <param name="textFormatter">Supplies culture-specific formatting information, or null.</param> public DatadogSink(DatadogConfiguration datadogConfiguration, int batchSizeLimit, TimeSpan period, ITextFormatter textFormatter) : base(batchSizeLimit, period) { if (datadogConfiguration == null) throw new ArgumentNullException("datadogConfiguration"); _datadogConfiguration = datadogConfiguration; _textFormatter = textFormatter; _statsdUdp = new StatsdUDP(datadogConfiguration.StatsdServer, datadogConfiguration.StatsdPort); _statsd = new Statsd(_statsdUdp); }
/// <summary> /// Construct a sink that uses datadog with the specified details. /// </summary> /// <param name="datadogConfiguration">Connection information used to construct the Datadog client.</param> /// <param name="batchSizeLimit">The maximum number of events to post in a single batch.</param> /// <param name="period">The time to wait between checking for event batches.</param> /// <param name="textFormatter">Supplies culture-specific formatting information, or null.</param> public DatadogSink(DatadogConfiguration datadogConfiguration, int batchSizeLimit, TimeSpan period, ITextFormatter textFormatter) : base(batchSizeLimit, period) { if (datadogConfiguration == null) { throw new ArgumentNullException("datadogConfiguration"); } _datadogConfiguration = datadogConfiguration; _textFormatter = textFormatter; _statsdUdp = new StatsdUDP(datadogConfiguration.StatsdServer, datadogConfiguration.StatsdPort); _statsd = new Statsd(_statsdUdp); }
/// <summary> /// Adds a sink that sends log events via datadog. /// </summary> /// <param name="loggerConfiguration">The logger configuration.</param> /// <param name="datadogConfiguration">The configuration used for writing events to datadog.</param> /// <param name="outputTemplate">A message template describing the format used to write to the sink. /// the default is "{Timestamp} [{Level}] {Message}{NewLine}{Exception}".</param> /// <param name="restrictedToMinimumLevel">The minimum log event level required in order to write an event to the sink.</param> /// <param name="batchPostingLimit">The maximum number of events to post in a single batch.</param> /// <param name="period">The time to wait between checking for event batches.</param> /// <param name="formatProvider">Supplies culture-specific formatting information, or null.</param> /// <returns>Logger configuration, allowing datadogConfiguration to continue.</returns> /// <exception cref="ArgumentNullException">A required parameter is null.</exception> public static LoggerConfiguration Datadog( this LoggerSinkConfiguration loggerConfiguration, DatadogConfiguration datadogConfiguration, string outputTemplate = DefaultOutputTemplate, LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum, int batchPostingLimit = DatadogSink.DefaultBatchPostingLimit, TimeSpan? period = null, IFormatProvider formatProvider = null) { if (datadogConfiguration == null) throw new ArgumentNullException("datadogConfiguration"); var defaultedPeriod = period ?? DatadogSink.DefaultPeriod; var formatter = new MessageTemplateTextFormatter(outputTemplate, formatProvider); var datadogSink = new DatadogSink(datadogConfiguration, batchPostingLimit, defaultedPeriod, formatter); return loggerConfiguration.Sink(datadogSink, restrictedToMinimumLevel); }