This is an automated email from the ASF dual-hosted git repository.
wwbmmm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brpc.git
The following commit(s) were added to refs/heads/master by this push:
new b0a7c4a9 Escape span method name (#2411)
b0a7c4a9 is described below
commit b0a7c4a9da7ab44aeeaed10e6f3d126cde44e6f7
Author: Weibing Wang <[email protected]>
AuthorDate: Thu Oct 12 20:15:53 2023 +0800
Escape span method name (#2411)
* Escape span method name
* Reuse WebEscape
---
src/brpc/builtin/rpcz_service.cpp | 10 +++++-----
src/brpc/controller.cpp | 6 ++++++
src/brpc/controller.h | 1 +
3 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/src/brpc/builtin/rpcz_service.cpp
b/src/brpc/builtin/rpcz_service.cpp
index d4374e47..3625c068 100644
--- a/src/brpc/builtin/rpcz_service.cpp
+++ b/src/brpc/builtin/rpcz_service.cpp
@@ -194,7 +194,7 @@ static void PrintAnnotations(
while (extractors[i]->PopAnnotation(cur_time, &anno_time, &a)) {
PrintRealTime(os, anno_time);
PrintElapse(os, anno_time, last_time);
- os << ' ' << a;
+ os << ' ' << WebEscape(a);
if (a.empty() || butil::back_char(a) != '\n') {
os << '\n';
}
@@ -249,7 +249,7 @@ static void PrintClientSpan(
if (abs_remote_side.ip == loopback_ip) {
abs_remote_side.ip = butil::my_ip();
}
- os << " Requesting " << span.full_method_name() << '@' << remote_side
+ os << " Requesting " << WebEscape(span.full_method_name()) << '@' <<
remote_side
<< ' ' << protocol_name << ' ' << LOG_ID_STR << '=';
if (FLAGS_rpcz_hex_log_id) {
os << Hex(span.log_id());
@@ -346,7 +346,7 @@ static void PrintServerSpan(std::ostream& os, const
RpczSpan& span,
os, span.start_callback_real_us(),
&last_time, extr, ARRAY_SIZE(extr))) {
entered_user_method = true;
- os << " Enter " << span.full_method_name() << std::endl;
+ os << " Enter " << WebEscape(span.full_method_name()) << std::endl;
}
const int nclient = span.client_spans_size();
@@ -359,7 +359,7 @@ static void PrintServerSpan(std::ostream& os, const
RpczSpan& span,
os, span.start_send_real_us(),
&last_time, extr, ARRAY_SIZE(extr))) {
if (entered_user_method) {
- os << " Leave " << span.full_method_name() << std::endl;
+ os << " Leave " << WebEscape(span.full_method_name()) << std::endl;
} else {
os << " Responding" << std::endl;
}
@@ -665,7 +665,7 @@ void
RpczService::default_method(::google::protobuf::RpcController* cntl_base,
} else {
os << span.log_id();
}
- os << ' ' << span.full_method_name() << '(' << span.request_size()
+ os << ' ' << WebEscape(span.full_method_name()) << '(' <<
span.request_size()
<< ")=" << span.response_size();
if (span.error_code() == 0) {
diff --git a/src/brpc/controller.cpp b/src/brpc/controller.cpp
index eb8ea8a9..25a5940e 100644
--- a/src/brpc/controller.cpp
+++ b/src/brpc/controller.cpp
@@ -1392,6 +1392,12 @@ void WebEscape(const std::string& source, std::string*
output) {
}
}
+std::string WebEscape(const std::string& source) {
+ std::string output;
+ WebEscape(source, &output);
+ return output;
+}
+
void Controller::reset_sampled_request(SampledRequest* req) {
delete _sampled_request;
_sampled_request = req;
diff --git a/src/brpc/controller.h b/src/brpc/controller.h
index 144aa118..a9498818 100644
--- a/src/brpc/controller.h
+++ b/src/brpc/controller.h
@@ -856,6 +856,7 @@ google::protobuf::Closure* DoNothing();
// Convert non-web symbols to web equivalence.
void WebEscape(const std::string& source, std::string* output);
+std::string WebEscape(const std::string& source);
// True if Ctrl-C is ever pressed.
bool IsAskedToQuit();
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]