forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
general tracing context interface (envoyproxy#16793)
Signed-off-by: wbpcode <[email protected]> Sub-PR of envoyproxy#16049. Check envoyproxy#16049 get more background information. This PR designed a new generic abstraction `TraceContext` to replace `Http::RequestHeaderMap` to provide tracing context to the tracer driver. `Http::RequestHeaderMapImpl` already inherits from TraceContext and implements the relevant interfaces. Next, we just need simply replace `Http::RequestHeaderMap` with `TraceContext` in all tracer drivers implementations. After that, the main body of the entire general tracing system is completed. I'm not sure, whether the replacement step requires a separate PR. Because it does not involve any new logic, but there will be a lot of file changes. Risk Level: Low. Testing: Added. Docs Changes: N/A Release Notes: N/A Signed-off-by: wbpcode <[email protected]> Signed-off-by: chris.xin <[email protected]>
- Loading branch information
1 parent
bb800cb
commit bca0a92
Showing
9 changed files
with
226 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
|
||
#include "envoy/common/pure.h" | ||
|
||
#include "absl/strings/string_view.h" | ||
#include "absl/types/optional.h" | ||
|
||
namespace Envoy { | ||
namespace Tracing { | ||
|
||
/** | ||
* Protocol-independent abstraction for traceable stream. It hides the differences between different | ||
* protocol and provides tracer driver with common methods for obtaining and setting the tracing | ||
* context. | ||
*/ | ||
class TraceContext { | ||
public: | ||
virtual ~TraceContext() = default; | ||
|
||
/** | ||
* Get tracing context value by key. | ||
* | ||
* @param key The context key of string view type. | ||
* @return The optional context value of string_view type. | ||
*/ | ||
virtual absl::optional<absl::string_view> getTraceContext(absl::string_view key) const PURE; | ||
|
||
/** | ||
* Set new tracing context key/value pair. | ||
* | ||
* @param key The context key of string view type. | ||
* @param val The context value of string view type. | ||
*/ | ||
virtual void setTraceContext(absl::string_view key, absl::string_view val) PURE; | ||
|
||
/** | ||
* Set new tracing context key/value pair. The key MUST point to data that will live beyond | ||
* the lifetime of any traceable stream that using the string. | ||
* | ||
* @param key The context key of string view type. | ||
* @param val The context value of string view type. | ||
*/ | ||
virtual void setTraceContextReferenceKey(absl::string_view key, absl::string_view val) { | ||
// The reference semantics of key and value are ignored by default. Derived classes that wish to | ||
// use reference semantics to improve performance or reduce memory overhead can override this | ||
// method. | ||
setTraceContext(key, val); | ||
} | ||
|
||
/** | ||
* Set new tracing context key/value pair. Both key and val MUST point to data that will live | ||
* beyond the lifetime of any traceable stream that using the string. | ||
* | ||
* @param key The context key of string view type. | ||
* @param val The context value of string view type. | ||
*/ | ||
virtual void setTraceContextReference(absl::string_view key, absl::string_view val) { | ||
// The reference semantics of key and value are ignored by default. Derived classes that wish to | ||
// use reference semantics to improve performance or reduce memory overhead can override this | ||
// method. | ||
setTraceContext(key, val); | ||
} | ||
}; | ||
|
||
} // namespace Tracing | ||
} // 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