-
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
xray: Use correct types for segment document output #10834
Conversation
Signed-off-by: David Bell <belldav@amazon.com>
…retain type information Risk Level: Low Testing: unit tests, manual Docs Changes: N/A Release Notes: N/A Fixes: envoyproxy#10814 Signed-off-by: David Bell <belldav@amazon.com>
@marcomagdy for first pass. Also, please substantially improve xray coverage here: https://storage.googleapis.com/envoy-coverage/report-master/index.html. There is a lot missing. Thank you! /wait |
Signed-off-by: David Bell <belldav@amazon.com>
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.
Thank you for taking care of this. I left some comments.
daemon::Segment_http_annotations* http = s.mutable_http(); | ||
|
||
ProtobufWkt::Struct* request = http->mutable_request(); | ||
auto request_fields = request->mutable_fields(); |
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.
nit: auto*
instead of auto
when the deduced type is a pointer.
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.
fixed.
for (const auto& field : http_request_annotations_) { | ||
request_fields->insert(StructField{field.first, field.second}); | ||
|
||
(*request_fields)[field.first] = field.second; |
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.
This line is a duplicate. remove?
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.
bleh, looking at this and cout it looks like I didn't look at my rebase merge closely enough. fixed.
@@ -179,20 +191,31 @@ void Span::setTag(absl::string_view name, absl::string_view value) { | |||
} | |||
|
|||
if (name == HttpUrl) { | |||
http_request_annotations_.emplace(SpanUrl, value); | |||
http_request_annotations_.emplace(SpanUrl, ValueUtil::stringValue(std::string(value))); |
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.
value
is a string already.
so this should be ValueUtil::stringValue(value);
instead?
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.
So value is a string_view, and based off my read of the abseil docs and the header there is no implicit conversion from string_view to string. As rusty as I am at c++, I'm assuming the reason the "implicit conversion" works for flat_hash_map::emplace is because its constructing from arguments internally
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.
if value is a string_view, then this is fine.
} else if (name == HttpStatusCode) { | ||
http_response_annotations_.emplace(SpanStatus, value); | ||
uint64_t status_code; | ||
std::cout << "belldav" << value << std::endl; |
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.
remove
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.
😬, removed.
if (!absl::SimpleAtoi(value, &status_code)) { | ||
ENVOY_LOG(warn, "{} must be a number, given: {}", HttpStatusCode, value); | ||
return; | ||
} |
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.
Rather than discard the entire trace, it's better just to skip the status if we can't parse it.
Also, Matt is likely to have you change this log verbosity to debug or trace.
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.
setTag only operates on a single key-value pair, so this won't fail the entire trace.
I could however see failing to parse falling back to registering a custom annotation with these values.
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.
You're right. I confused this with the code in finishSpan().
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.
I did drop the log level down to debug.
uint64_t response_size; | ||
if (!absl::SimpleAtoi(value, &response_size)) { | ||
ENVOY_LOG(warn, "{} must be a number, given: {}", HttpResponseSize, value); | ||
return; | ||
} | ||
http_response_annotations_.emplace(SpanContentLength, ValueUtil::numberValue(response_size)); |
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.
same as above. change log verbosity, and skip just the value.
daemon::Segment_http_annotations* http = s.mutable_http(); | ||
|
||
ProtobufWkt::Struct* request = http->mutable_request(); |
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.
I'd change those two lines to:
ProtobufWkt::Struct* request = s.http()->mutable_request();
The http
is not used anywhere else.
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.
makes sense. this was left over from my misunderstanding that constructing submessages and assigning isn't the right way to go in c++.
source/common/protobuf/utility.h
Outdated
/** | ||
* Wrap double into ProtobufWkt::Value string value. | ||
* @param d double to be wrapped. | ||
* @return wrapped double. | ||
*/ | ||
static ProtobufWkt::Value numberValue(const double str); | ||
|
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.
There's already a numberValue(..)
utility function on line 459.
You can remove this function and its definition.
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.
removed.
Signed-off-by: David Bell <belldav@amazon.com>
This reverts commit ecd5844. Signed-off-by: David Bell <belldav@amazon.com>
Signed-off-by: David Bell <belldav@amazon.com>
Signed-off-by: David Bell <belldav@amazon.com>
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.
LGTM. Thanks.
@mattklein123 I have a separate PR for improving the test coverage here #10890
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.
Thanks!
Risk Level: Low Testing: unit tests, manual Docs Changes: N/A Release Notes: N/A Fixes: envoyproxy#10814 Signed-off-by: pengg <pengg@google.com>
Signed-off-by: Spencer Lewis <slewis@squareup.com> * master: (46 commits) allow specifying the API version of bootstrap from the command line (envoyproxy#10803) config: adding connect matcher (unused) (envoyproxy#10894) Add missing dependency on `assert.h` (envoyproxy#10918) Lower heap and disk space used by kafka tests (envoyproxy#10915) [tools] handle commits merged without PR in deprecated script (envoyproxy#10723) tools: including working tree in modified_since_last_github_commit.sh diff. (envoyproxy#10911) rocketmq_proxy: implement rocketmq proxy [docs] PR template to include commit message (envoyproxy#10900) docs: breaking long word to stop content overflow. (envoyproxy#10880) Delete legacy connection pool code. (envoyproxy#10881) wasm: clarify how configuration is passed (envoyproxy#10782) issue template: clarify security/crash reporting (envoyproxy#10885) api/faq: add entry on incremental xDS. (envoyproxy#10876) router: retry overloaded requests (envoyproxy#10847) Remove inclusion of pthread.h, not needed for linux compilation (envoyproxy#10895) request_id: Add option to always set request id in response (envoyproxy#10808) xray: Use correct types for segment document output (envoyproxy#10834) router: fixing a watermark bug for streaming retries (envoyproxy#10866) http: auditing Path() calls for safety with Pathless CONNECT (envoyproxy#10851) Remove hardcoded type urls Part.2 (envoyproxy#10848) ...
Description: Switches X-Ray tracing plugin to use proto3 structs, which emit correctly typed outputs (String for StringValue, Number for NumberValue, etc.) such that X-Ray will process those fields.
Risk Level: Low
Testing: unit-tests, manual
Docs Changes: N/A
Release Notes: N/A
Fixes: #10814
manual verification via a udpdump script