Repository navigation
replace RequestHeaderMap in tracers with general TraceContext - #17212
Conversation
Signed-off-by: wbpcode <[email protected]>
|
|
||
| namespace { | ||
| class OpenTracingHTTPHeadersWriter : public opentracing::HTTPHeadersWriter { | ||
| class OpenTracingHeadersWriter : public opentracing::HTTPHeadersWriter { |
There was a problem hiding this comment.
Can we operate general tracing context, not only HTTP header in this class? If not, I think we don't have to modify this class. It is because we only accept HTTP headers here, not general tracing context.
There was a problem hiding this comment.
🤔 I think there is no problem, because here only simple set and get operations are needed on TraceContext. So it is completely possible to use TraceContext to replace HeaderMap.
TraceContext does not support iterative API for the time being, so dynamic_cast is used to temporarily bypass this problem.
And this is an overall change, we can't just keep this one class without making changes.
There was a problem hiding this comment.
The superclass is HTTPHeadersWriter so this is still HTTP only?
There was a problem hiding this comment.
@lizan Apart from the name, HTTPHeadersWriter does not seem to have anything related to the HTTP protocol.
I have checked source code of opentracing interface and also implementation of datadog/lightstep. HTTPHeadersWriter does not contain any HTTP-dependent interfaces. HTTPHeadersWriter simply inherits from TextMapWriter, without adding any HTTP-related methods.
class TextMapReader {
public:
virtual ~TextMapReader() = default;
virtual expected<string_view> LookupKey(string_view /*key*/) const {
return make_unexpected(lookup_key_not_supported_error);
}
virtual expected<void> ForeachKey(
std::function<expected<void>(string_view key, string_view value)> f)
const = 0;
};
class TextMapWriter {
public:
virtual ~TextMapWriter() = default;
virtual expected<void> Set(string_view key, string_view value) const = 0;
};
class HTTPHeadersReader : public TextMapReader {};
class HTTPHeadersWriter : public TextMapWriter {};
datadog/lightstep also does not provide any operations for HTTPHeadersWriter that are different from TextMapWriter.
In summary, HTTPHeadersWriter will not affect the generality of tracers. We can completely replace it with TextMapWriter. The reason why I have not done this at present is because I don't want the general tracing system to have any impact on existing HTTP Tracers users.
|
/retest |
|
Retrying Azure Pipelines: |
Signed-off-by: wbpcode <[email protected]>
Signed-off-by: wbpcode <[email protected]>
Signed-off-by: wbpcode <[email protected]>
| const auto entry = ctx.request_headers->get(name_); | ||
| return !entry.empty() ? entry[0]->value().getStringView() : default_value_; | ||
| const auto entry = ctx.trace_context->getTraceContext(name_); | ||
| return entry.has_value() ? entry.value() : default_value_; |
There was a problem hiding this comment.
| return entry.has_value() ? entry.value() : default_value_; | |
| return entry.value_or(default_value_); |
|
|
||
| namespace { | ||
| class OpenTracingHTTPHeadersWriter : public opentracing::HTTPHeadersWriter { | ||
| class OpenTracingHeadersWriter : public opentracing::HTTPHeadersWriter { |
There was a problem hiding this comment.
The superclass is HTTPHeadersWriter so this is still HTTP only?
Signed-off-by: wbpcode <[email protected]>
|
/retest |
|
Retrying Azure Pipelines: |
…roxy#17212) Sub-PR of envoyproxy#16049. Check envoyproxy#16049 get more background information. This PR is last sub-PR of envoyproxy#16049. It simply replaces `Http::RequestHeaderMap` with general `Tracing::TraceContext` in all tracer drivers implementations. Check envoyproxy#16793 get more info about `Tracing::TraceContext`. After this PR, the main body of the entire general tracing system is completed. Next, we can try to use the new general tracing system in dubbo and thrift. Commit Message: replace RequestHeaderMap in tracers with general TraceContext Risk Level: Low. Testing: N/A. Docs Changes: N/A. Release Notes: N/A. Signed-off-by: wbpcode <[email protected]>
Sub-PR of #16049. Check #16049 get more background information.
This PR is last sub-PR of #16049. It simply replaces
Http::RequestHeaderMapwith generalTracing::TraceContextin all tracer drivers implementations.Check #16793 get more info about
Tracing::TraceContext.After this PR, the main body of the entire general tracing system is completed. Next, we can try to use the new general tracing system in dubbo and thrift.
Commit Message: replace RequestHeaderMap in tracers with general TraceContext
Risk Level: Low.
Testing: N/A.
Docs Changes: N/A.
Release Notes: N/A.