-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
http: dumping session state on the decode path #7390
Merged
Merged
Changes from 9 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
d260dcd
Basic logging functions
alyssawilk ac93703
http: active session tracking, and crash logging on the request path
alyssawilk e0c631d
Fixing build, adding UT
alyssawilk b17c382
tidy + more tests
alyssawilk 4939235
reviewer comments
alyssawilk e5c0d31
Merge branch 'master' into dumpState
alyssawilk ce554b7
more detail
alyssawilk 42e27ba
some comments: still no config guards
alyssawilk 41d620a
renames, file moves, relnotes, build flags
alyssawilk e8bbe34
speeling
alyssawilk 56ccb5a
better compile config
alyssawilk 510534e
Merge branch 'master' into dumpState
alyssawilk 9e31cd1
Merge branch 'master' into dumpState
alyssawilk f0b1519
hopefully fixing build/copt inversion
alyssawilk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 SIGSEVG due to OOM, where allocating more | ||
// memory would likely lead to the crash handler itself causing a subeqeuent 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) { | ||
mattklein123 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Can we add a bazel config setting similar to https://github.com/envoyproxy/envoy/blob/master/bazel/BUILD#L98? And then also document here: https://github.com/envoyproxy/envoy/tree/master/bazel#disabling-optional-features? And maybe also define this in the compile time options CI build? Also, does disabling signal traces implicitly disable this? I think so but maybe I'm not reading the code correctly? If that's the case can we document that?