Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
f8d8ffb1
D
Docs
项目概览
OpenHarmony
/
Docs
1 年多 前同步成功
通知
159
Star
292
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
f8d8ffb1
编写于
9月 05, 2023
作者:
O
openharmony_ci
提交者:
Gitee
9月 05, 2023
浏览文件
操作
浏览文件
下载
差异文件
!23916 【0815monthly分支挑单】hisysevent/hitracechain开发指导样例代码ArkTs语法规范整改
Merge pull request !23916 from honghecun/cherry-pick-1693899037
上级
bbc65b5d
cdf5d948
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
255 addition
and
220 deletion
+255
-220
zh-cn/application-dev/dfx/hitracechain-guidelines.md
zh-cn/application-dev/dfx/hitracechain-guidelines.md
+14
-11
zh-cn/application-dev/reference/apis/js-apis-hisysevent.md
zh-cn/application-dev/reference/apis/js-apis-hisysevent.md
+227
-196
zh-cn/application-dev/reference/apis/js-apis-hitracechain.md
zh-cn/application-dev/reference/apis/js-apis-hitracechain.md
+14
-13
未找到文件。
zh-cn/application-dev/dfx/hitracechain-guidelines.md
浏览文件 @
f8d8ffb1
...
...
@@ -30,6 +30,7 @@ hiTraceChain是基于云计算分布式跟踪调用链思想,在端侧业务
```ts
import hiTraceChain from '@ohos.hiTraceChain';
import hiSysEvent from '@ohos.hiSysEvent';
import { BusinessError } from '@ohos.base';
@Entry
@Component
...
...
@@ -50,26 +51,28 @@ hiTraceChain是基于云计算分布式跟踪调用链思想,在端侧业务
// 业务开始前,开启分布式跟踪。
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",
name: "STACK",
eventType: hiSysEvent.EventType.FAULT,
params: {
PID: 1,
UID: 1,
PACKAGE_NAME: "com.demo.hitracechain",
PROCESS_NAME: "hitracechaindemo",
MSG: "no msg."
}
}).then((val) => {
params: customizedParams
}
hiSysEvent.write(eventInfo).then((val: number) => {
console.info(`write result is ${val}`);
// 业务结束,关闭分布式跟踪。
hiTraceChain.end(traceId);
}).catch((err) => {
}).catch((err
: BusinessError
) => {
console.error(`error message is ${err.message}`);
});
} catch (err) {
console.error(`error message is ${
err
.message}`);
console.error(`error message is ${
(err as BusinessError)
.message}`);
}
})
}
...
...
zh-cn/application-dev/reference/apis/js-apis-hisysevent.md
浏览文件 @
f8d8ffb1
...
...
@@ -10,7 +10,7 @@
## 导入模块
```
j
s
```
t
s
import
hiSysEvent
from
'
@ohos.hiSysEvent
'
;
```
...
...
@@ -73,26 +73,29 @@ write(info: SysEventInfo, callback: AsyncCallback<void>): void
**示例:**
```
j
s
```
t
s
import
hiSysEvent
from
'
@ohos.hiSysEvent
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
try
{
hiSysEvent
.
write
({
domain
:
"
RELIABILITY
"
,
name
:
"
STACK
"
,
eventType
:
hiSysEvent
.
EventType
.
FAULT
,
params
:
{
PID
:
487
,
UID
:
103
,
PACKAGE_NAME
:
"
com.ohos.hisysevent.test
"
,
PROCESS_NAME
:
"
syseventservice
"
,
MSG
:
"
no msg.
"
}
},
(
err
,
val
)
=>
{
// do something here.
})
}
catch
(
error
)
{
console
.
error
(
`error code:
${
error
.
code
}
, error msg:
${
error
.
message
}
`
);
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
"
,
name
:
"
STACK
"
,
eventType
:
hiSysEvent
.
EventType
.
FAULT
,
params
:
customizedParams
};
hiSysEvent
.
write
(
eventInfo
,
(
err
:
BusinessError
,
val
:
number
)
=>
{
// do something here.
});
}
catch
(
err
)
{
console
.
error
(
`error code:
${(
err
as
BusinessError
).
code
}
, error msg:
${(
err
as
BusinessError
).
message
}
`
);
}
```
...
...
@@ -134,32 +137,35 @@ write(info: SysEventInfo): Promise<void>
**示例:**
```
j
s
```
t
s
import
hiSysEvent
from
'
@ohos.hiSysEvent
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
try
{
hiSysEvent
.
write
({
domain
:
"
RELIABILITY
"
,
name
:
"
STACK
"
,
eventType
:
hiSysEvent
.
EventType
.
FAULT
,
params
:
{
PID
:
487
,
UID
:
103
,
PACKAGE_NAME
:
"
com.ohos.hisysevent.test
"
,
PROCESS_NAME
:
"
syseventservice
"
,
MSG
:
"
no msg.
"
}
}).
then
(
(
val
)
=>
{
// do something here.
}
).
catch
(
(
err
)
=>
{
// do something here.
}
)
}
catch
(
error
)
{
console
.
error
(
`error code:
${
error
.
code
}
, error msg:
${
error
.
message
}
`
);
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
"
,
name
:
"
STACK
"
,
eventType
:
hiSysEvent
.
EventType
.
FAULT
,
params
:
customizedParams
};
hiSysEvent
.
write
(
eventInfo
).
then
(
(
val
:
number
)
=>
{
// do something here.
}
).
catch
(
(
err
:
BusinessError
)
=>
{
console
.
error
(
`error code:
${
err
.
code
}
, error msg:
${
err
.
message
}
`
);
}
)
}
catch
(
err
)
{
console
.
error
(
`error code:
${(
err
as
BusinessError
).
code
}
, error msg:
${(
err
as
BusinessError
).
message
}
`
);
}
```
...
...
@@ -227,27 +233,29 @@ addWatcher(watcher: Watcher): void
**示例:**
```
j
s
```
t
s
import
hiSysEvent
from
'
@ohos.hiSysEvent
'
;
let
watcher
=
{
rules
:
[{
domain
:
"
RELIABILITY
"
,
name
:
"
STACK
"
,
tag
:
"
STABILITY
"
,
ruleType
:
hiSysEvent
.
RuleType
.
WHOLE_WORD
,
}],
onEvent
:
(
info
)
=>
{
// do something here.
},
onServiceDied
:
()
=>
{
// do something here.
}
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
watchRules
:
hiSysEvent
.
WatchRule
[]
=
[{
domain
:
"
RELIABILITY
"
,
name
:
"
STACK
"
,
tag
:
"
STABILITY
"
,
ruleType
:
hiSysEvent
.
RuleType
.
WHOLE_WORD
,
}
as
hiSysEvent
.
WatchRule
];
let
watcher
:
hiSysEvent
.
Watcher
=
{
rules
:
watchRules
,
onEvent
:
(
info
:
hiSysEvent
.
SysEventInfo
)
=>
{
// do something here.
},
onServiceDied
:
()
=>
{
// do something here.
}
}
try
{
hiSysEvent
.
addWatcher
(
watcher
)
}
catch
(
err
or
)
{
console
.
error
(
`error code:
${
error
.
code
}
, error msg:
${
error
.
message
}
`
);
hiSysEvent
.
addWatcher
(
watcher
)
}
catch
(
err
)
{
console
.
error
(
`error code:
${(
err
as
BusinessError
).
code
}
, error msg:
${(
err
as
BusinessError
)
.
message
}
`
);
}
```
...
...
@@ -277,28 +285,30 @@ removeWatcher(watcher: Watcher): void
**示例:**
```
j
s
```
t
s
import
hiSysEvent
from
'
@ohos.hiSysEvent
'
;
let
watcher
=
{
rules
:
[{
domain
:
"
RELIABILITY
"
,
name
:
"
STACK
"
,
tag
:
"
STABILITY
"
,
ruleType
:
hiSysEvent
.
RuleType
.
WHOLE_WORD
,
}],
onEvent
:
(
info
)
=>
{
// do something here.
},
onServiceDied
:
()
=>
{
// do something here.
}
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
watchRules
:
hiSysEvent
.
WatchRule
[]
=
[{
domain
:
"
RELIABILITY
"
,
name
:
"
STACK
"
,
tag
:
"
STABILITY
"
,
ruleType
:
hiSysEvent
.
RuleType
.
WHOLE_WORD
,
}
as
hiSysEvent
.
WatchRule
]
let
watcher
:
hiSysEvent
.
Watcher
=
{
rules
:
watchRules
,
onEvent
:
(
info
:
hiSysEvent
.
SysEventInfo
)
=>
{
// do something here.
},
onServiceDied
:
()
=>
{
// do something here.
}
}
try
{
hiSysEvent
.
addWatcher
(
watcher
)
hiSysEvent
.
removeWatcher
(
watcher
)
}
catch
(
err
or
)
{
console
.
error
(
`error code:
${
error
.
code
}
, error msg:
${
error
.
message
}
`
);
hiSysEvent
.
addWatcher
(
watcher
)
hiSysEvent
.
removeWatcher
(
watcher
)
}
catch
(
err
)
{
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
**示例:**
```
j
s
```
t
s
import
hiSysEvent
from
'
@ohos.hiSysEvent
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
try
{
hiSysEvent
.
write
({
domain
:
"
RELIABILITY
"
,
name
:
"
STACK
"
,
eventType
:
hiSysEvent
.
EventType
.
FAULT
,
params
:
{
PID
:
487
,
UID
:
103
,
PACKAGE_NAME
:
"
com.ohos.hisysevent.test
"
,
PROCESS_NAME
:
"
syseventservice
"
,
MSG
:
"
no msg.
"
}
},
(
err
,
val
)
=>
{
// do something here.
})
hiSysEvent
.
query
({
beginTime
:
-
1
,
endTime
:
-
1
,
maxEvents
:
5
,
},
[{
domain
:
"
RELIABILITY
"
,
names
:
[
"
STACK
"
],
}],
{
onQuery
:
function
(
infos
)
{
// do something here.
},
onComplete
:
function
(
reason
,
total
)
{
// do something here.
}
})
}
catch
(
error
)
{
console
.
error
(
`error code:
${
error
.
code
}
, error msg:
${
error
.
message
}
`
);
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
"
,
name
:
"
STACK
"
,
eventType
:
hiSysEvent
.
EventType
.
FAULT
,
params
:
customizedParams
};
hiSysEvent
.
write
(
eventInfo
,
(
err
:
BusinessError
,
val
:
number
)
=>
{
// do something here.
})
let
queryArg
:
hiSysEvent
.
QueryArg
=
{
beginTime
:
-
1
,
endTime
:
-
1
,
maxEvents
:
5
,
};
let
queryRules
:
hiSysEvent
.
QueryRule
[]
=
[{
domain
:
"
RELIABILITY
"
,
names
:
[
"
STACK
"
],
}
as
hiSysEvent
.
QueryRule
]
let
querier
:
hiSysEvent
.
Querier
=
{
onQuery
:
(
infos
:
hiSysEvent
.
SysEventInfo
[])
=>
{
// do something here.
},
onComplete
:
(
reason
:
number
,
total
:
number
)
=>
{
// do something here.
}
}
hiSysEvent
.
query
(
queryArg
,
queryRules
,
querier
)
}
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
**示例:**
```
```
ts
import
hiSysEvent
from
'
@ohos.hiSysEvent
'
;
import
fs
from
'
@ohos.file.fs
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
try
{
hiSysEvent.write({
domain: "RELIABILITY",
name: "STACK",
eventType: hiSysEvent.EventType.FAULT,
params: {
PID: 487,
UID: 103,
PACKAGE_NAME: "com.ohos.hisysevent.test",
PROCESS_NAME: "syseventservice",
MSG: "no msg."
}
}, (err, val) => {
// do something here.
})
let time = hiSysEvent.exportSysEvents({
beginTime: -1,
endTime: -1,
maxEvents: 1,
}, [{
domain: "RELIABILITY",
names: ["STACK"],
}])
console.log(`receive export task time is : ${time}`);
// 延迟读取本次导出的事件
setTimeout(function() {
let eventDir = '/data/storage/el2/base/cache/hiview/event';
let filenames = fs.listFileSync(eventDir);
for (let i = 0; i < filenames.length; i++) {
if (filenames[i].indexOf(time.toString()) != -1) {
let res = fs.readTextSync(eventDir + '/' + filenames[i]);
let events = JSON.parse('[' + res.slice(0, res.length - 1) + ']');
console.log("read file end, events is :" + JSON.stringify(events));
}
}
}, 10000)
} catch (error) {
console.error(`error code: ${error.code}, error msg: ${error.message}`);
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
"
,
name
:
"
STACK
"
,
eventType
:
hiSysEvent
.
EventType
.
FAULT
,
params
:
customizedParams
};
hiSysEvent
.
write
(
eventInfo
,
(
err
:
BusinessError
,
val
:
number
)
=>
{
// do something here.
})
let
queryArg
:
hiSysEvent
.
QueryArg
=
{
beginTime
:
-
1
,
endTime
:
-
1
,
maxEvents
:
1
,
}
let
queryRules
:
hiSysEvent
.
QueryRule
[]
=
[{
domain
:
"
RELIABILITY
"
,
names
:
[
"
STACK
"
],
}
as
hiSysEvent
.
QueryRule
]
let
time
=
hiSysEvent
.
exportSysEvents
(
queryArg
,
queryRules
)
console
.
log
(
`receive export task time is :
${
time
}
`
);
// 延迟读取本次导出的事件
setTimeout
(()
=>
{
let
eventDir
=
'
/data/storage/el2/base/cache/hiview/event
'
;
let
filenames
=
fs
.
listFileSync
(
eventDir
);
for
(
let
i
=
0
;
i
<
filenames
.
length
;
i
++
)
{
if
(
filenames
[
i
].
indexOf
(
time
.
toString
())
!=
-
1
)
{
let
res
=
fs
.
readTextSync
(
eventDir
+
'
/
'
+
filenames
[
i
]);
let
events
:
string
=
JSON
.
parse
(
'
[
'
+
res
.
slice
(
0
,
res
.
length
-
1
)
+
'
]
'
);
console
.
log
(
"
read file end, events is :
"
+
JSON
.
stringify
(
events
));
}
}
},
10000
)
}
catch
catch
(
err
)
{
console
.
error
(
`error code:
${(
err
as
BusinessError
).
code
}
, error msg:
${(
err
as
BusinessError
).
message
}
`
);
}
```
...
...
@@ -523,45 +545,51 @@ subscribe(rules: QueryRule[]): number
**示例:**
```
```
ts
import
hiSysEvent
from
'
@ohos.hiSysEvent
'
;
import
fs
from
'
@ohos.file.fs
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
try
{
hiSysEvent.subscribe([{
domain: "RELIABILITY",
names: ["STACK"],
},{
domain: "BUNDLE_MANAGER",
names: ["BUNDLE_UNINSTALL"],
}])
hiSysEvent.write({
domain: "RELIABILITY",
name: "STACK",
eventType: hiSysEvent.EventType.FAULT,
params: {
PID: 487,
UID: 103,
PACKAGE_NAME: "com.ohos.hisysevent.test",
PROCESS_NAME: "syseventservice",
MSG: "no msg."
}
}, (err, val) => {
// do something here.
})
// 延迟读取订阅的事件
setTimeout(function() {
let eventDir = '/data/storage/el2/base/cache/hiview/event';
let filenames = fs.listFileSync(eventDir);
for (let i = 0; i < filenames.length; i++) {
let res = fs.readTextSync(eventDir + '/' + filenames[i]);
let events = JSON.parse('[' + res.slice(0, res.length - 1) + ']');
console.log("read file end, events is :" + JSON.stringify(events));
}
}, 10000)
} catch (error) {
console.error(`error code: ${error.code}, error msg: ${error.message}`);
let
rules
:
hiSysEvent
.
QueryRule
[]
=
[{
domain
:
"
RELIABILITY
"
,
names
:
[
"
STACK
"
],
}
as
hiSysEvent
.
QueryRule
,
{
domain
:
"
BUNDLE_MANAGER
"
,
names
:
[
"
BUNDLE_UNINSTALL
"
],
}
as
hiSysEvent
.
QueryRule
];
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
"
,
name
:
"
STACK
"
,
eventType
:
hiSysEvent
.
EventType
.
FAULT
,
params
:
customizedParams
};
hiSysEvent
.
write
(
eventInfo
,
(
err
:
BusinessError
,
val
:
number
)
=>
{
// do something here.
})
// 延迟读取订阅的事件
setTimeout
(()
=>
{
let
eventDir
=
'
/data/storage/el2/base/cache/hiview/event
'
;
let
filenames
=
fs
.
listFileSync
(
eventDir
);
for
(
let
i
=
0
;
i
<
filenames
.
length
;
i
++
)
{
let
res
=
fs
.
readTextSync
(
eventDir
+
'
/
'
+
filenames
[
i
]);
let
events
:
string
=
JSON
.
parse
(
'
[
'
+
res
.
slice
(
0
,
res
.
length
-
1
)
+
'
]
'
);
console
.
log
(
"
read file end, events is :
"
+
JSON
.
stringify
(
events
));
}
},
10000
)
}
catch
catch
(
err
)
{
console
.
error
(
`error code:
${(
err
as
BusinessError
).
code
}
, error msg:
${(
err
as
BusinessError
).
message
}
`
);
}
```
...
...
@@ -585,20 +613,23 @@ unsubscribe(): void
**示例:**
```
```
ts
import
hiSysEvent
from
'
@ohos.hiSysEvent
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
try
{
hiSysEvent.subscribe([{
domain: "RELIABILITY",
names: ["STACK"],
},{
domain: "BUNDLE_MANAGER",
names: ["BUNDLE_UNINSTALL","BUNDLE_INSTALL"],
}])
hiSysEvent.unsubscribe();
} catch (error) {
console.error(`error code: ${error.code}, error msg: ${error.message}`);
let
rules
:
hiSysEvent
.
QueryRule
[]
=
[{
domain
:
"
RELIABILITY
"
,
names
:
[
"
STACK
"
],
}
as
hiSysEvent
.
QueryRule
,
{
domain
:
"
BUNDLE_MANAGER
"
,
names
:
[
"
BUNDLE_UNINSTALL
"
],
}
as
hiSysEvent
.
QueryRule
];
hiSysEvent
.
subscribe
(
rules
)
hiSysEvent
.
unsubscribe
();
}
catch
(
err
)
{
console
.
error
(
`error code:
${(
err
as
BusinessError
).
code
}
, error msg:
${(
err
as
BusinessError
).
message
}
`
);
}
```
zh-cn/application-dev/reference/apis/js-apis-hitracechain.md
浏览文件 @
f8d8ffb1
...
...
@@ -8,7 +8,7 @@
## 导入模块
```
j
s
```
t
s
import
hiTraceChain
from
'
@ohos.hiTraceChain
'
;
```
...
...
@@ -93,7 +93,7 @@ begin(name: string, flags?: number): HiTraceId
**示例:**
```
j
s
```
t
s
let
asyncTraceId
=
hiTraceChain
.
begin
(
"
business
"
,
hiTraceChain
.
HiTraceFlag
.
INCLUDE_ASYNC
|
hiTraceChain
.
HiTraceFlag
.
DONOT_CREATE_SPAN
);
```
...
...
@@ -113,7 +113,7 @@ end(id: HiTraceId): void
**示例:**
```
j
s
```
t
s
let
asyncTraceId
=
hiTraceChain
.
begin
(
"
business
"
,
hiTraceChain
.
HiTraceFlag
.
DEFAULT
);
// 若干业务逻辑完成后,结束跟踪。
hiTraceChain
.
end
(
asyncTraceId
);
...
...
@@ -135,7 +135,7 @@ getId(): HiTraceId
**示例:**
```
j
s
```
t
s
let
traceId
=
hiTraceChain
.
begin
(
"
business
"
,
hiTraceChain
.
HiTraceFlag
.
DEFAULT
);
// 若干业务逻辑完成后,获取当前HiTraceId。
let
curTraceId
=
hiTraceChain
.
getId
();
...
...
@@ -157,10 +157,11 @@ setId(id: HiTraceId): void
**示例:**
```
js
let
asyncTraceId
;
```
ts
let
asyncTraceId
:
hiTraceChain
.
HiTraceId
;
hiTraceChain
.
end
(
asyncTraceId
);
let
traceId
=
hiTraceChain
.
begin
(
"
business
"
,
hiTraceChain
.
HiTraceFlag
.
DEFAULT
);
// 若干业务逻辑完成后,
设置当前HiT
raceId。
// 若干业务逻辑完成后,
将之前的traceId设置为当前t
raceId。
hiTraceChain
.
setId
(
asyncTraceId
);
```
...
...
@@ -174,7 +175,7 @@ clearId(): void
**示例:**
```
j
s
```
t
s
let
traceId
=
hiTraceChain
.
begin
(
"
business
"
,
hiTraceChain
.
HiTraceFlag
.
DEFAULT
);
// 若干业务逻辑完成后,清除当前HiTraceId。
hiTraceChain
.
clearId
();
...
...
@@ -196,7 +197,7 @@ createSpan(): HiTraceId
**示例:**
```
j
s
```
t
s
let
traceId
=
hiTraceChain
.
begin
(
"
business
"
,
hiTraceChain
.
HiTraceFlag
.
DEFAULT
);
// 若干业务逻辑完成后,创建跟踪分支。
let
spanTraceId
=
hiTraceChain
.
createSpan
();
...
...
@@ -221,7 +222,7 @@ tracepoint(mode: HiTraceCommunicationMode, type: HiTraceTracepointType, id: HiTr
**示例:**
```
j
s
```
t
s
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
"
);
...
...
@@ -249,7 +250,7 @@ isValid(id: HiTraceId): boolean
**示例:**
```
j
s
```
t
s
let
traceId
=
hiTraceChain
.
begin
(
"
business
"
,
hiTraceChain
.
HiTraceFlag
.
DEFAULT
);
let
traceIdIsvalid
=
hiTraceChain
.
isValid
(
traceId
);
```
...
...
@@ -277,7 +278,7 @@ isFlagEnabled(id: HiTraceId, flag: HiTraceFlag): boolean
**示例:**
```
j
s
```
t
s
let
asyncTraceId
=
hiTraceChain
.
begin
(
"
business
"
,
hiTraceChain
.
HiTraceFlag
.
INCLUDE_ASYNC
);
// enabledDoNotCreateSpanFlag为true
let
enabledDoNotCreateSpanFlag
=
hiTraceChain
.
isFlagEnabled
(
asyncTraceId
,
hiTraceChain
.
HiTraceFlag
.
INCLUDE_ASYNC
);
...
...
@@ -300,7 +301,7 @@ enableFlag(id: HiTraceId, flag: HiTraceFlag): void
**示例:**
```
j
s
```
t
s
let
asyncTraceId
=
hiTraceChain
.
begin
(
"
business
"
,
hiTraceChain
.
HiTraceFlag
.
INCLUDE_ASYNC
);
hiTraceChain
.
enableFlag
(
asyncTraceId
,
hiTraceChain
.
HiTraceFlag
.
DONOT_CREATE_SPAN
);
// enabledDoNotCreateSpanFlag为true
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录