MCPcopy Create free account
hub / github.com/apache/brpc / FindSpan

Function FindSpan

src/brpc/span.cpp:931–950  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

929// =====================================
930
931int FindSpan(uint64_t trace_id, uint64_t span_id, RpczSpan* response) {
932 butil::intrusive_ptr<SpanDB> db;
933 if (GetSpanDB(&db) != 0) {
934 return -1;
935 }
936 uint32_t key_data[4];
937 ToBigEndian(trace_id, key_data);
938 ToBigEndian(span_id, key_data + 2);
939 leveldb::Slice key((char*)key_data, sizeof(key_data));
940 std::string value;
941 leveldb::Status st = db->id_db->Get(leveldb::ReadOptions(), key, &value);
942 if (!st.ok()) {
943 return -1;
944 }
945 if (!response->ParseFromString(value)) {
946 LOG(ERROR) << "Fail to parse from the value";
947 return -1;
948 }
949 return 0;
950}
951
952void FindSpans(uint64_t trace_id, std::deque<RpczSpan>* out) {
953 out->clear();

Callers 1

default_methodMethod · 0.85

Calls 4

GetSpanDBFunction · 0.85
ToBigEndianFunction · 0.85
okMethod · 0.80
GetMethod · 0.45

Tested by

no test coverage detected