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

!23752 hisysevent/hitracechain开发指导样例代码ArkTs语法规范整改

Merge pull request !23752 from honghecun/master
...@@ -30,6 +30,7 @@ hiTraceChain是基于云计算分布式跟踪调用链思想,在端侧业务 ...@@ -30,6 +30,7 @@ hiTraceChain是基于云计算分布式跟踪调用链思想,在端侧业务
```ts ```ts
import hiTraceChain from '@ohos.hiTraceChain'; import hiTraceChain from '@ohos.hiTraceChain';
import hiSysEvent from '@ohos.hiSysEvent'; import hiSysEvent from '@ohos.hiSysEvent';
import { BusinessError } from '@ohos.base';
@Entry @Entry
@Component @Component
...@@ -50,26 +51,28 @@ hiTraceChain是基于云计算分布式跟踪调用链思想,在端侧业务 ...@@ -50,26 +51,28 @@ hiTraceChain是基于云计算分布式跟踪调用链思想,在端侧业务
// 业务开始前,开启分布式跟踪。 // 业务开始前,开启分布式跟踪。
let traceId = hiTraceChain.begin("Write a new system event", hiTraceChain.HiTraceFlag.INCLUDE_ASYNC); let traceId = hiTraceChain.begin("Write a new system event", hiTraceChain.HiTraceFlag.INCLUDE_ASYNC);
// 业务开始:完成一次系统事件打点。 // 业务开始:完成一次系统事件打点。
hiSysEvent.write({ let customizedParams: Record<string, string | number> = {
'PID': 1,
'UID': 1,
'PACKAGE_NAME': "com.demo.hitracechain",
'PROCESS_NAME': "hitracechaindemo",
'MSG': "no msg."
}
let eventInfo: hiSysEvent.SysEventInfo = {
domain: "RELIABILITY", domain: "RELIABILITY",
name: "STACK", name: "STACK",
eventType: hiSysEvent.EventType.FAULT, eventType: hiSysEvent.EventType.FAULT,
params: { params: customizedParams
PID: 1,
UID: 1,
PACKAGE_NAME: "com.demo.hitracechain",
PROCESS_NAME: "hitracechaindemo",
MSG: "no msg."
} }
}).then((val) => { hiSysEvent.write(eventInfo).then((val: number) => {
console.info(`write result is ${val}`); console.info(`write result is ${val}`);
// 业务结束,关闭分布式跟踪。 // 业务结束,关闭分布式跟踪。
hiTraceChain.end(traceId); hiTraceChain.end(traceId);
}).catch((err) => { }).catch((err: BusinessError) => {
console.error(`error message is ${err.message}`); console.error(`error message is ${err.message}`);
}); });
} catch (err) { } catch (err) {
console.error(`error message is ${err.message}`); console.error(`error message is ${(err as BusinessError).message}`);
} }
}) })
} }
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
## 导入模块 ## 导入模块
```js ```ts
import hiSysEvent from '@ohos.hiSysEvent'; import hiSysEvent from '@ohos.hiSysEvent';
``` ```
...@@ -73,26 +73,29 @@ write(info: SysEventInfo, callback: AsyncCallback&lt;void&gt;): void ...@@ -73,26 +73,29 @@ write(info: SysEventInfo, callback: AsyncCallback&lt;void&gt;): void
**示例:** **示例:**
```js ```ts
import hiSysEvent from '@ohos.hiSysEvent'; import hiSysEvent from '@ohos.hiSysEvent';
import { BusinessError } from '@ohos.base';
try { try {
hiSysEvent.write({ let customizedParams: Record<string, string | number> = {
'PID': 487,
'UID': 103,
'PACKAGE_NAME': "com.ohos.hisysevent.test",
'PROCESS_NAME': "syseventservice",
'MSG': "no msg."
};
let eventInfo: hiSysEvent.SysEventInfo = {
domain: "RELIABILITY", domain: "RELIABILITY",
name: "STACK", name: "STACK",
eventType: hiSysEvent.EventType.FAULT, eventType: hiSysEvent.EventType.FAULT,
params: { params: customizedParams
PID: 487, };
UID: 103, hiSysEvent.write(eventInfo, (err: BusinessError, val: number) => {
PACKAGE_NAME: "com.ohos.hisysevent.test",
PROCESS_NAME: "syseventservice",
MSG: "no msg."
}
}, (err, val) => {
// do something here. // do something here.
}) });
} catch (error) { } catch (err) {
console.error(`error code: ${error.code}, error msg: ${error.message}`); console.error(`error code: ${(err as BusinessError).code}, error msg: ${(err as BusinessError).message}`);
} }
``` ```
...@@ -134,32 +137,35 @@ write(info: SysEventInfo): Promise&lt;void&gt; ...@@ -134,32 +137,35 @@ write(info: SysEventInfo): Promise&lt;void&gt;
**示例:** **示例:**
```js ```ts
import hiSysEvent from '@ohos.hiSysEvent'; import hiSysEvent from '@ohos.hiSysEvent';
import { BusinessError } from '@ohos.base';
try { try {
hiSysEvent.write({ let customizedParams: Record<string, string | number> = {
'PID': 487,
'UID': 103,
'PACKAGE_NAME': "com.ohos.hisysevent.test",
'PROCESS_NAME': "syseventservice",
'MSG': "no msg."
};
let eventInfo: hiSysEvent.SysEventInfo = {
domain: "RELIABILITY", domain: "RELIABILITY",
name: "STACK", name: "STACK",
eventType: hiSysEvent.EventType.FAULT, eventType: hiSysEvent.EventType.FAULT,
params: { params: customizedParams
PID: 487, };
UID: 103, hiSysEvent.write(eventInfo).then(
PACKAGE_NAME: "com.ohos.hisysevent.test", (val: number) => {
PROCESS_NAME: "syseventservice",
MSG: "no msg."
}
}).then(
(val) => {
// do something here. // do something here.
} }
).catch( ).catch(
(err) => { (err: BusinessError) => {
// do something here. console.error(`error code: ${err.code}, error msg: ${err.message}`);
} }
) )
} catch (error) { } catch (err) {
console.error(`error code: ${error.code}, error msg: ${error.message}`); console.error(`error code: ${(err as BusinessError).code}, error msg: ${(err as BusinessError).message}`);
} }
``` ```
...@@ -227,17 +233,19 @@ addWatcher(watcher: Watcher): void ...@@ -227,17 +233,19 @@ addWatcher(watcher: Watcher): void
**示例:** **示例:**
```js ```ts
import hiSysEvent from '@ohos.hiSysEvent'; import hiSysEvent from '@ohos.hiSysEvent';
import { BusinessError } from '@ohos.base';
let watcher = { let watchRules: hiSysEvent.WatchRule[] = [{
rules: [{
domain: "RELIABILITY", domain: "RELIABILITY",
name: "STACK", name: "STACK",
tag: "STABILITY", tag: "STABILITY",
ruleType: hiSysEvent.RuleType.WHOLE_WORD, ruleType: hiSysEvent.RuleType.WHOLE_WORD,
}], } as hiSysEvent.WatchRule];
onEvent: (info) => { let watcher: hiSysEvent.Watcher = {
rules: watchRules,
onEvent: (info: hiSysEvent.SysEventInfo) => {
// do something here. // do something here.
}, },
onServiceDied: () => { onServiceDied: () => {
...@@ -246,8 +254,8 @@ let watcher = { ...@@ -246,8 +254,8 @@ let watcher = {
} }
try { try {
hiSysEvent.addWatcher(watcher) hiSysEvent.addWatcher(watcher)
} catch (error) { } catch (err) {
console.error(`error code: ${error.code}, error msg: ${error.message}`); console.error(`error code: ${(err as BusinessError).code}, error msg: ${(err as BusinessError).message}`);
} }
``` ```
...@@ -277,17 +285,19 @@ removeWatcher(watcher: Watcher): void ...@@ -277,17 +285,19 @@ removeWatcher(watcher: Watcher): void
**示例:** **示例:**
```js ```ts
import hiSysEvent from '@ohos.hiSysEvent'; import hiSysEvent from '@ohos.hiSysEvent';
import { BusinessError } from '@ohos.base';
let watcher = { let watchRules: hiSysEvent.WatchRule[] = [{
rules: [{
domain: "RELIABILITY", domain: "RELIABILITY",
name: "STACK", name: "STACK",
tag: "STABILITY", tag: "STABILITY",
ruleType: hiSysEvent.RuleType.WHOLE_WORD, ruleType: hiSysEvent.RuleType.WHOLE_WORD,
}], } as hiSysEvent.WatchRule ]
onEvent: (info) => { let watcher: hiSysEvent.Watcher = {
rules: watchRules,
onEvent: (info: hiSysEvent.SysEventInfo) => {
// do something here. // do something here.
}, },
onServiceDied: () => { onServiceDied: () => {
...@@ -297,8 +307,8 @@ let watcher = { ...@@ -297,8 +307,8 @@ let watcher = {
try { try {
hiSysEvent.addWatcher(watcher) hiSysEvent.addWatcher(watcher)
hiSysEvent.removeWatcher(watcher) hiSysEvent.removeWatcher(watcher)
} catch (error) { } catch (err) {
console.error(`error code: ${error.code}, error msg: ${error.message}`); console.error(`error code: ${(err as BusinessError).code}, error msg: ${(err as BusinessError).message}`);
} }
``` ```
...@@ -370,41 +380,48 @@ query(queryArg: QueryArg, rules: QueryRule[], querier: Querier): void ...@@ -370,41 +380,48 @@ query(queryArg: QueryArg, rules: QueryRule[], querier: Querier): void
**示例:** **示例:**
```js ```ts
import hiSysEvent from '@ohos.hiSysEvent'; import hiSysEvent from '@ohos.hiSysEvent';
import { BusinessError } from '@ohos.base';
try { try {
hiSysEvent.write({ let customizedParams: Record<string, string | number> = {
'PID': 487,
'UID': 103,
'PACKAGE_NAME': "com.ohos.hisysevent.test",
'PROCESS_NAME': "syseventservice",
'MSG': "no msg."
};
let eventInfo: hiSysEvent.SysEventInfo = {
domain: "RELIABILITY", domain: "RELIABILITY",
name: "STACK", name: "STACK",
eventType: hiSysEvent.EventType.FAULT, eventType: hiSysEvent.EventType.FAULT,
params: { params: customizedParams
PID: 487, };
UID: 103, hiSysEvent.write(eventInfo, (err: BusinessError, val: number) => {
PACKAGE_NAME: "com.ohos.hisysevent.test",
PROCESS_NAME: "syseventservice",
MSG: "no msg."
}
}, (err, val) => {
// do something here. // do something here.
}) })
hiSysEvent.query({
let queryArg: hiSysEvent.QueryArg = {
beginTime: -1, beginTime: -1,
endTime: -1, endTime: -1,
maxEvents: 5, maxEvents: 5,
}, [{ };
let queryRules: hiSysEvent.QueryRule[] = [{
domain: "RELIABILITY", domain: "RELIABILITY",
names: ["STACK"], names: ["STACK"],
}], { } as hiSysEvent.QueryRule]
onQuery: function (infos) { let querier: hiSysEvent.Querier = {
onQuery: (infos: hiSysEvent.SysEventInfo[]) => {
// do something here. // do something here.
}, },
onComplete: function(reason, total) { onComplete: (reason: number, total: number) => {
// do something here. // do something here.
} }
}) }
} catch (error) { hiSysEvent.query(queryArg, queryRules, querier)
console.error(`error code: ${error.code}, error msg: ${error.message}`); } catch (err) {
console.error(`error code: ${(err as BusinessError).code}, error msg: ${(err as BusinessError).message}`);
} }
``` ```
...@@ -443,50 +460,55 @@ exportSysEvents(queryArg: QueryArg, rules: QueryRule[]): number ...@@ -443,50 +460,55 @@ exportSysEvents(queryArg: QueryArg, rules: QueryRule[]): number
**示例:** **示例:**
``` ```ts
import hiSysEvent from '@ohos.hiSysEvent'; import hiSysEvent from '@ohos.hiSysEvent';
import fs from '@ohos.file.fs'; import fs from '@ohos.file.fs';
import { BusinessError } from '@ohos.base';
try { try {
hiSysEvent.write({ let customizedParams: Record<string, string | number> = {
'PID': 487,
'UID': 103,
'PACKAGE_NAME': "com.ohos.hisysevent.test",
'PROCESS_NAME': "syseventservice",
'MSG': "no msg."
};
let eventInfo: hiSysEvent.SysEventInfo = {
domain: "RELIABILITY", domain: "RELIABILITY",
name: "STACK", name: "STACK",
eventType: hiSysEvent.EventType.FAULT, eventType: hiSysEvent.EventType.FAULT,
params: { params: customizedParams
PID: 487, };
UID: 103, hiSysEvent.write(eventInfo, (err: BusinessError, val: number) => {
PACKAGE_NAME: "com.ohos.hisysevent.test",
PROCESS_NAME: "syseventservice",
MSG: "no msg."
}
}, (err, val) => {
// do something here. // do something here.
}) })
let time = hiSysEvent.exportSysEvents({ let queryArg: hiSysEvent.QueryArg = {
beginTime: -1, beginTime: -1,
endTime: -1, endTime: -1,
maxEvents: 1, maxEvents: 1,
}, [{ }
let queryRules: hiSysEvent.QueryRule[] = [{
domain: "RELIABILITY", domain: "RELIABILITY",
names: ["STACK"], names: ["STACK"],
}]) } as hiSysEvent.QueryRule]
let time = hiSysEvent.exportSysEvents(queryArg, queryRules)
console.log(`receive export task time is : ${time}`); console.log(`receive export task time is : ${time}`);
// 延迟读取本次导出的事件 // 延迟读取本次导出的事件
setTimeout(function() { setTimeout(() => {
let eventDir = '/data/storage/el2/base/cache/hiview/event'; let eventDir = '/data/storage/el2/base/cache/hiview/event';
let filenames = fs.listFileSync(eventDir); let filenames = fs.listFileSync(eventDir);
for (let i = 0; i < filenames.length; i++) { for (let i = 0; i < filenames.length; i++) {
if (filenames[i].indexOf(time.toString()) != -1) { if (filenames[i].indexOf(time.toString()) != -1) {
let res = fs.readTextSync(eventDir + '/' + filenames[i]); let res = fs.readTextSync(eventDir + '/' + filenames[i]);
let events = JSON.parse('[' + res.slice(0, res.length - 1) + ']'); let events: string = JSON.parse('[' + res.slice(0, res.length - 1) + ']');
console.log("read file end, events is :" + JSON.stringify(events)); console.log("read file end, events is :" + JSON.stringify(events));
} }
} }
}, 10000) }, 10000)
} catch (error) { } catch catch (err) {
console.error(`error code: ${error.code}, error msg: ${error.message}`); console.error(`error code: ${(err as BusinessError).code}, error msg: ${(err as BusinessError).message}`);
} }
``` ```
...@@ -523,45 +545,51 @@ subscribe(rules: QueryRule[]): number ...@@ -523,45 +545,51 @@ subscribe(rules: QueryRule[]): number
**示例:** **示例:**
``` ```ts
import hiSysEvent from '@ohos.hiSysEvent'; import hiSysEvent from '@ohos.hiSysEvent';
import fs from '@ohos.file.fs'; import fs from '@ohos.file.fs';
import { BusinessError } from '@ohos.base';
try { try {
hiSysEvent.subscribe([{ let rules: hiSysEvent.QueryRule[] = [{
domain: "RELIABILITY", domain: "RELIABILITY",
names: ["STACK"], names: ["STACK"],
},{ } as hiSysEvent.QueryRule,
{
domain: "BUNDLE_MANAGER", domain: "BUNDLE_MANAGER",
names: ["BUNDLE_UNINSTALL"], names: ["BUNDLE_UNINSTALL"],
}]) } as hiSysEvent.QueryRule];
hiSysEvent.write({ hiSysEvent.subscribe(rules)
let customizedParams: Record<string, string | number> = {
'PID': 487,
'UID': 103,
'PACKAGE_NAME': "com.ohos.hisysevent.test",
'PROCESS_NAME': "syseventservice",
'MSG': "no msg."
};
let eventInfo: hiSysEvent.SysEventInfo = {
domain: "RELIABILITY", domain: "RELIABILITY",
name: "STACK", name: "STACK",
eventType: hiSysEvent.EventType.FAULT, eventType: hiSysEvent.EventType.FAULT,
params: { params: customizedParams
PID: 487, };
UID: 103, hiSysEvent.write(eventInfo, (err: BusinessError, val: number) => {
PACKAGE_NAME: "com.ohos.hisysevent.test",
PROCESS_NAME: "syseventservice",
MSG: "no msg."
}
}, (err, val) => {
// do something here. // do something here.
}) })
// 延迟读取订阅的事件 // 延迟读取订阅的事件
setTimeout(function() { setTimeout(() => {
let eventDir = '/data/storage/el2/base/cache/hiview/event'; let eventDir = '/data/storage/el2/base/cache/hiview/event';
let filenames = fs.listFileSync(eventDir); let filenames = fs.listFileSync(eventDir);
for (let i = 0; i < filenames.length; i++) { for (let i = 0; i < filenames.length; i++) {
let res = fs.readTextSync(eventDir + '/' + filenames[i]); let res = fs.readTextSync(eventDir + '/' + filenames[i]);
let events = JSON.parse('[' + res.slice(0, res.length - 1) + ']'); let events: string = JSON.parse('[' + res.slice(0, res.length - 1) + ']');
console.log("read file end, events is :" + JSON.stringify(events)); console.log("read file end, events is :" + JSON.stringify(events));
} }
}, 10000) }, 10000)
} catch (error) { } catch catch (err) {
console.error(`error code: ${error.code}, error msg: ${error.message}`); console.error(`error code: ${(err as BusinessError).code}, error msg: ${(err as BusinessError).message}`);
} }
``` ```
...@@ -585,20 +613,23 @@ unsubscribe(): void ...@@ -585,20 +613,23 @@ unsubscribe(): void
**示例:** **示例:**
``` ```ts
import hiSysEvent from '@ohos.hiSysEvent'; import hiSysEvent from '@ohos.hiSysEvent';
import { BusinessError } from '@ohos.base';
try { try {
hiSysEvent.subscribe([{ let rules: hiSysEvent.QueryRule[] = [{
domain: "RELIABILITY", domain: "RELIABILITY",
names: ["STACK"], names: ["STACK"],
},{ } as hiSysEvent.QueryRule,
{
domain: "BUNDLE_MANAGER", domain: "BUNDLE_MANAGER",
names: ["BUNDLE_UNINSTALL","BUNDLE_INSTALL"], names: ["BUNDLE_UNINSTALL"],
}]) } as hiSysEvent.QueryRule];
hiSysEvent.subscribe(rules)
hiSysEvent.unsubscribe(); hiSysEvent.unsubscribe();
} catch (error) { } catch (err) {
console.error(`error code: ${error.code}, error msg: ${error.message}`); console.error(`error code: ${(err as BusinessError).code}, error msg: ${(err as BusinessError).message}`);
} }
``` ```
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
## 导入模块 ## 导入模块
```js ```ts
import hiTraceChain from '@ohos.hiTraceChain'; import hiTraceChain from '@ohos.hiTraceChain';
``` ```
...@@ -93,7 +93,7 @@ begin(name: string, flags?: number): HiTraceId ...@@ -93,7 +93,7 @@ begin(name: string, flags?: number): HiTraceId
**示例:** **示例:**
```js ```ts
let asyncTraceId = hiTraceChain.begin("business", hiTraceChain.HiTraceFlag.INCLUDE_ASYNC | hiTraceChain.HiTraceFlag.DONOT_CREATE_SPAN); let asyncTraceId = hiTraceChain.begin("business", hiTraceChain.HiTraceFlag.INCLUDE_ASYNC | hiTraceChain.HiTraceFlag.DONOT_CREATE_SPAN);
``` ```
...@@ -113,7 +113,7 @@ end(id: HiTraceId): void ...@@ -113,7 +113,7 @@ end(id: HiTraceId): void
**示例:** **示例:**
```js ```ts
let asyncTraceId = hiTraceChain.begin("business", hiTraceChain.HiTraceFlag.DEFAULT); let asyncTraceId = hiTraceChain.begin("business", hiTraceChain.HiTraceFlag.DEFAULT);
// 若干业务逻辑完成后,结束跟踪。 // 若干业务逻辑完成后,结束跟踪。
hiTraceChain.end(asyncTraceId); hiTraceChain.end(asyncTraceId);
...@@ -135,7 +135,7 @@ getId(): HiTraceId ...@@ -135,7 +135,7 @@ getId(): HiTraceId
**示例:** **示例:**
```js ```ts
let traceId = hiTraceChain.begin("business", hiTraceChain.HiTraceFlag.DEFAULT); let traceId = hiTraceChain.begin("business", hiTraceChain.HiTraceFlag.DEFAULT);
// 若干业务逻辑完成后,获取当前HiTraceId。 // 若干业务逻辑完成后,获取当前HiTraceId。
let curTraceId = hiTraceChain.getId(); let curTraceId = hiTraceChain.getId();
...@@ -157,10 +157,11 @@ setId(id: HiTraceId): void ...@@ -157,10 +157,11 @@ setId(id: HiTraceId): void
**示例:** **示例:**
```js ```ts
let asyncTraceId; let asyncTraceId: hiTraceChain.HiTraceId;
hiTraceChain.end(asyncTraceId);
let traceId = hiTraceChain.begin("business", hiTraceChain.HiTraceFlag.DEFAULT); let traceId = hiTraceChain.begin("business", hiTraceChain.HiTraceFlag.DEFAULT);
// 若干业务逻辑完成后,设置当前HiTraceId。 // 若干业务逻辑完成后,将之前的traceId设置为当前traceId。
hiTraceChain.setId(asyncTraceId); hiTraceChain.setId(asyncTraceId);
``` ```
...@@ -174,7 +175,7 @@ clearId(): void ...@@ -174,7 +175,7 @@ clearId(): void
**示例:** **示例:**
```js ```ts
let traceId = hiTraceChain.begin("business", hiTraceChain.HiTraceFlag.DEFAULT); let traceId = hiTraceChain.begin("business", hiTraceChain.HiTraceFlag.DEFAULT);
// 若干业务逻辑完成后,清除当前HiTraceId。 // 若干业务逻辑完成后,清除当前HiTraceId。
hiTraceChain.clearId(); hiTraceChain.clearId();
...@@ -196,7 +197,7 @@ createSpan(): HiTraceId ...@@ -196,7 +197,7 @@ createSpan(): HiTraceId
**示例:** **示例:**
```js ```ts
let traceId = hiTraceChain.begin("business", hiTraceChain.HiTraceFlag.DEFAULT); let traceId = hiTraceChain.begin("business", hiTraceChain.HiTraceFlag.DEFAULT);
// 若干业务逻辑完成后,创建跟踪分支。 // 若干业务逻辑完成后,创建跟踪分支。
let spanTraceId = hiTraceChain.createSpan(); let spanTraceId = hiTraceChain.createSpan();
...@@ -221,7 +222,7 @@ tracepoint(mode: HiTraceCommunicationMode, type: HiTraceTracepointType, id: HiTr ...@@ -221,7 +222,7 @@ tracepoint(mode: HiTraceCommunicationMode, type: HiTraceTracepointType, id: HiTr
**示例:** **示例:**
```js ```ts
let asyncTraceId = hiTraceChain.begin("business", hiTraceChain.HiTraceFlag.INCLUDE_ASYNC | hiTraceChain.HiTraceFlag.DONOT_CREATE_SPAN); 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"); hiTraceChain.tracepoint(hiTraceChain.HiTraceCommunicationMode.THREAD, hiTraceChain.HiTraceTracepointType.SS, asyncTraceId, "Just a example");
...@@ -249,7 +250,7 @@ isValid(id: HiTraceId): boolean ...@@ -249,7 +250,7 @@ isValid(id: HiTraceId): boolean
**示例:** **示例:**
```js ```ts
let traceId = hiTraceChain.begin("business", hiTraceChain.HiTraceFlag.DEFAULT); let traceId = hiTraceChain.begin("business", hiTraceChain.HiTraceFlag.DEFAULT);
let traceIdIsvalid = hiTraceChain.isValid(traceId); let traceIdIsvalid = hiTraceChain.isValid(traceId);
``` ```
...@@ -277,7 +278,7 @@ isFlagEnabled(id: HiTraceId, flag: HiTraceFlag): boolean ...@@ -277,7 +278,7 @@ isFlagEnabled(id: HiTraceId, flag: HiTraceFlag): boolean
**示例:** **示例:**
```js ```ts
let asyncTraceId = hiTraceChain.begin("business", hiTraceChain.HiTraceFlag.INCLUDE_ASYNC); let asyncTraceId = hiTraceChain.begin("business", hiTraceChain.HiTraceFlag.INCLUDE_ASYNC);
// enabledDoNotCreateSpanFlag为true // enabledDoNotCreateSpanFlag为true
let enabledDoNotCreateSpanFlag = hiTraceChain.isFlagEnabled(asyncTraceId, hiTraceChain.HiTraceFlag.INCLUDE_ASYNC); let enabledDoNotCreateSpanFlag = hiTraceChain.isFlagEnabled(asyncTraceId, hiTraceChain.HiTraceFlag.INCLUDE_ASYNC);
...@@ -300,7 +301,7 @@ enableFlag(id: HiTraceId, flag: HiTraceFlag): void ...@@ -300,7 +301,7 @@ enableFlag(id: HiTraceId, flag: HiTraceFlag): void
**示例:** **示例:**
```js ```ts
let asyncTraceId = hiTraceChain.begin("business", hiTraceChain.HiTraceFlag.INCLUDE_ASYNC); let asyncTraceId = hiTraceChain.begin("business", hiTraceChain.HiTraceFlag.INCLUDE_ASYNC);
hiTraceChain.enableFlag(asyncTraceId, hiTraceChain.HiTraceFlag.DONOT_CREATE_SPAN); hiTraceChain.enableFlag(asyncTraceId, hiTraceChain.HiTraceFlag.DONOT_CREATE_SPAN);
// enabledDoNotCreateSpanFlag为true // enabledDoNotCreateSpanFlag为true
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册