Skip to content

Commit

Permalink
Update NewRelicLogsSink to implement IBatchedLogEventSink
Browse files Browse the repository at this point in the history
  • Loading branch information
Niels Pilgaard Grøndahl committed May 25, 2023
1 parent 1c20b18 commit 75e0794
Showing 1 changed file with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Serilog.Sinks.NewRelic.Logs
{
internal class NewRelicLogsSink : PeriodicBatchingSink
internal class NewRelicLogsSink : IBatchedLogEventSink
{
public const int DefaultBatchSizeLimit = 1000;

Expand All @@ -30,14 +30,11 @@ internal class NewRelicLogsSink : PeriodicBatchingSink
private IFormatProvider FormatProvider { get; }

public NewRelicLogsSink(
string endpointUrl,
string applicationName,
string licenseKey,
string insertKey,
int batchSizeLimit,
TimeSpan period,
string endpointUrl,
string applicationName,
string licenseKey,
string insertKey,
IFormatProvider formatProvider = null)
: base(batchSizeLimit, period)
{
this.EndpointUrl = endpointUrl;
this.ApplicationName = applicationName;
Expand All @@ -46,7 +43,7 @@ public NewRelicLogsSink(
this.FormatProvider = formatProvider;
}

protected override async Task EmitBatchAsync(IEnumerable<LogEvent> eventsEnumerable)
public async Task EmitBatchAsync(IEnumerable<LogEvent> eventsEnumerable)
{
var payload = new NewRelicLogPayload(this.ApplicationName);
var events = eventsEnumerable.ToList();
Expand All @@ -70,6 +67,11 @@ protected override async Task EmitBatchAsync(IEnumerable<LogEvent> eventsEnumera
await this.SendToNewRelicLogsAsync(body).ConfigureAwait(false);
}

public Task OnEmptyBatchAsync()
{
return Task.CompletedTask;
}

private Task SendToNewRelicLogsAsync(string body)
{
return Task.Run(() =>
Expand Down

0 comments on commit 75e0794

Please sign in to comment.