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

 ##########
 File path: src/brpc/span.cpp
 ##########
 @@ -304,499 +298,44 @@ void AnnotateSpan(const char* fmt, ...) {
     va_end(ap);
 }
 
-class SpanDB : public SharedObject {
-public:
-    leveldb::DB* id_db;
-    leveldb::DB* time_db;
-    std::string id_db_name;
-    std::string time_db_name;
-
-    SpanDB() : id_db(NULL), time_db(NULL) { }
-    static SpanDB* Open();
-    leveldb::Status Index(const Span* span, std::string* value_buf);
-    leveldb::Status RemoveSpansBefore(int64_t tm);
-
-private:
-    static void Swap(SpanDB& db1, SpanDB& db2) {
-        std::swap(db1.id_db, db2.id_db);
-        std::swap(db1.id_db_name, db2.id_db_name);
-        std::swap(db1.time_db, db2.time_db);
-        std::swap(db1.time_db_name, db2.time_db_name);
-    }
-    
-    ~SpanDB() {
-        if (id_db == NULL && time_db == NULL) {
-            return;
-        }
-        delete id_db;
-        delete time_db;
-        if (!FLAGS_rpcz_keep_span_db) {
-            std::string cmd = butil::string_printf("rm -rf %s %s",
-                                                  id_db_name.c_str(),
-                                                  time_db_name.c_str());
-            butil::ignore_result(system(cmd.c_str()));
-        }
-    }
-};
-
-static bool started_span_indexing = false;
-static pthread_once_t start_span_indexing_once = PTHREAD_ONCE_INIT;
-static int64_t g_last_time_key = 0;
-static int64_t g_last_delete_tm = 0;
-
-// Following variables are monitored by builtin services, thus non-static.
-static pthread_mutex_t g_span_db_mutex = PTHREAD_MUTEX_INITIALIZER;
-static bool g_span_ending = false;  // don't open span again if this var is 
true.
-// Can't use intrusive_ptr which has ctor/dtor issues.
-static SpanDB* g_span_db = NULL;
-bool has_span_db() { return !!g_span_db; }
 bvar::CollectorSpeedLimit g_span_sl = BVAR_COLLECTOR_SPEED_LIMIT_INITIALIZER;
 static bvar::DisplaySamplingRatio s_display_sampling_ratio(
     "rpcz_sampling_ratio", &g_span_sl);
 
 struct SpanEarlier {
     bool operator()(bvar::Collected* c1, bvar::Collected* c2) const {
-        return ((Span*)c1)->GetStartRealTimeUs() < 
((Span*)c2)->GetStartRealTimeUs();
+        return GetStartRealTimeUs((Span*)c1) < GetStartRealTimeUs((Span*)c2);
     }
 };
+
 class SpanPreprocessor : public bvar::CollectorPreprocessor {
 public:
     void process(std::vector<bvar::Collected*> & list) {
         // Sort spans by their starting time so that the code on making
         // time monotonic in Span::Index works better.
-        std::sort(list.begin(), list.end(), SpanEarlier()); 
+        std::sort(list.begin(), list.end(), SpanEarlier());
     }
 };
-static SpanPreprocessor* g_span_prep = NULL;
+static SpanPreprocessor g_span_prep;
 
 Review comment:
   避免在brpc框架中使用static non-pod,在main函数之前没构造,之后被析构,而client很可能在main函数之前之后运行。

----------------------------------------------------------------
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