Skip to content

Commit c3ec95b

Browse files
committed
opt(trace): 添加对trace提交时长的超时日志打印
1 parent bd45894 commit c3ec95b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

modules/trace/sink.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ void Sink::commitRecord(const char *name, const char *module, uint32_t line, uin
156156
if (!is_enabled_)
157157
return;
158158

159+
auto start_ts = std::chrono::steady_clock::now();
160+
159161
RecordHeader header = {
160162
.thread_id = ::syscall(SYS_gettid),
161163
.end_ts_us = end_timepoint_us,
@@ -170,6 +172,10 @@ void Sink::commitRecord(const char *name, const char *module, uint32_t line, uin
170172
async_pipe_.appendLockless(name, header.name_size);
171173
async_pipe_.appendLockless(module, header.module_size);
172174
async_pipe_.appendUnlock();
175+
176+
auto time_cost = std::chrono::steady_clock::now() - start_ts;
177+
if (time_cost > std::chrono::milliseconds(100))
178+
LogNotice("trace commit cost > 100 ms, %lu us", time_cost.count() / 1000);
173179
}
174180

175181
void Sink::onBackendRecvData(const void *data, size_t size)

0 commit comments

Comments
 (0)