mirror of
https://gitee.com/openharmony/communication_ipc
synced 2024-12-04 14:18:48 +00:00
!397 Rename HiTrace to HiTraceChain
Merge pull request !397 from honghecun/master
This commit is contained in:
commit
60da11e971
@ -74,7 +74,7 @@ ohos_shared_library("ipc_core") {
|
||||
"access_token:libaccesstoken_sdk",
|
||||
"c_utils:utils",
|
||||
"dsoftbus:softbus_client",
|
||||
"hitrace_native:libhitrace",
|
||||
"hitrace_native:libhitracechain",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
]
|
||||
|
||||
|
@ -59,7 +59,7 @@ ohos_shared_library("ipc_single") {
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"hitrace_native:libhitrace",
|
||||
"hitrace_native:libhitracechain",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
]
|
||||
|
||||
|
@ -701,7 +701,7 @@ int DBinderBaseInvoker<T>::SendRequest(int32_t handle, uint32_t code, MessagePar
|
||||
int userWaitTime = option.GetWaitTime();
|
||||
MessageParcel &newData = const_cast<MessageParcel &>(data);
|
||||
size_t oldWritePosition = newData.GetWritePosition();
|
||||
HiTraceId traceId = HiTrace::GetId();
|
||||
HiTraceId traceId = HiTraceChain::GetId();
|
||||
// set client send trace point if trace is enabled
|
||||
HiTraceId childId = HitraceInvoker::TraceClientSend(handle, code, newData, flags, traceId);
|
||||
std::shared_ptr<T> session = WriteTransaction(BC_TRANSACTION, flags, handle, 0, code, data, seqNumber, 0);
|
||||
|
@ -100,7 +100,7 @@ int BinderInvoker::SendRequest(int handle, uint32_t code, MessageParcel &data, M
|
||||
ZLOGD(LABEL, "%{public}s: handle=%d ,flags:%u", __func__, handle, flags);
|
||||
MessageParcel &newData = const_cast<MessageParcel &>(data);
|
||||
size_t oldWritePosition = newData.GetWritePosition();
|
||||
HiTraceId traceId = HiTrace::GetId();
|
||||
HiTraceId traceId = HiTraceChain::GetId();
|
||||
// set client send trace point if trace is enabled
|
||||
HiTraceId childId = HitraceInvoker::TraceClientSend(handle, code, newData, flags, traceId);
|
||||
if (!WriteTransaction(BC_TRANSACTION, flags, handle, code, data, nullptr)) {
|
||||
|
@ -20,9 +20,7 @@
|
||||
|
||||
#include "hilog/log_c.h"
|
||||
#include "hilog/log_cpp.h"
|
||||
#include "hitrace/hitrace.h"
|
||||
#include "hitrace/hitracec.h"
|
||||
#include "hitrace/hitraceid.h"
|
||||
#include "hitrace/trace.h"
|
||||
#include "ipc_debug.h"
|
||||
#include "log_tags.h"
|
||||
#include "parcel.h"
|
||||
@ -45,7 +43,7 @@ HiTraceId HitraceInvoker::TraceClientSend(int32_t handle, uint32_t code, Parcel
|
||||
HiTraceId childId = traceId;
|
||||
bool isClientTraced = IsClientTraced(handle, flags, traceId);
|
||||
if (isClientTraced) {
|
||||
childId = HiTrace::CreateSpan();
|
||||
childId = HiTraceChain::CreateSpan();
|
||||
// add childid to parcel data
|
||||
uint8_t idBytes[HITRACE_ID_LEN];
|
||||
size_t idLen = (size_t)(childId.ToBytes(idBytes, HITRACE_ID_LEN));
|
||||
@ -70,7 +68,8 @@ HiTraceId HitraceInvoker::TraceClientSend(int32_t handle, uint32_t code, Parcel
|
||||
return childId;
|
||||
}
|
||||
// tracepoint: CS(Client Send)
|
||||
HiTrace::Tracepoint(HITRACE_TP_CS, childId, "%s handle=%d,code=%u", (flags & TF_ONE_WAY) ? "ASYNC" : "SYNC",
|
||||
HiTraceChain::Tracepoint(HITRACE_TP_CS, childId, "%s handle=%d,code=%u",
|
||||
(flags & TF_ONE_WAY) ? "ASYNC" : "SYNC",
|
||||
handle, code);
|
||||
flags |= TF_HITRACE;
|
||||
}
|
||||
@ -87,9 +86,9 @@ void HitraceInvoker::TraceClientReceieve(int32_t handle, uint32_t code, uint32_t
|
||||
if (isClientTraced) {
|
||||
if (!(flags & TF_ONE_WAY)) {
|
||||
// restore thread trace id
|
||||
HiTrace::SetId(traceId);
|
||||
HiTraceChain::SetId(traceId);
|
||||
// tracepoint: CR(Client Receive)
|
||||
HiTrace::Tracepoint(HITRACE_TP_CR, childId, "%s handle=%d,code=%u", "SYNC", handle, code);
|
||||
HiTraceChain::Tracepoint(HITRACE_TP_CR, childId, "%s handle=%d,code=%u", "SYNC", handle, code);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -123,9 +122,10 @@ bool HitraceInvoker::TraceServerReceieve(int32_t handle, uint32_t code, Parcel &
|
||||
return isServerTraced;
|
||||
}
|
||||
HiTraceId traceId(idBytes, sizeof(HiTraceIdStruct));
|
||||
HiTrace::SetId(traceId);
|
||||
HiTraceChain::SetId(traceId);
|
||||
// tracepoint: SR(Server Receive)
|
||||
HiTrace::Tracepoint(HITRACE_TP_SR, traceId, "%s handle=%d,code=%u", (flags & TF_ONE_WAY) ? "ASYNC" : "SYNC",
|
||||
HiTraceChain::Tracepoint(HITRACE_TP_SR, traceId,
|
||||
"%s handle=%d,code=%u", (flags & TF_ONE_WAY) ? "ASYNC" : "SYNC",
|
||||
handle, code);
|
||||
}
|
||||
|
||||
@ -138,9 +138,9 @@ void HitraceInvoker::TraceServerSend(int32_t handle, uint32_t code, bool isServe
|
||||
{
|
||||
if (isServerTraced) {
|
||||
// tracepoint: SS(Server Send)
|
||||
HiTrace::Tracepoint(HITRACE_TP_SS, HiTrace::GetId(), "%s handle=%d,code=%u",
|
||||
HiTraceChain::Tracepoint(HITRACE_TP_SS, HiTraceChain::GetId(), "%s handle=%d,code=%u",
|
||||
(flags & TF_ONE_WAY) ? "ASYNC" : "SYNC", handle, code);
|
||||
}
|
||||
HiTrace::ClearId();
|
||||
HiTraceChain::ClearId();
|
||||
}
|
||||
} // namespace OHOS
|
||||
|
@ -88,7 +88,7 @@ ohos_unittest("IPCHiTraceUnitTest") {
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"hitrace_native:libhitrace",
|
||||
"hitrace_native:libhitracechain",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"samgr:samgr_proxy",
|
||||
|
@ -154,9 +154,9 @@ static std::string PrintTagLog(const std::string &tag)
|
||||
|
||||
HWTEST_F(BinderTraceTest, Sync001, TestSize.Level1)
|
||||
{
|
||||
HiTraceId getId = HiTrace::GetId();
|
||||
HiTraceId getId = HiTraceChain::GetId();
|
||||
EXPECT_EQ(0, getId.IsValid());
|
||||
HiTraceId traceId = HiTrace::Begin("ipc hitrace", 0);
|
||||
HiTraceId traceId = HiTraceChain::Begin("ipc hitrace", 0);
|
||||
std::string chainId = HitraceLongToString(traceId.GetChainId());
|
||||
EXPECT_NE(0UL, chainId.size());
|
||||
IPCTestHelper helper;
|
||||
@ -185,10 +185,10 @@ HWTEST_F(BinderTraceTest, Sync001, TestSize.Level1)
|
||||
HiLog::Info(LOG_LABEL, "Got Stub node\n");
|
||||
}
|
||||
|
||||
getId = HiTrace::GetId();
|
||||
getId = HiTraceChain::GetId();
|
||||
EXPECT_EQ(1, getId.IsValid());
|
||||
HiTrace::End(traceId);
|
||||
getId = HiTrace::GetId();
|
||||
HiTraceChain::End(traceId);
|
||||
getId = HiTraceChain::GetId();
|
||||
EXPECT_EQ(0, getId.IsValid());
|
||||
std::string remainLogMsgs = BinderTraceGetRemainLog(logTag);
|
||||
EXPECT_EQ(0, BinderTraceCheckLog(remainLogMsgs, "HITRACE_TP_CS", chainId));
|
||||
@ -207,9 +207,9 @@ HWTEST_F(BinderTraceTest, Sync002, TestSize.Level1)
|
||||
"\\[[a-f0-9]{1,16}, [a-f0-9]{1,16}, 0\\] <HITRACE_TP_SS,chain=[0-9a-f]{1,16},span=[0-9a-f]{1,16},pspan=";
|
||||
const std::string HITRACE_TP_CR_LOG =
|
||||
"\\[[a-f0-9]{1,16}, 0, 0\\] <HITRACE_TP_CR,chain=[0-9a-f]{1,16},span=[0-9a-f]{1,16},pspan=";
|
||||
HiTraceId getId = HiTrace::GetId();
|
||||
HiTraceId getId = HiTraceChain::GetId();
|
||||
EXPECT_EQ(0, getId.IsValid());
|
||||
HiTraceId traceId = HiTrace::Begin("ipc hitrace", HITRACE_FLAG_TP_INFO);
|
||||
HiTraceId traceId = HiTraceChain::Begin("ipc hitrace", HITRACE_FLAG_TP_INFO);
|
||||
std::string chainId = HitraceLongToString(traceId.GetChainId());
|
||||
EXPECT_NE(0UL, chainId.size());
|
||||
IPCTestHelper helper;
|
||||
@ -238,10 +238,10 @@ HWTEST_F(BinderTraceTest, Sync002, TestSize.Level1)
|
||||
HiLog::Info(LOG_LABEL, "Got Stub node\n");
|
||||
}
|
||||
|
||||
getId = HiTrace::GetId();
|
||||
getId = HiTraceChain::GetId();
|
||||
EXPECT_EQ(1, getId.IsValid());
|
||||
HiTrace::End(traceId);
|
||||
getId = HiTrace::GetId();
|
||||
HiTraceChain::End(traceId);
|
||||
getId = HiTraceChain::GetId();
|
||||
EXPECT_EQ(0, getId.IsValid());
|
||||
}
|
||||
|
||||
@ -251,9 +251,9 @@ HWTEST_F(BinderTraceTest, Sync003, TestSize.Level1)
|
||||
const std::string HITRACE_TP_SR_LOG = "\\[[a-f0-9]{1,16}\\] <HITRACE_TP_SR,chain=[0-9a-f]{1,16},span=0,pspan=";
|
||||
const std::string HITRACE_TP_SS_LOG = "\\[[a-f0-9]{1,16}\\] <HITRACE_TP_SS,chain=[0-9a-f]{1,16},span=0,pspan=";
|
||||
const std::string HITRACE_TP_CR_LOG = "\\[[a-f0-9]{1,16}\\] <HITRACE_TP_CR,chain=[0-9a-f]{1,16},span=0,pspan=";
|
||||
HiTraceId getId = HiTrace::GetId();
|
||||
HiTraceId getId = HiTraceChain::GetId();
|
||||
EXPECT_EQ(0, getId.IsValid());
|
||||
HiTraceId traceId = HiTrace::Begin("ipc hitrace", HITRACE_FLAG_TP_INFO | HITRACE_FLAG_DONOT_CREATE_SPAN);
|
||||
HiTraceId traceId = HiTraceChain::Begin("ipc hitrace", HITRACE_FLAG_TP_INFO | HITRACE_FLAG_DONOT_CREATE_SPAN);
|
||||
std::string chainId = HitraceLongToString(traceId.GetChainId());
|
||||
EXPECT_NE(0UL, chainId.size());
|
||||
IPCTestHelper helper;
|
||||
@ -280,18 +280,18 @@ HWTEST_F(BinderTraceTest, Sync003, TestSize.Level1)
|
||||
HiLog::Info(LOG_LABEL, "Got Stub node\n");
|
||||
}
|
||||
|
||||
getId = HiTrace::GetId();
|
||||
getId = HiTraceChain::GetId();
|
||||
EXPECT_EQ(1, getId.IsValid());
|
||||
HiTrace::End(traceId);
|
||||
getId = HiTrace::GetId();
|
||||
HiTraceChain::End(traceId);
|
||||
getId = HiTraceChain::GetId();
|
||||
EXPECT_EQ(0, getId.IsValid());
|
||||
}
|
||||
|
||||
HWTEST_F(BinderTraceTest, Async001, TestSize.Level1)
|
||||
{
|
||||
HiTraceId getId = HiTrace::GetId();
|
||||
HiTraceId getId = HiTraceChain::GetId();
|
||||
EXPECT_EQ(0, getId.IsValid());
|
||||
HiTraceId traceId = HiTrace::Begin("ipc hitrace", HITRACE_FLAG_INCLUDE_ASYNC);
|
||||
HiTraceId traceId = HiTraceChain::Begin("ipc hitrace", HITRACE_FLAG_INCLUDE_ASYNC);
|
||||
std::string chainId = HitraceLongToString(traceId.GetChainId());
|
||||
EXPECT_NE(0UL, chainId.size());
|
||||
IPCTestHelper helper;
|
||||
@ -318,10 +318,10 @@ HWTEST_F(BinderTraceTest, Async001, TestSize.Level1)
|
||||
HiLog::Info(LOG_LABEL, "Got Stub node\n");
|
||||
}
|
||||
|
||||
getId = HiTrace::GetId();
|
||||
getId = HiTraceChain::GetId();
|
||||
EXPECT_EQ(1, getId.IsValid());
|
||||
HiTrace::End(traceId);
|
||||
getId = HiTrace::GetId();
|
||||
HiTraceChain::End(traceId);
|
||||
getId = HiTraceChain::GetId();
|
||||
EXPECT_EQ(0, getId.IsValid());
|
||||
std::string remainLogMsgs = BinderTraceGetRemainLog(logTag);
|
||||
EXPECT_EQ(0, BinderTraceCheckLog(remainLogMsgs, "HITRACE_TP_CS", chainId));
|
||||
@ -336,9 +336,9 @@ HWTEST_F(BinderTraceTest, Async002, TestSize.Level1)
|
||||
"\\[[a-f0-9]{1,16}, 0, 0\\] <HITRACE_TP_CS,chain=[0-9a-f]{1,16},span=[0-9a-f]{1,16},pspan=";
|
||||
const std::string HITRACE_TP_SR_LOG =
|
||||
"\\[[a-f0-9]{1,16}, [a-f0-9]{1,16}, 0\\] <HITRACE_TP_SR,chain=[0-9a-f]{1,16},span=[0-9a-f]{1,16},pspan=";
|
||||
HiTraceId getId = HiTrace::GetId();
|
||||
HiTraceId getId = HiTraceChain::GetId();
|
||||
EXPECT_EQ(0, getId.IsValid());
|
||||
HiTraceId traceId = HiTrace::Begin("ipc hitrace", HITRACE_FLAG_TP_INFO | HITRACE_FLAG_INCLUDE_ASYNC);
|
||||
HiTraceId traceId = HiTraceChain::Begin("ipc hitrace", HITRACE_FLAG_TP_INFO | HITRACE_FLAG_INCLUDE_ASYNC);
|
||||
std::string chainId = HitraceLongToString(traceId.GetChainId());
|
||||
EXPECT_NE(0UL, chainId.size());
|
||||
IPCTestHelper helper;
|
||||
@ -365,10 +365,10 @@ HWTEST_F(BinderTraceTest, Async002, TestSize.Level1)
|
||||
HiLog::Info(LOG_LABEL, "Got Stub node\n");
|
||||
}
|
||||
|
||||
getId = HiTrace::GetId();
|
||||
getId = HiTraceChain::GetId();
|
||||
EXPECT_EQ(1, getId.IsValid());
|
||||
HiTrace::End(traceId);
|
||||
getId = HiTrace::GetId();
|
||||
HiTraceChain::End(traceId);
|
||||
getId = HiTraceChain::GetId();
|
||||
EXPECT_EQ(0, getId.IsValid());
|
||||
}
|
||||
|
||||
@ -376,9 +376,9 @@ HWTEST_F(BinderTraceTest, Async003, TestSize.Level1)
|
||||
{
|
||||
const std::string HITRACE_TP_CS_LOG = "\\[[a-f0-9]{1,16}\\] <HITRACE_TP_CS,chain=[0-9a-f]{1,16},span=0,pspan=";
|
||||
const std::string HITRACE_TP_SR_LOG = "\\[[a-f0-9]{1,16}\\] <HITRACE_TP_SR,chain=[0-9a-f]{1,16},span=0,pspan=";
|
||||
HiTraceId getId = HiTrace::GetId();
|
||||
HiTraceId getId = HiTraceChain::GetId();
|
||||
EXPECT_EQ(0, getId.IsValid());
|
||||
HiTraceId traceId = HiTrace::Begin("ipc hitrace",
|
||||
HiTraceId traceId = HiTraceChain::Begin("ipc hitrace",
|
||||
HITRACE_FLAG_TP_INFO | HITRACE_FLAG_INCLUDE_ASYNC | HITRACE_FLAG_DONOT_CREATE_SPAN);
|
||||
std::string chainId = HitraceLongToString(traceId.GetChainId());
|
||||
EXPECT_NE(0UL, chainId.size());
|
||||
@ -406,9 +406,9 @@ HWTEST_F(BinderTraceTest, Async003, TestSize.Level1)
|
||||
HiLog::Info(LOG_LABEL, "Got Stub node\n");
|
||||
}
|
||||
|
||||
getId = HiTrace::GetId();
|
||||
getId = HiTraceChain::GetId();
|
||||
EXPECT_EQ(1, getId.IsValid());
|
||||
HiTrace::End(traceId);
|
||||
getId = HiTrace::GetId();
|
||||
HiTraceChain::End(traceId);
|
||||
getId = HiTraceChain::GetId();
|
||||
EXPECT_EQ(0, getId.IsValid());
|
||||
}
|
||||
|
@ -1079,7 +1079,7 @@ HWTEST_F(DbinderTest, DbinderRemoteCall024, TestSize.Level3)
|
||||
{
|
||||
DBINDER_LOGI(LOG_LABEL, "");
|
||||
SetCurrentTestCase(DBINDER_TEST_TRACE_001);
|
||||
HiTraceId traceId = HiTrace::Begin("rpc hitrace", 0);
|
||||
HiTraceId traceId = HiTraceChain::Begin("rpc hitrace", 0);
|
||||
|
||||
/*
|
||||
* @tc.steps: step1.Get a proxy (called testService) from remote server.
|
||||
|
@ -494,7 +494,7 @@ int DBinderTestServiceStub::OnReverseInt(MessageParcel &data, MessageParcel &rep
|
||||
|
||||
int DBinderTestServiceStub::OnGetChildId(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
uint64_t reqData = HiTrace::GetId().GetChainId();
|
||||
uint64_t reqData = HiTraceChain::GetId().GetChainId();
|
||||
if (!reply.WriteUint64(reqData)) {
|
||||
DBINDER_LOGE(LOG_LABEL, "fail to write parcel");
|
||||
return ERR_INVALID_STATE;
|
||||
|
Loading…
Reference in New Issue
Block a user