Skip to content

Commit

Permalink
Log flow messages when dropped due to queue level
Browse files Browse the repository at this point in the history
When flow messages were being dropped due to queue level, they were
not getting logged even if log_flow was enabled.

Change-Id: Ib6c3ea717f3147f31f9879231cab518c7e57c991
Closes-Bug: #1583671
  • Loading branch information
Megh Bhatt committed May 20, 2016
1 parent c8af604 commit 7c3857e
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 29 deletions.
43 changes: 23 additions & 20 deletions compiler/generate/t_cpp_generator.cc
Expand Up @@ -1401,17 +1401,22 @@ void t_cpp_generator::generate_sandesh_async_creator_helper(ofstream &out, t_san
indent_up();
out << indent() << "UpdateTxMsgFailStats(\"" << tsandesh->get_name() <<
"\", 0, SandeshTxDropReason::QueueLevel);" << endl;
if (!is_flow) {
out << indent() << "std::string drop_reason = \"SANDESH: Queue Drop:"
" \";" << endl;
out << indent() << "DropLog";
if(use_sandesh) {
out << "(drop_reason, category, level, snh);" << endl;
out << indent() << "snh->Release();" << endl;
} else {
out << generate_sandesh_async_creator(tsandesh, false, false, false, "",
"", false, false, true) << "; " << endl;
}
if (is_flow) {
out << indent() << "if (IsLoggingDroppedAllowed(SandeshType::FLOW)) {" << endl;
indent_up();
}
out << indent() << "std::string drop_reason = \"SANDESH: Queue Drop:"
" \";" << endl;
out << indent() << "DropLog";
if (use_sandesh) {
out << "(drop_reason, category, level, snh);" << endl;
out << indent() << "snh->Release();" << endl;
} else {
out << generate_sandesh_async_creator(tsandesh, false, false, false, "",
"", false, false, true) << "; " << endl;
}
if (is_flow) {
scope_down(out);
}
out << indent() << "return;" << endl;
scope_down(out);
Expand Down Expand Up @@ -1469,15 +1474,13 @@ void t_cpp_generator::generate_sandesh_async_creators(ofstream &out, t_sandesh *
generate_sandesh_async_creator_helper(out, tsandesh, false);

// Generate DropLog
if (!is_flow) {
out << indent() << "static void DropLog" <<
generate_sandesh_async_creator(tsandesh, true, false, false, "", "", false, false, true) <<
" {" << endl;
indent_up();
generate_sandesh_logger(out, tsandesh, sandesh_logger::DROP_LOG);
indent_down();
indent(out) << "}" << endl << endl;
}
out << indent() << "static void DropLog" <<
generate_sandesh_async_creator(tsandesh, true, false, false, "", "", false, false, true) <<
" {" << endl;
indent_up();
generate_sandesh_logger(out, tsandesh, sandesh_logger::DROP_LOG);
indent_down();
indent(out) << "}" << endl << endl;

// Generate WriteToBuffer
if (is_system) {
Expand Down
10 changes: 5 additions & 5 deletions library/cpp/sandesh.cc
Expand Up @@ -471,7 +471,7 @@ void Sandesh::DisableFlowCollection(bool disable) {

bool Sandesh::Enqueue(SandeshQueue *queue) {
if (!queue) {
if (IsLoggingDroppedAllowed()) {
if (IsLoggingDroppedAllowed(type())) {
SANDESH_LOG(ERROR, __func__ << ": SandeshQueue NULL : Dropping Message: "
<< ToString());
}
Expand Down Expand Up @@ -595,7 +595,7 @@ int32_t Sandesh::ReceiveBinaryMsg(u_int8_t *buf, u_int32_t buf_len,

bool Sandesh::SendEnqueue() {
if (!client_) {
if (IsLoggingDroppedAllowed()) {
if (IsLoggingDroppedAllowed(type())) {
if (IsConnectToCollectorEnabled()) {
SANDESH_LOG(ERROR, "SANDESH: No client: " << ToString());
} else {
Expand All @@ -607,7 +607,7 @@ bool Sandesh::SendEnqueue() {
return false;
}
if (!client_->SendSandesh(this)) {
if (IsLoggingDroppedAllowed()) {
if (IsLoggingDroppedAllowed(type())) {
SANDESH_LOG(ERROR, "SANDESH: Send FAILED: " << ToString());
}
UpdateTxMsgFailStats(name_, 0,
Expand Down Expand Up @@ -710,8 +710,8 @@ bool Sandesh::IsLoggingAllowed() const {
}
}

bool Sandesh::IsLoggingDroppedAllowed() const {
if (type_ == SandeshType::FLOW) {
bool Sandesh::IsLoggingDroppedAllowed(SandeshType::type type) {
if (type == SandeshType::FLOW) {
return enable_flow_log_;
} else {
return true;
Expand Down
2 changes: 1 addition & 1 deletion library/cpp/sandesh.h
Expand Up @@ -261,7 +261,7 @@ class Sandesh {
virtual int32_t ReadBinary(u_int8_t *buf, u_int32_t buf_len, int *error);

bool IsLoggingAllowed() const;
bool IsLoggingDroppedAllowed() const;
static bool IsLoggingDroppedAllowed(SandeshType::type);

// Accessors
static void set_source(std::string &source) { source_ = source; }
Expand Down
4 changes: 2 additions & 2 deletions library/cpp/sandesh_client_sm.cc
Expand Up @@ -496,7 +496,7 @@ struct ClientInit : public sc::state<ClientInit, SandeshClientSMImpl> {
SM_LOG(DEBUG, state_machine->StateName() << " : " << event.Name() <<
" : " << snh->Name());
if (dynamic_cast<SandeshUVE *>(snh)) {
if (snh->IsLoggingDroppedAllowed()) {
if (Sandesh::IsLoggingDroppedAllowed(snh->type())) {
SANDESH_LOG(ERROR, "SANDESH: Send FAILED: " <<
snh->ToString());
}
Expand Down Expand Up @@ -669,7 +669,7 @@ void SandeshClientSMImpl::OnIdle(const Ev &event) {
template <class Ev>
void SandeshClientSMImpl::ReleaseSandesh(const Ev &event) {
Sandesh *snh(event.snh);
if (snh->IsLoggingDroppedAllowed()) {
if (Sandesh::IsLoggingDroppedAllowed(snh->type())) {
SANDESH_LOG(ERROR, "SANDESH: Send FAILED: " << snh->ToString());
}
Sandesh::UpdateTxMsgFailStats(snh->Name(), 0,
Expand Down
2 changes: 1 addition & 1 deletion library/cpp/sandesh_session.cc
Expand Up @@ -355,7 +355,7 @@ bool SandeshSession::SendMsg(SandeshElement element) {
Sandesh *sandesh = element.snh_;
tbb::mutex::scoped_lock lock(send_mutex_);
if (!IsEstablished()) {
if (sandesh->IsLoggingDroppedAllowed()) {
if (Sandesh::IsLoggingDroppedAllowed(sandesh->type())) {
SANDESH_LOG(ERROR, __func__ << " Not Connected : Dropping Message: " <<
sandesh->ToString());
}
Expand Down

0 comments on commit 7c3857e

Please sign in to comment.