From 5134fe2d2e26b8cb1e1fdec46bc22e40ae23e01d Mon Sep 17 00:00:00 2001 From: Martijn Laarman Date: Wed, 18 Sep 2024 12:02:08 +0200 Subject: [PATCH] Update to latest ingest that attempts to flush out buffer before fully disposing (#440) This also updates our serology sink to implement `IDisposable` so it waits to flush as well. See also #411 --- .../Elastic.Ingest.Elasticsearch.CommonSchema.csproj | 2 +- src/Elastic.Serilog.Sinks/ElasticsearchSink.cs | 4 +++- .../Elasticsearch.IntegrationDefaults.csproj | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Elastic.Ingest.Elasticsearch.CommonSchema/Elastic.Ingest.Elasticsearch.CommonSchema.csproj b/src/Elastic.Ingest.Elasticsearch.CommonSchema/Elastic.Ingest.Elasticsearch.CommonSchema.csproj index 796626a8..bdf8b400 100644 --- a/src/Elastic.Ingest.Elasticsearch.CommonSchema/Elastic.Ingest.Elasticsearch.CommonSchema.csproj +++ b/src/Elastic.Ingest.Elasticsearch.CommonSchema/Elastic.Ingest.Elasticsearch.CommonSchema.csproj @@ -10,7 +10,7 @@ - + diff --git a/src/Elastic.Serilog.Sinks/ElasticsearchSink.cs b/src/Elastic.Serilog.Sinks/ElasticsearchSink.cs index 79653885..a7386832 100644 --- a/src/Elastic.Serilog.Sinks/ElasticsearchSink.cs +++ b/src/Elastic.Serilog.Sinks/ElasticsearchSink.cs @@ -93,7 +93,7 @@ public ElasticsearchSink(ElasticsearchSinkOptions options) : base(options) {} } /// > - public class ElasticsearchSink : ILogEventSink + public class ElasticsearchSink : ILogEventSink, IDisposable where TEcsDocument : EcsDocument, new() { private readonly EcsTextFormatterConfiguration _formatterConfiguration; @@ -121,6 +121,8 @@ public void Emit(LogEvent logEvent) _channel.TryWrite(ecsDoc); } + /// Disposes and flushed + public void Dispose() => _channel.Dispose(); } internal class SelfLogCallbackListener : IChannelCallbacks where TEcsDocument : EcsDocument, new() diff --git a/tests-integration/Elasticsearch.IntegrationDefaults/Elasticsearch.IntegrationDefaults.csproj b/tests-integration/Elasticsearch.IntegrationDefaults/Elasticsearch.IntegrationDefaults.csproj index 78725c6d..f95fa3a9 100644 --- a/tests-integration/Elasticsearch.IntegrationDefaults/Elasticsearch.IntegrationDefaults.csproj +++ b/tests-integration/Elasticsearch.IntegrationDefaults/Elasticsearch.IntegrationDefaults.csproj @@ -11,7 +11,7 @@ - +