未验证 提交 4c9ed452 编写于 作者: O openharmony_ci 提交者: Gitee

!4197 修改错误的api接口调用

Merge pull request !4197 from honghecun/OpenHarmony-3.1-Release
# Distributed Call Chain Tracing
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
```
```js
import hiTraceChain from '@ohos.hiTraceChain';
```
......@@ -16,16 +16,16 @@ Enumerates trace flag types.
**System capability**: SystemCapability.HiviewDFX.HiTrace
| Name| Default Value| Description|
| Name | Default Value | Description |
| -------- | -------- | -------- |
| DEFAULT | 0 | Default flag. |
| INCLUDE_ASYNC | 1 | Asynchronous call flag. By default, only synchronous calls are traced. If this flag is set, both synchronous and asynchronous calls will be traced. |
| DONOT_CREATE_SPAN | 1 << 1 | No span flag. By default, a span is automatically created during tracing of synchronous and asynchronous calls. If this flag is set, no span will be created. |
| TP_INFO | 1 << 2 | Trace point flag. By default, no trace point is added when tracing is enabled. This flag is used for debugging. If this flag is set, trace points will be automatically added on the TX and RX sides of synchronous and asynchronous calls to output trace point and timestamp information. Trace points are classified into four types: [CS, SR, SS, and CR](#hitracetracepointtype). For a synchronous call, the output trace points are CS, SR, SS, and CR; for an asynchronous call, the output trace points are CS, SR, and SS. |
| NO_BE_INFO | 1 << 3 | No begin/end flag. By default, information about the start and end of the trace task is printed. If this flag is set, information about the start and end of the trace task will not be printed.|
| DEFAULT | 0 | Default flag. |
| INCLUDE_ASYNC | 1 | Asynchronous call flag. By default, only synchronous calls are traced. If this flag is set, both synchronous and asynchronous calls will be traced. |
| DONOT_CREATE_SPAN | 1 << 1 | No span flag. By default, a span is automatically created during tracing of synchronous and asynchronous calls. If this flag is set, no span will be created. |
| TP_INFO | 1 << 2 | Trace point flag. By default, no trace point is added when tracing is enabled. This flag is used for debugging. If this flag is set, trace points will be automatically added on the TX and RX sides of synchronous and asynchronous calls to output trace point and timestamp information. Trace points are classified into four types: [CS, SR, SS, and CR](#hitracetracepointtype). For a synchronous call, the output trace points are CS, SR, SS, and CR; for an asynchronous call, the output trace points are CS, SR, and SS. |
| NO_BE_INFO | 1 << 3 | No begin/end flag. By default, information about the start and end of the trace task is printed. If this flag is set, information about the start and end of the trace task will not be printed. |
| DISABLE_LOG | 1 << 4 | Log association flag. If this flag is set, information about the trace task will not be printed. |
| FAILURE_TRIGGER | 1 << 5 | Failure trigger flag. This flag is reserved for future use. |
| D2D_TP_INFO | 1 << 6 | Device-to-device trace point flag. It is a subset of **TP_INFO**. If this flag is set, trace points are added only for call chain tracing between devices.|
| D2D_TP_INFO | 1 << 6 | Device-to-device trace point flag. It is a subset of **TP_INFO**. If this flag is set, trace points are added only for call chain tracing between devices. |
## HiTraceTracepointType
......@@ -33,13 +33,13 @@ Enumerates trace point types.
**System capability**: SystemCapability.HiviewDFX.HiTrace
| Name| Default Value| Description|
| Name| Default Value | Description |
| -------- | -------- | -------- |
| CS | 0 | Client Send (CS) trace point. |
| CR | 1 | Client Receive (CS) trace point. |
| SS | 2 | Server Send (SS) trace point. |
| SR | 3 | Server Receive (SR) trace point. |
| GENERAL | 4 | General trace points except CS, CR, SS, and SR.|
| CS | 0 | Client Send (CS) trace point. |
| CR | 1 | Client Receive (CS) trace point. |
| SS | 2 | Server Send (SS) trace point. |
| SR | 3 | Server Receive (SR) trace point. |
| GENERAL | 4 | General trace points except CS, CR, SS, and SR. |
## HiTraceCommunicationMode
......@@ -47,9 +47,9 @@ Enumerates communication modes.
**System capability**: SystemCapability.HiviewDFX.HiTrace
| Name| Default Value| Description|
| Name| Default Value | Description |
| -------- | -------- | -------- |
| DEFAULT | 0 | Default communication mode. |
| DEFAULT | 0 | Default communication mode. |
| THREAD | 1 | Inter-thread communication. |
| PROCESS | 2 | Inter-process communication. |
| DEVICE | 3 | Inter-device communication. |
......@@ -60,12 +60,12 @@ Defines a **HiTraceId** object.
**System capability**: SystemCapability.HiviewDFX.HiTrace
| Name| Type| Mandatory| Description|
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| chainId | bigint | Yes| Call chain ID. |
| spanId | number | No| Span ID. |
| parentSpanId | number | No| Parent span ID. |
| flags | number | No| Trace flag combination.|
| chainId | bigint | Yes| Call chain ID. |
| spanId | number | No| Span ID. |
| parentSpanId | number | No| Parent span ID. |
| flags | number | No| Trace flag combination. |
## hiTraceChain.begin
......@@ -77,20 +77,20 @@ Starts call chain tracing. This API works in synchronous manner.
**Parameters**
| Name| Type| Mandatory| Description|
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| name | string | Yes| Traced service name.|
| flags | number | Yes| Trace flag combination. For details, see [HiTraceFlag](#hitraceflag).|
| name | string | Yes| Traced service name. |
| flags | number | Yes| Trace flag combination. For details, see [HiTraceFlag](#hitraceflag). |
**Return Value**
| Type| Description|
| Type | Description |
| -------- | -------- |
| [HiTraceId](#hitraceid) | **HiTraceId** instance.|
| [HiTraceId](#hitraceid) | **HiTraceId** instance. |
**Example**
```
```js
let asyncTraceId = hiTraceChain.begin("business", hiTraceChain.HiTraceFlag.INCLUDE_ASYNC | hiTraceChain.HiTraceFlag.DONOT_CREATE_SPAN);
```
......@@ -104,13 +104,13 @@ Stops call chain tracing. This API works in synchronous manner.
**Parameters**
| Name| Type| Mandatory| Description|
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| id | [HiTraceId](#hitraceid) | Yes| **HiTraceId** instance.|
| id | [HiTraceId](#hitraceid) | Yes| **HiTraceId** instance. |
**Example**
```
```js
let asyncTraceId = hiTraceChain.begin("business");
// End the call chain tracing after the service logic is executed for several times.
hiTraceChain.end(asyncTraceId);
......@@ -126,13 +126,13 @@ Obtains the trace ID. This API works in synchronous manner.
**Return Value**
| Type| Description|
| Type | Description |
| -------- | -------- |
| [HiTraceId](#hitraceid) | **HiTraceId** instance.|
| [HiTraceId](#hitraceid) | **HiTraceId** instance. |
**Example**
```
```js
let traceId = hiTraceChain.begin("business");
// Obtain the current trace ID after the service logic is executed for several times.
let curTraceId = hiTraceChain.getId();
......@@ -148,13 +148,14 @@ Sets a trace ID. This API works in synchronous manner.
**Parameters**
| Name| Type| Mandatory| Description|
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| id | [HiTraceId](#hitraceid) | Yes| **HiTraceId** instance.|
| id | [HiTraceId](#hitraceid) | Yes| **HiTraceId** instance. |
**Example**
```
```js
let asyncTraceId;
let traceId = hiTraceChain.begin("business");
// Set the current trace ID after the service logic is executed for several times.
hiTraceChain.setId(asyncTraceId);
......@@ -170,7 +171,7 @@ Clears the trace ID. This API works in synchronous manner.
**Example**
```
```js
let traceId = hiTraceChain.begin("business");
// Clear the current trace ID after the service logic is executed for several times.
hiTraceChain.clearId();
......@@ -186,13 +187,13 @@ Creates a trace span. This API works in synchronous manner.
**Return Value**
| Type| Description|
| Type | Description |
| -------- | -------- |
| [HiTraceId](#hitraceid) | **HiTraceId** instance.|
| [HiTraceId](#hitraceid) | **HiTraceId** instance. |
**Example**
```
```js
let traceId = hiTraceChain.begin("business");
// Create a trace span after the service logic is executed for several times.
let spanTraceId = hiTraceChain.createSpan();
......@@ -208,16 +209,16 @@ Triggers a trace point. This API works in synchronous manner.
**Parameters**
| Name| Type| Mandatory| Description|
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| mode | [HiTraceCommunicationMode](#hitracecommunicationmode) | Yes| Communication mode for the trace point.|
| type | [HiTraceTracepointType](#hitracetracepointtype)| Yes| Trace point type.|
| id | [HiTraceId](#hitraceid) | Yes| **HiTraceId** instance for trace point triggering.|
| msg | string | No| Trace description passed for trace point triggering.|
| mode | [HiTraceCommunicationMode](#hitracecommunicationmode) | Yes| Communication mode for the trace point. |
| type | [HiTraceTracepointType](#hitracetracepointtype)| Yes| Trace point type. |
| id | [HiTraceId](#hitraceid) | Yes| **HiTraceId** instance for trace point triggering. |
| msg | string | No| Trace description passed for trace point triggering. |
**Example**
```
```js
let asyncTraceId = hiTraceChain.begin("business", hiTraceChain.HiTraceFlag.INCLUDE_ASYNC | hiTraceChain.HiTraceFlag.DONOT_CREATE_SPAN);
// Trigger the trace point after the service logic is executed for several times.
hiTraceChain.tracepoint(hiTraceChain.HiTraceCommunicationMode.THREAD, hiTraceChain.HiTraceTracepointType.SS, asyncTraceId, "Just a example");
......@@ -233,19 +234,19 @@ Checks whether a **HiTraceId** instance is valid. This API works in synchronous
**Parameters**
| Name| Type| Mandatory| Description|
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| id | [HiTraceId](#hitraceid) | Yes| **HiTraceId** instance.|
| id | [HiTraceId](#hitraceid) | Yes| **HiTraceId** instance. |
**Return Value**
| Type| Description|
| Type | Description |
| -------- | -------- |
| boolean | Returns **true** if the **HiTraceId** instance is valid; returns **false** otherwise.|
| boolean | Returns **true** if the **HiTraceId** instance is valid; returns **false** otherwise. |
**Example**
```
```js
let traceId = hiTraceChain.begin("business");
let traceIdIsvalid = hiTraceChain.isValid(traceId);
```
......@@ -260,20 +261,20 @@ Checks whether the specified trace flag in the **HiTraceId** instance is enabled
**Parameters**
| Name| Type| Mandatory| Description|
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| id | [HiTraceId](#hitraceid) | Yes| **HiTraceId** instance.|
| flag | [HiTraceFlag](#hitraceflag) | Yes| Specified trace flag.|
| id | [HiTraceId](#hitraceid) | Yes | **HiTraceId** instance. |
| flag | [HiTraceFlag](#hitraceflag) | Yes | Specified trace flag. |
**Return Value**
| Type| Description|
| Type | Description |
| -------- | -------- |
| boolean | Returns **true** if the specified trace flag in the **HiTraceId** instance is enabled; returns **false** otherwise.|
| boolean | Returns **true** if the specified trace flag in the **HiTraceId** instance is enabled; returns **false** otherwise. |
**Example**
```
```js
let asyncTraceId = hiTraceChain.begin("business", hiTraceChain.HiTraceFlag.INCLUDE_ASYNC);
// The value of enabledDoNotCreateSpanFlag is true.
let enabledDoNotCreateSpanFlag = hiTraceChain.isFlagEnabled(asyncTraceId, hiTraceChain.HiTraceFlag.INCLUDE_ASYNC);
......@@ -288,16 +289,16 @@ Enables the specified trace flag in the **HiTraceId** instance. This API works i
**System capability**: SystemCapability.HiviewDFX.HiTrace
**Parameters**
| Name| Type| Mandatory| Description|
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| id | [HiTraceId](#hitraceid) | Yes| **HiTraceId** instance.|
| flag | [HiTraceFlag](#hitraceflag) | Yes| Specified trace flag.|
| id | [HiTraceId](#hitraceid) | Yes | **HiTraceId** instance. |
| flag | [HiTraceFlag](#hitraceflag) | Yes | Specified trace flag. |
**Example**
```
```js
let asyncTraceId = hiTraceChain.begin("business", hiTraceChain.HiTraceFlag.INCLUDE_ASYNC);
hiTraceChain.enable(asyncTraceId, hiTraceChain.HiTraceFlag.DONOT_CREATE_SPAN);
hiTraceChain.enableFlag(asyncTraceId, hiTraceChain.HiTraceFlag.DONOT_CREATE_SPAN);
// The value of enabledDoNotCreateSpanFlag is true.
let enabledDoNotCreateSpanFlag = hiTraceChain.isFlagEnabled(asyncTraceId, hiTraceChain.HiTraceFlag.DONOT_CREATE_SPAN);
```
# Performance Tracing
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
```
```js
import hiTraceMeter from '@ohos.hiTraceMeter';
```
......@@ -25,16 +25,15 @@ If the trace tasks with the same name are not performed at the same time, the sa
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| name | string | Yes| Name of the trace task to start.|
| taskId | number | Yes| Task ID.|
| name | string | Yes | Name of the trace task to start. |
| taskId | number | Yes| Task ID. |
**Example**
```
```js
hiTraceMeter.startTrace("myTestFunc", 1);
hiTraceMeter.startTrace("myTestFunc", 1, 5); // The expected duration of the trace task is 5 ms.
```
......@@ -52,16 +51,16 @@ To stop a trace task, the values of name and task ID in **finishTrace** must be
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| name | string | Yes| Name of the trace task to start.|
| taskId | number | Yes| Task ID.|
| name | string | Yes| Name of the trace task to start. |
| taskId | number | Yes| Task ID. |
**Example**
```
```js
hiTraceMeter.finishTrace("myTestFunc", 1);
```
```
```js
// Start track tasks with the same name concurrently.
hiTraceMeter.startTrace("myTestFunc", 1);
// Service flow
......@@ -72,7 +71,7 @@ hiTraceMeter.finishTrace("myTestFunc", 1);
hiTraceMeter.finishTrace("myTestFunc", 2);
```
```
```js
// Start track tasks with the same name at different times.
hiTraceMeter.startTrace("myTestFunc", 1);
// Service flow
......@@ -96,11 +95,11 @@ Traces the value changes of a variable.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| name | string | Yes| Name of the variable.|
| count | number | Yes| Value of the variable.|
| name | string | Yes | Name of the variable. |
| count | number | Yes | Value of the variable. |
**Example**
```
```js
let traceCount = 3;
hiTraceMeter.traceByValue("myTestCount", traceCount);
traceCount = 4;
......
......@@ -5,7 +5,7 @@
## 导入模块
```
```js
import hiTraceChain from '@ohos.hiTraceChain';
```
......@@ -90,7 +90,7 @@ begin(name: string, flags: number = HiTraceFlag.DEFAULT): HiTraceId
**示例:**
```
```js
let asyncTraceId = hiTraceChain.begin("business", hiTraceChain.HiTraceFlag.INCLUDE_ASYNC | hiTraceChain.HiTraceFlag.DONOT_CREATE_SPAN);
```
......@@ -110,7 +110,7 @@ end(id: HiTraceId): void
**示例:**
```
```js
let asyncTraceId = hiTraceChain.begin("business");
// 若干业务逻辑完成后,结束跟踪。
hiTraceChain.end(asyncTraceId);
......@@ -132,7 +132,7 @@ getId(): HiTraceId
**示例:**
```
```js
let traceId = hiTraceChain.begin("business");
// 若干业务逻辑完成后,获取当前HiTraceId。
let curTraceId = hiTraceChain.getId();
......@@ -154,7 +154,8 @@ setId(id: HiTraceId): void
**示例:**
```
```js
let asyncTraceId;
let traceId = hiTraceChain.begin("business");
// 若干业务逻辑完成后,设置当前HiTraceId。
hiTraceChain.setId(asyncTraceId);
......@@ -170,7 +171,7 @@ clearId(): void
**示例:**
```
```js
let traceId = hiTraceChain.begin("business");
// 若干业务逻辑完成后,清除当前HiTraceId。
hiTraceChain.clearId();
......@@ -192,7 +193,7 @@ createSpan(): HiTraceId
**示例:**
```
```js
let traceId = hiTraceChain.begin("business");
// 若干业务逻辑完成后,创建跟踪分支。
let spanTraceId = hiTraceChain.createSpan();
......@@ -217,7 +218,7 @@ tracepoint(mode: HiTraceCommunicationMode, type: HiTraceTracepointType, id: HiTr
**示例:**
```
```js
let asyncTraceId = hiTraceChain.begin("business", hiTraceChain.HiTraceFlag.INCLUDE_ASYNC | hiTraceChain.HiTraceFlag.DONOT_CREATE_SPAN);
// 若干业务逻辑完成后,触发信息埋点操作。
hiTraceChain.tracepoint(hiTraceChain.HiTraceCommunicationMode.THREAD, hiTraceChain.HiTraceTracepointType.SS, asyncTraceId, "Just a example");
......@@ -245,7 +246,7 @@ isValid(id: HiTraceId): boolean
**示例:**
```
```js
let traceId = hiTraceChain.begin("business");
let traceIdIsvalid = hiTraceChain.isValid(traceId);
```
......@@ -273,7 +274,7 @@ isFlagEnabled(id: HiTraceId, flag: HiTraceFlag): boolean
**示例:**
```
```js
let asyncTraceId = hiTraceChain.begin("business", hiTraceChain.HiTraceFlag.INCLUDE_ASYNC);
// enabledDoNotCreateSpanFlag为true
let enabledDoNotCreateSpanFlag = hiTraceChain.isFlagEnabled(asyncTraceId, hiTraceChain.HiTraceFlag.INCLUDE_ASYNC);
......@@ -295,9 +296,9 @@ enableFlag(id: HiTraceId, flag: HiTraceFlag): void
**示例:**
```
```js
let asyncTraceId = hiTraceChain.begin("business", hiTraceChain.HiTraceFlag.INCLUDE_ASYNC);
hiTraceChain.enable(asyncTraceId, hiTraceChain.HiTraceFlag.DONOT_CREATE_SPAN);
hiTraceChain.enableFlag(asyncTraceId, hiTraceChain.HiTraceFlag.DONOT_CREATE_SPAN);
// enabledDoNotCreateSpanFlag为true
let enabledDoNotCreateSpanFlag = hiTraceChain.isFlagEnabled(asyncTraceId, hiTraceChain.HiTraceFlag.DONOT_CREATE_SPAN);
```
......@@ -6,7 +6,7 @@
## 导入模块
```
```js
import hiTraceMeter from '@ohos.hiTraceMeter';
```
......@@ -32,9 +32,8 @@ startTrace(name: string, taskId: number): void
**示例:**
```
```js
hiTraceMeter.startTrace("myTestFunc", 1);
hiTraceMeter.startTrace("myTestFunc", 1, 5); //从startTrace到finishTrace流程的耗时期望为5ms
```
......@@ -57,11 +56,11 @@ finishTrace的name和taskId必须与流程开始的[startTrace](#hitracemetersta
**示例:**
```
```js
hiTraceMeter.finishTrace("myTestFunc", 1);
```
```
```js
//追踪并行执行的同名任务
hiTraceMeter.startTrace("myTestFunc", 1);
//业务流程......
......@@ -72,7 +71,7 @@ hiTraceMeter.finishTrace("myTestFunc", 1);
hiTraceMeter.finishTrace("myTestFunc", 2);
```
```
```js
//追踪串行执行的同名任务
hiTraceMeter.startTrace("myTestFunc", 1);
//业务流程......
......@@ -100,7 +99,7 @@ traceByValue(name: string, count: number): void
| count | number | 是 | 变量的值 |
**示例:**
```
```js
let traceCount = 3;
hiTraceMeter.traceByValue("myTestCount", traceCount);
traceCount = 4;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册