Skip to content

Commit 4ba40a1

Browse files
authored
Remove WriteEvent usages (#453)
- Ensure correct embdedded logical name for UParser.regexes.cs - Remove WriteEvent usages
1 parent a79063e commit 4ba40a1

File tree

4 files changed

+6
-15
lines changed

4 files changed

+6
-15
lines changed

src/Elastic.Extensions.Logging/ElasticsearchLoggerProvider.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ private IBufferedChannel<LogEvent> CreatIngestChannel(ElasticsearchLoggerOptions
169169
{
170170
IndexFormat = loggerOptions.Index.Format,
171171
IndexOffset = loggerOptions.Index.IndexOffset,
172-
WriteEvent = async (stream, ctx, logEvent) => await logEvent.SerializeAsync(stream, ctx).ConfigureAwait(false),
173172
TimestampLookup = l => l.Timestamp,
174173
};
175174
SetupChannelOptions(_channelConfigurations, indexChannelOptions);

src/Elastic.Ingest.Elasticsearch.CommonSchema/EcsDataStreamChannel.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@ public EcsDataStreamChannel(DataStreamChannelOptions<TEcsDocument> options) : th
2626
public EcsDataStreamChannel(
2727
DataStreamChannelOptions<TEcsDocument> options,
2828
ICollection<IChannelCallbacks<TEcsDocument, BulkResponse>>? callbackListeners
29-
) : base(options, callbackListeners) =>
30-
options.WriteEvent = async (stream, ctx, @event) =>
31-
await JsonSerializer.SerializeAsync(stream, @event, typeof(TEcsDocument), EcsJsonConfiguration.SerializerOptions, ctx)
32-
.ConfigureAwait(false);
29+
) : base(options, callbackListeners) { }
3330

3431
/// <summary>
3532
/// Bootstrap the target data stream. Will register the appropriate index and component templates

src/Elastic.Ingest.Elasticsearch.CommonSchema/EcsIndexChannel.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@ public class EcsIndexChannel<TEcsDocument> : IndexChannel<TEcsDocument>
1818
where TEcsDocument : EcsDocument
1919
{
2020
/// <inheritdoc cref="EcsIndexChannel{TEcsDocument}"/>
21-
public EcsIndexChannel(IndexChannelOptions<TEcsDocument> options) : base(options) =>
22-
options.WriteEvent = async (stream, ctx, @event) =>
23-
await JsonSerializer.SerializeAsync(stream, @event, typeof(TEcsDocument), EcsJsonConfiguration.SerializerOptions, ctx)
24-
.ConfigureAwait(false);
21+
public EcsIndexChannel(IndexChannelOptions<TEcsDocument> options) : base(options) { }
2522

2623
/// <summary>
2724
/// Bootstrap the target index. Will register the appropriate index and component templates

src/Elastic.NLog.Targets/ElasticsearchTarget.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public class ElasticsearchTarget : TargetWithLayout
5555

5656
/// <summary>
5757
/// Gets or sets the format string for the Elastic search index. The current <c>DateTimeOffset</c> is passed as parameter 0.
58-
///
58+
///
5959
/// <para> Example: "dotnet-{0:yyyy.MM.dd}"</para>
6060
/// <para> If no {0} parameter is defined the index name is effectively fixed</para>
6161
/// </summary>
@@ -213,8 +213,7 @@ private EcsDataStreamChannel<NLogEcsDocument> CreateDataStreamChannel(Distribute
213213
var dataStreamNamespace = DataStreamNamespace?.Render(LogEventInfo.CreateNullEvent()) ?? string.Empty;
214214
var channelOptions = new DataStreamChannelOptions<NLogEcsDocument>(transport)
215215
{
216-
DataStream = new DataStreamName(dataStreamType, dataStreamSet, dataStreamNamespace),
217-
WriteEvent = async (stream, ctx, logEvent) => await logEvent.SerializeAsync(stream, ctx).ConfigureAwait(false),
216+
DataStream = new DataStreamName(dataStreamType, dataStreamSet, dataStreamNamespace)
218217
};
219218
SetupChannelOptions(channelOptions);
220219
var channel = new EcsDataStreamChannel<NLogEcsDocument>(channelOptions, new[] { new InternalLoggerCallbackListener<NLogEcsDocument>() });
@@ -228,9 +227,8 @@ private EcsIndexChannel<NLogEcsDocument> CreateIndexChannel(DistributedTransport
228227
{
229228
IndexFormat = indexFormat,
230229
IndexOffset = indexOffset,
231-
WriteEvent = async (stream, ctx, logEvent) => await logEvent.SerializeAsync(stream, ctx).ConfigureAwait(false),
232230
TimestampLookup = l => l.Timestamp,
233-
OperationMode = indexOperation,
231+
OperationMode = indexOperation
234232
};
235233

236234
if (_hasIndexEventId)
@@ -251,7 +249,7 @@ protected override void CloseTarget()
251249

252250
/// <inheritdoc />
253251
protected override void Write(LogEventInfo logEvent)
254-
{
252+
{
255253
var ecsDoc = _layout.RenderEcsDocument(logEvent);
256254
_channel?.TryWrite(ecsDoc);
257255
}

0 commit comments

Comments
 (0)