Skip to content

Commit

Permalink
Merge pull request #210 from nblumhardt/default-to-no-header-propagation
Browse files Browse the repository at this point in the history
Default the sink to not tracing its own outbound requests, when possible
  • Loading branch information
nblumhardt authored Feb 22, 2024
2 parents 384b2d4 + a4ebc46 commit 3108823
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
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

0 comments on commit 3108823

Please sign in to comment.