fix wrong span_id in full link tracing
This commit is contained in:
parent
4f2ab1f735
commit
03cafacec1
1
deps/oblib/src/lib/trace/ob_trace.cpp
vendored
1
deps/oblib/src/lib/trace/ob_trace.cpp
vendored
@ -413,6 +413,7 @@ ObSpanCtx* ObTrace::begin_span(uint32_t span_type, uint8_t level, bool is_follow
|
||||
new_span = freed_span_.remove_last();
|
||||
current_span_.add_first(new_span);
|
||||
new_span->span_type_ = span_type;
|
||||
new_span->span_id_.high_ = 0;
|
||||
new_span->span_id_.low_ = ++seq_;
|
||||
new_span->span_id_.high_ = 0;
|
||||
new_span->source_span_ = last_active_span_;
|
||||
|
14
deps/oblib/src/lib/trace/ob_trace.h
vendored
14
deps/oblib/src/lib/trace/ob_trace.h
vendored
@ -28,7 +28,7 @@
|
||||
#define FLT_END_SPAN(span) \
|
||||
if (OB_NOT_NULL(span)) { \
|
||||
OBTRACE->end_span(span); \
|
||||
if (span->span_id_.is_inited() && OBTRACE->is_auto_flush()) { \
|
||||
if (span->is_inited() && OBTRACE->is_auto_flush()) { \
|
||||
FLUSH_TRACE(); \
|
||||
} \
|
||||
}
|
||||
@ -126,6 +126,7 @@ public:
|
||||
|
||||
struct ObTagCtxBase
|
||||
{
|
||||
friend void flush_trace();
|
||||
ObTagCtxBase() : next_(nullptr), tag_type_(0) {}
|
||||
virtual ~ObTagCtxBase() {}
|
||||
virtual int tostring(char* buf, const int64_t buf_len, int64_t& pos)
|
||||
@ -146,6 +147,7 @@ struct ObTagCtxBase
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
protected:
|
||||
ObTagCtxBase* next_;
|
||||
uint16_t tag_type_;
|
||||
};
|
||||
@ -186,6 +188,7 @@ int tag_to_string(char* buf, const int64_t buf_len, int64_t& pos, const T& value
|
||||
template <typename T>
|
||||
struct ObTagCtx final : public ObTagCtxBase
|
||||
{
|
||||
friend struct ObTrace;
|
||||
ObTagCtx() {}
|
||||
virtual ~ObTagCtx() override {}
|
||||
virtual int tostring(char* buf, const int64_t buf_len, int64_t& pos) override
|
||||
@ -198,13 +201,18 @@ struct ObTagCtx final : public ObTagCtxBase
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
private:
|
||||
T data_;
|
||||
};
|
||||
|
||||
struct ObSpanCtx final : public common::ObDLinkBase<ObSpanCtx>
|
||||
{
|
||||
friend struct ObTrace;
|
||||
friend void flush_trace();
|
||||
public:
|
||||
ObSpanCtx();
|
||||
|
||||
OB_INLINE bool is_inited() const { return span_id_.is_inited(); }
|
||||
UUID get_span_id() const { return span_id_; }
|
||||
UUID span_id_;
|
||||
ObSpanCtx* source_span_;
|
||||
int64_t start_ts_;
|
||||
@ -348,7 +356,7 @@ public:
|
||||
{
|
||||
span_ = OBTRACE->begin_span(span_type, level, false);
|
||||
#ifndef NDEBUG
|
||||
if (OB_NOT_NULL(span_) && span_->span_id_.is_inited()) {
|
||||
if (OB_NOT_NULL(span_) && span_->is_inited()) {
|
||||
FLT_SET_TAG(span_back_trace, lbt());
|
||||
}
|
||||
#endif
|
||||
|
2
deps/oblib/unittest/lib/trace/test_trace.cpp
vendored
2
deps/oblib/unittest/lib/trace/test_trace.cpp
vendored
@ -54,7 +54,7 @@ TEST(TestTrace, basic_test)
|
||||
FLUSH_TRACE();
|
||||
auto t = std::thread([=]() {
|
||||
// RPC框架端完成初始化
|
||||
OBTRACE->init(trace_id, proxy->span_id_, (auto_flush << 7) + level);
|
||||
OBTRACE->init(trace_id, proxy->get_span_id(), (auto_flush << 7) + level);
|
||||
//
|
||||
FLTSpanGuard(ObSql);
|
||||
FLT_SET_TAG(sql_id, 123);
|
||||
|
Loading…
x
Reference in New Issue
Block a user