-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Added simple logging abstraction so mixer client logs can be relayed to envoy logs. #2116
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
|
||
#include "src/istio/mixerclient/report_batch.h" | ||
#include "include/istio/utils/protobuf.h" | ||
#include "src/istio/utils/logger.h" | ||
|
||
using ::google::protobuf::util::Status; | ||
using ::google::protobuf::util::error::Code; | ||
|
@@ -25,6 +26,9 @@ using ::istio::mixer::v1::ReportResponse; | |
namespace istio { | ||
namespace mixerclient { | ||
|
||
static std::atomic<uint32_t> REPORT_FAIL_LOG_MESSAGES{0}; | ||
static constexpr uint32_t REPORT_FAIL_LOG_MODULUS{100}; | ||
|
||
ReportBatch::ReportBatch(const ReportOptions& options, | ||
TransportReportFunc transport, | ||
TimerCreateFunc timer_create, | ||
|
@@ -70,7 +74,12 @@ void ReportBatch::FlushWithLock() { | |
transport_(request, response, [this, response](const Status& status) { | ||
delete response; | ||
if (!status.ok()) { | ||
GOOGLE_LOG(ERROR) << "Mixer Report failed with: " << status.ToString(); | ||
if (MIXER_WARN_ENABLED && | ||
0 == REPORT_FAIL_LOG_MESSAGES++ % REPORT_FAIL_LOG_MODULUS) { | ||
MIXER_WARN("Mixer Report failed with: %s", status.ToString().c_str()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. my only question here is whether or not we also want to track (via stats) the number of times this is happening to make monitoring easier. if so, we can do that in a follow-up PR if it is going to slow down this PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, that's coming in a separate PR. Already done and tested, just trying to create smaller PRs |
||
} else if (MIXER_DEBUG_ENABLED) { | ||
MIXER_DEBUG("Mixer Report failed with: %s", status.ToString().c_str()); | ||
} | ||
if (utils::InvalidDictionaryStatus(status)) { | ||
compressor_.ShrinkGlobalDictionary(); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Each MIXER_DEBUG has this "if MIXER_DEBUG_ENABLE" check. Can they be combined?
Put the isEnabled() check inside MIXER_DEBUG macro?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wonderful idea if I can make it work. I'll do it if I can ensure that log arguments won't be serialized into nice pretty printed messages, etc when the log threshold wouldn't log them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. src/istio/utils/logger_test.cc shows that arguments to the logging macros will not be needlessly invoked if the log message is under the logging threshold.