-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
http: dumping session state on the decode path (#7390)
Signed-off-by: Alyssa Wilk <[email protected]>
- Loading branch information
1 parent
c60df64
commit 733052a
Showing
37 changed files
with
518 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#pragma once | ||
|
||
#include <ostream> | ||
|
||
#include "envoy/common/pure.h" | ||
|
||
namespace Envoy { | ||
|
||
/* | ||
* A class for tracking the scope of work. | ||
* Currently this is only used for best-effort tracking the L7 stream doing | ||
* work if a fatal error occurs. | ||
*/ | ||
class ScopeTrackedObject { | ||
public: | ||
virtual ~ScopeTrackedObject() = default; | ||
|
||
/** | ||
* Dump debug state of the object in question to the provided ostream | ||
* | ||
* This is called on Envoy fatal errors, so should do minimal memory allocation. | ||
* | ||
* @param os the ostream to output to. | ||
* @param indent_level how far to indent, for pretty-printed classes and subclasses. | ||
*/ | ||
virtual void dumpState(std::ostream& os, int indent_level = 0) const PURE; | ||
}; | ||
|
||
} // namespace Envoy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#pragma once | ||
|
||
#include <sstream> | ||
|
||
namespace Envoy { | ||
|
||
// A collection of macros for pretty printing objects on fatal error. | ||
// These are fairly ugly in an attempt to maximize the conditions where fatal error logging occurs, | ||
// i.e. under the Envoy signal handler if encountering a crash due to OOM, where allocating more | ||
// memory would likely lead to the crash handler itself causing a subsequent OOM. | ||
|
||
#define DUMP_MEMBER(member) ", " #member ": " << (member) | ||
|
||
#define DUMP_OPTIONAL_MEMBER(member) \ | ||
", " #member ": " << ((member).has_value() ? absl::StrCat((member).value()) : "null") | ||
|
||
// Macro assumes local member variables | ||
// os (ostream) | ||
// indent_level (int) | ||
#define DUMP_DETAILS(member) \ | ||
do { \ | ||
os << spaces << #member ": "; \ | ||
if ((member) != nullptr) { \ | ||
os << "\n"; \ | ||
(member)->dumpState(os, indent_level + 1); \ | ||
} else { \ | ||
os << spaces << "null\n"; \ | ||
} \ | ||
} while (false) | ||
|
||
// Return the const char* equivalent of string(level*2, ' '), without dealing | ||
// with string creation overhead. Cap arbitrarily at 6 as we're (hopefully) | ||
// not going to have nested objects deeper than that. | ||
inline const char* spacesForLevel(int level) { | ||
switch (level) { | ||
case 0: | ||
return ""; | ||
case 1: | ||
return " "; | ||
case 2: | ||
return " "; | ||
case 3: | ||
return " "; | ||
case 4: | ||
return " "; | ||
case 5: | ||
return " "; | ||
default: | ||
return " "; | ||
} | ||
return ""; | ||
} | ||
|
||
} // namespace Envoy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#pragma once | ||
|
||
#include "envoy/common/scope_tracker.h" | ||
#include "envoy/event/dispatcher.h" | ||
|
||
namespace Envoy { | ||
|
||
// A small class for tracking the scope of the object which is currently having | ||
// work done in this thread. | ||
// | ||
// When created, it sets the tracked object in the dispatcher, and when destroyed it points the | ||
// dispatcher at the previously tracked object. | ||
class ScopeTrackerScopeState { | ||
public: | ||
ScopeTrackerScopeState(const ScopeTrackedObject* object, Event::Dispatcher& dispatcher) | ||
: dispatcher_(dispatcher) { | ||
latched_object_ = dispatcher_.setTrackedObject(object); | ||
} | ||
|
||
~ScopeTrackerScopeState() { dispatcher_.setTrackedObject(latched_object_); } | ||
|
||
private: | ||
const ScopeTrackedObject* latched_object_; | ||
Event::Dispatcher& dispatcher_; | ||
}; | ||
|
||
} // namespace Envoy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.