From 4a541d0d87fde7a13a3b5c34376c02eccbe1a11b Mon Sep 17 00:00:00 2001 From: Otto van der Schaaf Date: Fri, 4 Sep 2020 20:40:38 +0200 Subject: [PATCH] Bound log emission in a few potentially high frequency spots. Fixes #484 Signed-off-by: Otto van der Schaaf --- source/client/benchmark_client_impl.cc | 2 +- source/client/stream_decoder.cc | 5 ++--- source/common/statistic_impl.cc | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/source/client/benchmark_client_impl.cc b/source/client/benchmark_client_impl.cc index 7c7dd1fab..accf508ed 100644 --- a/source/client/benchmark_client_impl.cc +++ b/source/client/benchmark_client_impl.cc @@ -156,7 +156,7 @@ bool BenchmarkClientHttpImpl::tryStartRequest(CompletionCallback caller_completi if (content_length_header != nullptr) { auto s_content_length = content_length_header->value().getStringView(); if (!absl::SimpleAtoi(s_content_length, &content_length)) { - ENVOY_LOG(error, "Ignoring bad content length of {}", s_content_length); + ENVOY_LOG_EVERY_POW_2(error, "Ignoring bad content length of {}", s_content_length); content_length = 0; } } diff --git a/source/client/stream_decoder.cc b/source/client/stream_decoder.cc index f70109608..94f10d0a8 100644 --- a/source/client/stream_decoder.cc +++ b/source/client/stream_decoder.cc @@ -28,8 +28,7 @@ void StreamDecoder::decodeHeaders(Envoy::Http::ResponseHeaderMapPtr&& headers, b if (absl::SimpleAtoi(timing_value, &origin_delta) && origin_delta >= 0) { origin_latency_statistic_.addValue(origin_delta); } else { - // TODO(#484): avoid high frequency logging. - ENVOY_LOG(warn, "Bad origin delta: '{}'.", timing_value); + ENVOY_LOG_EVERY_POW_2(warn, "Bad origin delta: '{}'.", timing_value); } } @@ -69,7 +68,7 @@ void StreamDecoder::onComplete(bool success) { stream_info_.response_code_.value(), (time_source_.monotonicTime() - request_start_).count()); } else { - ENVOY_LOG(warn, "response_code is not available in onComplete"); + ENVOY_LOG_EVERY_POW_2(warn, "response_code is not available in onComplete"); } } upstream_timing_.onLastUpstreamRxByteReceived(time_source_); diff --git a/source/common/statistic_impl.cc b/source/common/statistic_impl.cc index d708ecd76..0810b99ae 100644 --- a/source/common/statistic_impl.cc +++ b/source/common/statistic_impl.cc @@ -180,7 +180,7 @@ void HdrStatistic::addValue(uint64_t value) { // Failure to record a value can happen when it exceeds the configured minimum // or maximum value we passed when initializing histogram_. if (!hdr_record_value(histogram_, value)) { - ENVOY_LOG(warn, "Failed to record value into HdrHistogram."); + ENVOY_LOG_EVERY_POW_2(warn, "Failed to record value into HdrHistogram."); } else { StatisticImpl::addValue(value); }