From dfd081c3248f03112a6274b17e3f4b0c44991426 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Jun 2024 13:57:09 +0000 Subject: [PATCH 1/2] Bump Serilog from 3.1.1 to 4.0.0 Bumps [Serilog](https://github.com/serilog/serilog) from 3.1.1 to 4.0.0. - [Release notes](https://github.com/serilog/serilog/releases) - [Commits](https://github.com/serilog/serilog/compare/v3.1.1...v4.0.0) --- updated-dependencies: - dependency-name: Serilog dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- sample/Sample/Sample.csproj | 2 +- src/Serilog.Sinks.Splunk/Serilog.Sinks.Splunk.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sample/Sample/Sample.csproj b/sample/Sample/Sample.csproj index f455830..ea77fd8 100644 --- a/sample/Sample/Sample.csproj +++ b/sample/Sample/Sample.csproj @@ -8,7 +8,7 @@ - + diff --git a/src/Serilog.Sinks.Splunk/Serilog.Sinks.Splunk.csproj b/src/Serilog.Sinks.Splunk/Serilog.Sinks.Splunk.csproj index 70e704f..7dc4f13 100644 --- a/src/Serilog.Sinks.Splunk/Serilog.Sinks.Splunk.csproj +++ b/src/Serilog.Sinks.Splunk/Serilog.Sinks.Splunk.csproj @@ -18,7 +18,7 @@ - + From bda4bce034d3296095dadab081d8193d081c64a0 Mon Sep 17 00:00:00 2001 From: EEParker Date: Wed, 5 Jun 2024 14:13:01 -0500 Subject: [PATCH 2/2] Drop dependency Serilog.Sinks.PeriodicBatching in favor of built in batching from Serilog 4.0 --- .../Serilog.Sinks.Splunk.csproj | 3 +-- .../Splunk/CompactSplunkJsonFormatter.cs | 1 - .../Sinks/Splunk/CustomField.cs | 6 +---- .../Sinks/Splunk/CustomFields.cs | 6 +---- .../Sinks/Splunk/EventCollectorSink.cs | 17 +++++------- .../Sinks/Splunk/SplunkJsonFormatter.cs | 1 - .../SplunkLoggingConfigurationExtensions.cs | 26 +++++++------------ src/Serilog.Sinks.UDP/Sinks/Splunk/UdpSink.cs | 3 +-- .../SplunkLoggingConfigurationExtensions.cs | 17 +++++------- src/common.props | 2 +- .../TCPCollectorTests.cs | 6 ----- .../EpochExtensionsTests.cs | 4 +-- 12 files changed, 28 insertions(+), 64 deletions(-) diff --git a/src/Serilog.Sinks.Splunk/Serilog.Sinks.Splunk.csproj b/src/Serilog.Sinks.Splunk/Serilog.Sinks.Splunk.csproj index 7dc4f13..399996f 100644 --- a/src/Serilog.Sinks.Splunk/Serilog.Sinks.Splunk.csproj +++ b/src/Serilog.Sinks.Splunk/Serilog.Sinks.Splunk.csproj @@ -1,6 +1,6 @@  - + The Splunk Sink for Serilog @@ -19,7 +19,6 @@ - diff --git a/src/Serilog.Sinks.Splunk/Sinks/Splunk/CompactSplunkJsonFormatter.cs b/src/Serilog.Sinks.Splunk/Sinks/Splunk/CompactSplunkJsonFormatter.cs index 7b56f49..b587b8d 100644 --- a/src/Serilog.Sinks.Splunk/Sinks/Splunk/CompactSplunkJsonFormatter.cs +++ b/src/Serilog.Sinks.Splunk/Sinks/Splunk/CompactSplunkJsonFormatter.cs @@ -17,7 +17,6 @@ using Serilog.Formatting.Json; using Serilog.Parsing; using System; -using System.Globalization; using System.IO; using System.Linq; diff --git a/src/Serilog.Sinks.Splunk/Sinks/Splunk/CustomField.cs b/src/Serilog.Sinks.Splunk/Sinks/Splunk/CustomField.cs index 85ed968..b3d2908 100644 --- a/src/Serilog.Sinks.Splunk/Sinks/Splunk/CustomField.cs +++ b/src/Serilog.Sinks.Splunk/Sinks/Splunk/CustomField.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Collections.Generic; namespace Serilog.Sinks.Splunk { /// diff --git a/src/Serilog.Sinks.Splunk/Sinks/Splunk/CustomFields.cs b/src/Serilog.Sinks.Splunk/Sinks/Splunk/CustomFields.cs index aa072d8..0e875c9 100644 --- a/src/Serilog.Sinks.Splunk/Sinks/Splunk/CustomFields.cs +++ b/src/Serilog.Sinks.Splunk/Sinks/Splunk/CustomFields.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Collections.Generic; namespace Serilog.Sinks.Splunk { diff --git a/src/Serilog.Sinks.Splunk/Sinks/Splunk/EventCollectorSink.cs b/src/Serilog.Sinks.Splunk/Sinks/Splunk/EventCollectorSink.cs index 6f455f5..91bb299 100644 --- a/src/Serilog.Sinks.Splunk/Sinks/Splunk/EventCollectorSink.cs +++ b/src/Serilog.Sinks.Splunk/Sinks/Splunk/EventCollectorSink.cs @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. +using Serilog.Core; using Serilog.Debugging; using Serilog.Events; using Serilog.Formatting; -using Serilog.Sinks.PeriodicBatching; using System; using System.Collections.Generic; using System.IO; @@ -177,15 +177,15 @@ public EventCollectorSink( : new EventCollectorClient(eventCollectorToken); } - /// - /// Emit a batch of log events, running asynchronously. - /// - /// The events to emit. - public virtual async Task EmitBatchAsync(IEnumerable events) + /// + public virtual Task OnEmptyBatchAsync() => Task.CompletedTask; + + /// + public virtual async Task EmitBatchAsync(IReadOnlyCollection batch) { var allEvents = new StringWriter(); - foreach (var logEvent in events) + foreach (var logEvent in batch) { _jsonFormatter.Format(logEvent, allEvents); } @@ -210,8 +210,5 @@ public virtual async Task EmitBatchAsync(IEnumerable events) } } } - - /// - public Task OnEmptyBatchAsync() => Task.CompletedTask; } } diff --git a/src/Serilog.Sinks.Splunk/Sinks/Splunk/SplunkJsonFormatter.cs b/src/Serilog.Sinks.Splunk/Sinks/Splunk/SplunkJsonFormatter.cs index ef03c47..9926c24 100644 --- a/src/Serilog.Sinks.Splunk/Sinks/Splunk/SplunkJsonFormatter.cs +++ b/src/Serilog.Sinks.Splunk/Sinks/Splunk/SplunkJsonFormatter.cs @@ -17,7 +17,6 @@ using Serilog.Formatting.Json; using System; using System.Collections.Generic; -using System.Globalization; using System.IO; namespace Serilog.Sinks.Splunk diff --git a/src/Serilog.Sinks.Splunk/SplunkLoggingConfigurationExtensions.cs b/src/Serilog.Sinks.Splunk/SplunkLoggingConfigurationExtensions.cs index 861ae25..04dc1c9 100644 --- a/src/Serilog.Sinks.Splunk/SplunkLoggingConfigurationExtensions.cs +++ b/src/Serilog.Sinks.Splunk/SplunkLoggingConfigurationExtensions.cs @@ -17,7 +17,6 @@ using Serilog.Core; using Serilog.Events; using Serilog.Formatting; -using Serilog.Sinks.PeriodicBatching; using Serilog.Sinks.Splunk; using System; using System.Net.Http; @@ -73,10 +72,10 @@ public static LoggerConfiguration EventCollector( { if (configuration == null) throw new ArgumentNullException(nameof(configuration)); - var batchingOptions = new PeriodicBatchingSinkOptions + var batchingOptions = new BatchingOptions { BatchSizeLimit = batchSizeLimit, - Period = TimeSpan.FromSeconds(batchIntervalInSeconds), + BufferingTimeLimit = TimeSpan.FromSeconds(batchIntervalInSeconds), EagerlyEmitFirstEvent = true, QueueLimit = queueLimit }; @@ -95,9 +94,7 @@ public static LoggerConfiguration EventCollector( messageHandler: messageHandler, subSecondPrecision: subSecondPrecision); - var batchingSink = new PeriodicBatchingSink(eventCollectorSink, batchingOptions); - - return configuration.Sink(batchingSink, restrictedToMinimumLevel, levelSwitch); + return configuration.Sink(eventCollectorSink, batchingOptions, restrictedToMinimumLevel, levelSwitch); } /// @@ -132,10 +129,10 @@ public static LoggerConfiguration EventCollector( if (jsonFormatter == null) throw new ArgumentNullException(nameof(jsonFormatter)); - var batchingOptions = new PeriodicBatchingSinkOptions + var batchingOptions = new BatchingOptions { BatchSizeLimit = batchSizeLimit, - Period = TimeSpan.FromSeconds(batchIntervalInSeconds), + BufferingTimeLimit = TimeSpan.FromSeconds(batchIntervalInSeconds), EagerlyEmitFirstEvent = true, QueueLimit = queueLimit }; @@ -147,9 +144,7 @@ public static LoggerConfiguration EventCollector( jsonFormatter, messageHandler); - var batchingSink = new PeriodicBatchingSink(eventCollectorSink, batchingOptions); - - return configuration.Sink(batchingSink, restrictedToMinimumLevel, levelSwitch); + return configuration.Sink(eventCollectorSink, batchingOptions, restrictedToMinimumLevel, levelSwitch); } @@ -199,10 +194,10 @@ public static LoggerConfiguration EventCollector( { if (configuration == null) throw new ArgumentNullException(nameof(configuration)); - var batchingOptions = new PeriodicBatchingSinkOptions + var batchingOptions = new BatchingOptions { BatchSizeLimit = batchSizeLimit, - Period = TimeSpan.FromSeconds(batchIntervalInSeconds), + BufferingTimeLimit = TimeSpan.FromSeconds(batchIntervalInSeconds), EagerlyEmitFirstEvent = true, QueueLimit = queueLimit }; @@ -223,10 +218,7 @@ public static LoggerConfiguration EventCollector( subSecondPrecision: subSecondPrecision ); - - var batchingSink = new PeriodicBatchingSink(eventCollectorSink, batchingOptions); - - return configuration.Sink(batchingSink, restrictedToMinimumLevel, levelSwitch); + return configuration.Sink(eventCollectorSink, batchingOptions, restrictedToMinimumLevel, levelSwitch); } } } diff --git a/src/Serilog.Sinks.UDP/Sinks/Splunk/UdpSink.cs b/src/Serilog.Sinks.UDP/Sinks/Splunk/UdpSink.cs index 7ce99a2..f5d4c14 100644 --- a/src/Serilog.Sinks.UDP/Sinks/Splunk/UdpSink.cs +++ b/src/Serilog.Sinks.UDP/Sinks/Splunk/UdpSink.cs @@ -21,7 +21,6 @@ using System.Net.Sockets; using System.Text; using System.Threading.Tasks; -using Serilog.Sinks.PeriodicBatching; namespace Serilog.Sinks.Splunk { @@ -95,7 +94,7 @@ private void DisposeSocket() /// or , /// not both. /// - public async Task EmitBatchAsync(IEnumerable batch) + public async Task EmitBatchAsync(IReadOnlyCollection batch) { foreach (var logEvent in batch) { diff --git a/src/Serilog.Sinks.UDP/SplunkLoggingConfigurationExtensions.cs b/src/Serilog.Sinks.UDP/SplunkLoggingConfigurationExtensions.cs index 1ec70ee..737af66 100644 --- a/src/Serilog.Sinks.UDP/SplunkLoggingConfigurationExtensions.cs +++ b/src/Serilog.Sinks.UDP/SplunkLoggingConfigurationExtensions.cs @@ -15,7 +15,6 @@ using Serilog.Configuration; using Serilog.Events; using Serilog.Formatting; -using Serilog.Sinks.PeriodicBatching; using Serilog.Sinks.Splunk; using System; @@ -44,19 +43,17 @@ public static LoggerConfiguration SplunkViaUdp( bool renderTemplate = true, bool renderMessage = true) { - var batchingOptions = new PeriodicBatchingSinkOptions + var batchingOptions = new BatchingOptions { BatchSizeLimit = connectionInfo.BatchPostingLimit, - Period = connectionInfo.Period, + BufferingTimeLimit = connectionInfo.Period, EagerlyEmitFirstEvent = true, QueueLimit = connectionInfo.QueueSizeLimit }; var sink = new UdpSink(connectionInfo, formatProvider, renderTemplate, renderMessage); - var batchingSink = new PeriodicBatchingSink(sink, batchingOptions); - - return loggerConfiguration.Sink(batchingSink, restrictedToMinimumLevel); + return loggerConfiguration.Sink(sink, batchingOptions, restrictedToMinimumLevel); } /// @@ -73,19 +70,17 @@ public static LoggerConfiguration SplunkViaUdp( ITextFormatter formatter, LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum) { - var batchingOptions = new PeriodicBatchingSinkOptions + var batchingOptions = new BatchingOptions { BatchSizeLimit = connectionInfo.BatchPostingLimit, - Period = connectionInfo.Period, + BufferingTimeLimit = connectionInfo.Period, EagerlyEmitFirstEvent = true, QueueLimit = connectionInfo.QueueSizeLimit }; var sink = new UdpSink(connectionInfo, formatter); - var batchingSink = new PeriodicBatchingSink(sink, batchingOptions); - - return loggerConfiguration.Sink(batchingSink, restrictedToMinimumLevel); + return loggerConfiguration.Sink(sink, batchingOptions, restrictedToMinimumLevel); } } } diff --git a/src/common.props b/src/common.props index 0d14599..b0442c9 100644 --- a/src/common.props +++ b/src/common.props @@ -1,7 +1,7 @@ - 4.1.1 + 5.0.0 debug Matthew Erbs, Serilog Contributors true diff --git a/test/Serilog.Sinks.Splunk.TCP.Tests/TCPCollectorTests.cs b/test/Serilog.Sinks.Splunk.TCP.Tests/TCPCollectorTests.cs index e66210a..293e5c9 100644 --- a/test/Serilog.Sinks.Splunk.TCP.Tests/TCPCollectorTests.cs +++ b/test/Serilog.Sinks.Splunk.TCP.Tests/TCPCollectorTests.cs @@ -1,12 +1,6 @@ using System; -using System.Collections.Generic; -using System.Linq; using System.Net; -using System.Net.NetworkInformation; using System.Net.Sockets; -using System.Text; -using System.Threading; -using System.Threading.Tasks; using Serilog.Events; using Xunit; diff --git a/test/Serilog.Sinks.Splunk.Tests/EpochExtensionsTests.cs b/test/Serilog.Sinks.Splunk.Tests/EpochExtensionsTests.cs index 8bbfca5..cb52067 100644 --- a/test/Serilog.Sinks.Splunk.Tests/EpochExtensionsTests.cs +++ b/test/Serilog.Sinks.Splunk.Tests/EpochExtensionsTests.cs @@ -1,6 +1,4 @@ -using Serilog.Sinks.Splunk; -using System; -using System.Diagnostics; +using System; using Xunit; namespace Serilog.Sinks.Splunk.Tests