Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default the sink to not tracing its own outbound requests, when possible #210

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "8.0.100",
"version": "8.0.201",
"rollForward": "latestFeature"
}
}
2 changes: 1 addition & 1 deletion src/Serilog.Sinks.Seq/SeqLoggerConfigurationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static class SeqLoggerConfigurationExtensions
static readonly TimeSpan DefaultPeriod = TimeSpan.FromSeconds(2);
const int DefaultQueueSizeLimit = 100000;
static ITextFormatter CreateDefaultFormatter() => new SeqCompactJsonFormatter();

/// <summary>
/// Write log events to a <a href="https://datalust.co/seq">Seq</a> server.
/// </summary>
Expand Down
18 changes: 12 additions & 6 deletions src/Serilog.Sinks.Seq/Sinks/Seq/Http/SeqIngestionApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ sealed class SeqIngestionApiClient : SeqIngestionApi
{
const string BulkUploadResource = "api/events/raw";
const string ApiKeyHeaderName = "X-Seq-ApiKey";

readonly string? _apiKey;
readonly HttpClient _httpClient;

Expand All @@ -50,6 +50,7 @@ public SeqIngestionApiClient(string serverUrl, string? apiKey, HttpMessageHandle
_httpClient = new HttpClient();
}
#endif

#if SOCKETS_HTTP_HANDLER_ALWAYS_DEFAULT
else
{
Expand All @@ -59,14 +60,19 @@ public SeqIngestionApiClient(string serverUrl, string? apiKey, HttpMessageHandle
// require that the Seq API be accessed at a different IP address. Setting a timeout here puts
// an upper bound on the duration of DNS-related outages, while hopefully incurring only infrequent
// connection reestablishment costs.
PooledConnectionLifetime = TimeSpan.FromMinutes(5)
PooledConnectionLifetime = TimeSpan.FromMinutes(5),

// Don't trace the sink's own requests. On platforms that use alternative message handler implementations
// by default, the caller needs to do this manually and pass a handler through. Where `SocketsHttpHandler`
// is the default, we can safely set this without inadvertently causing behavior changes.
ActivityHeadersPropagator = null
});
}
#else
else
{
_httpClient = new HttpClient();
}
else
{
_httpClient = new HttpClient();
}
#endif

_httpClient.BaseAddress = new Uri(NormalizeServerBaseAddress(serverUrl));
Expand Down