jamesge commented on a change in pull request #537: customise span exporter
URL: https://github.com/apache/incubator-brpc/pull/537#discussion_r362695272
 
 

 ##########
 File path: src/brpc/span.cpp
 ##########
 @@ -199,47 +199,42 @@ void Span::destroy() {
     Span* p = _next_client;
     while (p) {
         Span* p_next = p->_next_client;
-        p->_info.clear();
+        p->_annotation_list.clear();
         butil::return_object(p);
         p = p_next;
     }
-    _info.clear();
+    _annotation_list.clear();
     butil::return_object(this);
 }
 
 void Span::Annotate(const char* fmt, ...) {
-    const int64_t anno_time = butil::cpuwide_time_us() + _base_real_us;
-    butil::string_appendf(&_info, BRPC_SPAN_INFO_SEP "%lld ",
-                         (long long)anno_time);
     va_list ap;
     va_start(ap, fmt);
-    butil::string_vappendf(&_info, fmt, ap);
+    Annotate(fmt, ap);
     va_end(ap);
 }
 
 void Span::Annotate(const char* fmt, va_list args) {
     const int64_t anno_time = butil::cpuwide_time_us() + _base_real_us;
-    butil::string_appendf(&_info, BRPC_SPAN_INFO_SEP "%lld ",
-                         (long long)anno_time);
-    butil::string_vappendf(&_info, fmt, args);
+    std::string anno_content;
+    butil::string_vappendf(&anno_content, fmt, args);
+    _annotation_list.emplace_back(anno_time, std::move(anno_content));
 }
 
 void Span::Annotate(const std::string& info) {
     const int64_t anno_time = butil::cpuwide_time_us() + _base_real_us;
-    butil::string_appendf(&_info, BRPC_SPAN_INFO_SEP "%lld ",
-                         (long long)anno_time);
-    _info.append(info);
+    _annotation_list.push_back(Annotation(anno_time, info));
 }
 
 void Span::AnnotateCStr(const char* info, size_t length) {
     const int64_t anno_time = butil::cpuwide_time_us() + _base_real_us;
-    butil::string_appendf(&_info, BRPC_SPAN_INFO_SEP "%lld ",
-                         (long long)anno_time);
-    if (length <= 0) {
-        _info.append(info);
+    std::string anno_content;
+    if (length > 0) {
+        anno_content = std::string(info, length);
 
 Review comment:
   anno_content.assign(info, length);

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org

Reply via email to