Go to file
jiangwei d010361a0c fix: epoll_wait函数返回错误EINTR后再次执行该方法
Signed-off-by: jiangwei <jiangwei214@h-partners.com>
2024-10-22 11:54:04 +08:00
cmd modify head file for hiview 2024-09-23 14:59:57 +08:00
config feat: hitracedump clear old file policy update 2024-09-01 21:11:58 +08:00
figures Description:[feature] add hitrace 2021-08-18 22:02:26 +08:00
frameworks High frequency log cleaning & repair hitrace tool parse 2024-10-11 19:35:39 +08:00
interfaces fix: epoll_wait函数返回错误EINTR后再次执行该方法 2024-10-22 11:54:04 +08:00
test fix: 对trace文件移除的结果进行判断,并添加日志记录及用例看护 2024-10-11 16:52:22 +08:00
tools/hitrace_converter 新增switch字段解析,兼容旧格式 2024-10-18 16:06:18 +08:00
utils fix: Alarm cleaning 2024-09-24 14:24:34 +08:00
.gitignore fix: some misspelled words and logic errors. 2024-06-28 23:55:38 +08:00
bundle.json add hitrace fuzz testcases 2024-09-11 15:38:28 +08:00
Cargo.toml 回滚删除Cargo.toml 2024-06-25 19:22:16 +08:00
hitrace.gni feat: hitracedump clear old file policy update 2024-09-01 21:11:58 +08:00
LICENSE Description:[feature] add hitrace 2021-08-18 22:02:26 +08:00
OAT.xml 新增OAT文件,屏蔽静态检查问题 2024-06-05 16:39:45 +08:00
README_zh.md 更新README文档 2022-02-25 11:37:30 +08:00
README.md 修改英文readme的错误链接 2022-03-12 15:02:31 +08:00

HiTrace

Overview

HiTrace provides APIs to implement call chain tracing throughout a service process. With HiTrace, you can quickly obtain the run log for the call chain of a specified service process and locate faults in cross-device, cross-process, or cross-thread communications.

Architecture

Figure 1 Architecture of HiTrace

HiTrace is the lightweight implementation based on the distributed call chain of cloud computing. HiTrace implements call chain tracing as follows:

  • Transfers traceid in cross-device, cross-process, and cross-thread communications.
  • Stores traceid in the thread local storage TLS at the Native layer of the process.
  • Automatically adds traceid to existing events and run logs.

Directory Structure

/base/hiviewdfx/hitrace
├── frameworks            # Framework code
│   └── native            # HiTrace Native implementation code
├── interfaces            # APIs
│   └── js                # JS APIs
│       └── kits          # JS inner implementation code 
│   └── native            # C/C++ APIs
│       └── innerkits     # Header files opened to internal subsystems
└── test                  # Test cases

Constraints

HiTrace is already supported by the IPC and EventHandler communication mechanisms. If you are using a custom communication mechanism, adaptation is required to use HiTrace.

Usage

Available APIs

Major APIs of HiTrace

Class

API

Description

HiTrace

HiTraceId begin(String name, int flags)

Starts call chain tracing, generates a HiTraceId object, and sets it in the TLS of the calling thread.

Input parameters:

name: Indicates the name of the service process.

flags: Indicates call chain flags, which can be used in combination.

HITRACE_FLAG_INCLUDE_ASYNC: Traces both synchronous and asynchronous calls. By default, only synchronous calls are traced.

HITRACE_FLAG_DONOT_CREATE_SPAN: Do note create a span. By default, a span is created.

HITRACE_FLAG_TP_INFO: Outputs the tracepoint information. By default, the tracepoint information is not output.

HITRACE_FLAG_NO_BE_INFO: Do not output the start and end information. By default, the information is output.

HITRACE_FLAG_DONOT_ENABLE_LOG: Do not associate logs for output. By default, logs are associated for output.

HITRACE_FLAG_FAULT_TRIGGER: Triggers call chain tracing by fault. By default, call chain tracing is triggered normally.

HITRACE_FLAG_D2D_TP_INFO: Outputs inter-device tracepoint information. By default, the tracepoint information is not output.

HITRACE_FLAG_DEFAULT: Indicates the default flag.

Output parameters: none

Return value: Returns a valid HiTraceId object if call chain tracing is triggered successfully; returns an invalid object otherwise.

Note: In nested tracing mode, an invalid object will be returned if tracing is started at the nested layer.

void end(HiTraceId id)

Stops call chain tracing based on the HiTraceId object returned by the Begin API, and clears the HiTraceId object in the TLS of the calling thread.

Input parameters:

id: Indicates the HiTraceId object.

Output parameters: none

Return value: none

Repositories Involved

DFX SubSystem

hiviewdfx_hiview

hiviewdfx_hilog

hiviewdfx_hiappevent

hiviewdfx_hisysevent