Skip to content

Commit

Permalink
Truncate unknown keys logging from central config parser (#2277)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mpdreamz authored Feb 5, 2024
1 parent aacb5cc commit 11de017
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,16 @@ string httpResponseBody

private CentralConfiguration ParseConfigPayload(HttpResponseMessage httpResponse, CentralConfigPayload configPayload)
{
if (configPayload.UnknownKeys != null && configPayload.UnknownKeys.Any())
if (configPayload.UnknownKeys != null && configPayload.UnknownKeys.Any()
&& _logger.IsEnabled(LogLevel.Information))
{
var keys = string.Join(", ", configPayload.UnknownKeys.Select(k => $"`[{k.Key}, {k.Value}]'")).Truncate(1024);
var values = string.Join(", ", CentralConfigPayload.SupportedOptions.Select(k => $"`{k}'")).Truncate(1024);
_logger.Info()
?.Log("Central configuration response contains keys that are not in the list of options"
+ " that can be changed after Agent start: {UnknownKeys}. Supported options: {ReloadableOptions}."
, string.Join(", ", configPayload.UnknownKeys.Select(k => $"`[{k.Key}, {k.Value}]'"))
, string.Join(", ", CentralConfigPayload.SupportedOptions.Select(k => $"`{k}'")));
, keys
, values);
}

var eTag = httpResponse.Headers.ETag.ToString();
Expand Down

0 comments on commit 11de017

Please sign in to comment.