add hitrace

Signed-off-by: wanderer-dl122 <dengliang21@huawei.com>
This commit is contained in:
wanderer-dl122
2022-06-08 10:12:36 +08:00
parent 9abc473ff6
commit 74d82cd3c2
5 changed files with 20 additions and 15 deletions
@@ -66,7 +66,7 @@ std::map<std::string, DHType> g_mapDhTypeName = {
int32_t ComponentLoader::Init()
{
DHTraceStart("COMPONENT_LOAD_START");
DHTraceStart(COMPONENT_LOAD_START);
int32_t ret = ParseConfig();
DHTraceEnd();
@@ -275,7 +275,7 @@ int32_t ComponentLoader::ReleaseHandler(void *&handler)
int32_t ComponentLoader::UnInit()
{
DHLOGI("release all handler");
DHTraceStart("COMPONENT_RELEASE_START");
DHTraceStart(COMPONENT_RELEASE_START);
int32_t ret = DH_FWK_SUCCESS;
for (std::map<DHType, CompHandler>::iterator iter = compHandlerMap_.begin();
iter != compHandlerMap_.end(); iter++) {
@@ -252,7 +252,7 @@ int32_t ComponentManager::Enable(const std::string &networkId, const std::string
}
auto compEnable = std::make_shared<ComponentEnable>();
CompEnableTraceStart(dhType);
DHCompMgrTraceStart(GetAnonyString(networkId), GetAnonyString(dhId), ENABLE_START);
auto result = compEnable->Enable(networkId, dhId, param, find->second);
if (result != DH_FWK_SUCCESS) {
for (int32_t retryCount = 0; retryCount < ENABLE_RETRY_MAX_TIMES; retryCount++) {
@@ -288,7 +288,7 @@ int32_t ComponentManager::Disable(const std::string &networkId, const std::strin
}
auto compDisable = std::make_shared<ComponentDisable>();
CompDisableTraceStart(dhType);
DHCompMgrTraceStart(GetAnonyString(networkId), GetAnonyString(dhId), DISABLE_START);
auto result = compDisable->Disable(networkId, dhId, find->second);
if (result != DH_FWK_SUCCESS) {
for (int32_t retryCount = 0; retryCount < DISABLE_RETRY_MAX_TIMES; retryCount++) {
@@ -48,7 +48,10 @@ void LocalHardwareManager::Init()
DHLOGE("Initialize %#X failed", dhType);
continue;
}
DHQeryTraceStart(dhType);
QueryLocalHardware(dhType, hardwareHandler);
DHTraceEnd();
if (!hardwareHandler->IsSupportPlugin()) {
DHLOGI("hardwareHandler is not support hot swap plugin, release!");
ComponentLoader::GetInstance().ReleaseHardwareHandler(dhType);
+9 -2
View File
@@ -25,8 +25,15 @@ namespace OHOS {
namespace DistributedHardware {
constexpr uint64_t DHFWK_HITRACE_LABEL = HITRACE_TAG_DISTRIBUTED_HARDWARE_FWK;
void CompEnableTraceStart(const DHType dhType);
void CompDisableTraceStart(const DHType dhType);
const std::string COMPONENT_LOAD_START = "COMPONENT_LOAD_START";
const std::string COMPONENT_RELEASE_START = "COMPONENT_RELEASE_START";
const std::string COMPONENT_INIT_START = "COMPONENT_INIT_START";
const std::string QUERY_START = "QUERY_START";
const std::string ENABLE_START = "ENABLE_START";
const std::string DISABLE_START = "DISABLE_START";
void DHCompMgrTraceStart(const std::string &anonyNetworkId, const std::string &anonyDHId, const std::string &msg);
void DHQeryTraceStart(const DHType dhType);
void DHTraceStart(const std::string &msg);
void DHTraceEnd();
} // namespace DistributedHardware
+4 -9
View File
@@ -19,24 +19,19 @@
namespace OHOS {
namespace DistributedHardware {
void CompEnableTraceStart(const DHType dhType)
void DHCompMgrTraceStart(const std::string &anonyNetworkId, const std::string &anonyDHId, const std::string &msg)
{
std::string dhTypeStr = "UNKNOWN";
auto it = DHTypeStrMap.find(dhType);
if (it != DHTypeStrMap.end()) {
dhTypeStr = it->second;
}
StartTrace(DHFWK_HITRACE_LABEL, dhTypeStr + "_ENABLE_START");
StartTrace(DHFWK_HITRACE_LABEL, anonyNetworkId + "_" + anonyDHId + "_" + msg);
}
void CompDisableTraceStart(const DHType dhType)
void DHQeryTraceStart(const DHType dhType)
{
std::string dhTypeStr = "UNKNOWN";
auto it = DHTypeStrMap.find(dhType);
if (it != DHTypeStrMap.end()) {
dhTypeStr = it->second;
}
StartTrace(DHFWK_HITRACE_LABEL, dhTypeStr + "_DISABLE_START");
StartTrace(DHFWK_HITRACE_LABEL, dhTypeStr + "_" + QUERY_START);
}
void DHTraceStart(const std::string &msg)