From 35bfaf85ed6e2496ead0efc0a2bfb80b9e33161d Mon Sep 17 00:00:00 2001 From: xuyong Date: Tue, 8 Feb 2022 10:13:20 +0800 Subject: [PATCH 01/11] =?UTF-8?q?HiTrace=20Js=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xuyong --- api/@ohos.hitrace.d.ts | 214 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 214 insertions(+) create mode 100644 api/@ohos.hitrace.d.ts diff --git a/api/@ohos.hitrace.d.ts b/api/@ohos.hitrace.d.ts new file mode 100644 index 0000000000..cebf79a519 --- /dev/null +++ b/api/@ohos.hitrace.d.ts @@ -0,0 +1,214 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * 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. + * + * @since 9 + */ +declare namespace hitrace { + /** + * Enumerate trace flag + */ + enum HiTraceFlag { + /** + * default value + */ + DEFAULT = 0, + + /** + * trace sync and async call. default: trace sync call only. + */ + INCLUDE_ASYNC = 1, + + /** + * do not create child span. default: create child span. + */ + DONOT_CREATE_SPAN = 1 << 1, + + /** + * output tracepoint info in span. default: do not output tracepoint info. + */ + TP_INFO = 1 << 2, + + /** + * do not output begin and end info. default: output begin and end info. + */ + NO_BE_INFO = 1 << 3, + + /** + * do not add id to log. default: add id to log. + */ + DONOT_ENABLE_LOG = 1 << 4, + + /** + * the trace is triggered by fault. + */ + FAILURE_TRIGGER = 1 << 5, + + /** + * output device-to-device tracepoint info in span only. default: do not output device-to-device tracepoint info. + */ + D2D_TP_INFO = 1 << 6, + } + + /** + * Enumerate trace point type + */ + enum HiTraceTracePointType { + /** + * client send + */ + CS = 0, + + /** + * client receive + */ + CR = 1, + + /** + * server send + */ + SS = 2, + + /** + * server receive + */ + SR = 3, + + /** + * general info + */ + GENERAL = 4, + } + + /** + * Enumerate trace communication mode + */ + enum HiTraceCommunicationMode { + /** + * unspecified + */ + DEFAULT = 0, + + /** + * thread-to-thread + */ + THREAD = 1, + + /** + * process-to-process + */ + PROCESS = 2, + + /** + * device-to-device + */ + DEVICE = 3, + } + + /** + * trace id + */ + interface HiTraceId { + chainId: bigint; /* 0n: invalid */ + spandId?: number; + parentSpanId?: number; + flags?: number; + } + + /** + * begin a new trace. + * + * @param {string} name trace name. + * @param {number} flags trace flags. + * @return {HiTraceId} id of the trace. + */ + function begin(name: string, flags: number = HiTraceFlag.DEFAULT): HiTraceId; + + /** + * end a trace by trace id. + * + * @param {HiTraceId} id trace id of the trace. + */ + function end(id: HiTraceId): void; + + /** + * get the trace id of a trace. + * + * @return {HiTraceId} trace id of a trace. + */ + function getId(): HiTraceId; + + /** + * change the trace id for a trace. + * + * @param {HiTraceId} id trace id which will be set into a trace. + */ + function setId(id: HiTraceId): void; + + /** + * clear the id of a trace. + * + */ + function clearId(): void; + + /** + * create span for a trace. + * + * @return {HiTraceId} trace id of the trace which has created a span. + */ + function createSpan(): HiTraceId; + + /** + * set a trace point + * + * @param {HiTraceCommunicationMode} mode communication mode. + * @param {HiTraceTracePointType} type trace point type. + * @param {HiTraceId} id trace id of the trace. + * @param {string} msg description about this trace point. + */ + function tracepoint(mode: HiTraceCommunicationMode, type: HiTraceTracePointType, id: HiTraceId, msg?: string): void; + + /** + * check whether a trace id is valid. + * + * @param {HiTraceId} id the trace id to check. + * @return {boolean} true if trace id is valid. + */ + function isValid(id: HiTraceId): boolean; + + /** + * check whether a trace id has enabled the designative trace flag. + * + * @param {HiTraceId} id the trace id to check. + * @param {HiTraceFlag} flag the trace flag to check. + * @return {boolean} true if the flag has been enabled in a trace. + */ + function isFlagEnabled(id: HiTraceId, flag: HiTraceFlag): boolean; + + /** + * enable a designative trace flag for a trace id. + * + * @param {HiTraceId} id trace id which need enable a flag. + * @param {HiTraceFlag} flag the designative trace flag which will be enabled. + */ + function enableFlag(id: HiTraceId, flag: HiTraceFlag): void; +} + +export default hitrace; -- Gitee From 9f480588bf5397a49c6e2320229605c21f0fc197 Mon Sep 17 00:00:00 2001 From: xuyong Date: Tue, 8 Feb 2022 11:27:58 +0800 Subject: [PATCH 02/11] =?UTF-8?q?hitrace=20js=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xuyong --- api/@ohos.hitrace.d.ts | 47 +++++++++++++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 7 deletions(-) diff --git a/api/@ohos.hitrace.d.ts b/api/@ohos.hitrace.d.ts index cebf79a519..af1126b058 100644 --- a/api/@ohos.hitrace.d.ts +++ b/api/@ohos.hitrace.d.ts @@ -18,12 +18,16 @@ * 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. - * - * @since 9 + * + * @since 8 + * @SysCap SystemCapability.HiviewDFX.HiTrace */ declare namespace hitrace { /** * Enumerate trace flag + * + * @since 8 + * @SysCap SystemCapability.HiviewDFX.HiTrace */ enum HiTraceFlag { /** @@ -69,6 +73,9 @@ declare namespace hitrace { /** * Enumerate trace point type + * + * @since 8 + * @SysCap SystemCapability.HiviewDFX.HiTrace */ enum HiTraceTracePointType { /** @@ -99,6 +106,9 @@ declare namespace hitrace { /** * Enumerate trace communication mode + * + * @since 8 + * @SysCap SystemCapability.HiviewDFX.HiTrace */ enum HiTraceCommunicationMode { /** @@ -124,6 +134,9 @@ declare namespace hitrace { /** * trace id + * + * @since 8 + * @SysCap SystemCapability.HiviewDFX.HiTrace */ interface HiTraceId { chainId: bigint; /* 0n: invalid */ @@ -135,6 +148,8 @@ declare namespace hitrace { /** * begin a new trace. * + * @since 8 + * @SysCap SystemCapability.HiviewDFX.HiTrace * @param {string} name trace name. * @param {number} flags trace flags. * @return {HiTraceId} id of the trace. @@ -144,6 +159,8 @@ declare namespace hitrace { /** * end a trace by trace id. * + * @since 8 + * @SysCap SystemCapability.HiviewDFX.HiTrace * @param {HiTraceId} id trace id of the trace. */ function end(id: HiTraceId): void; @@ -151,6 +168,8 @@ declare namespace hitrace { /** * get the trace id of a trace. * + * @since 8 + * @SysCap SystemCapability.HiviewDFX.HiTrace * @return {HiTraceId} trace id of a trace. */ function getId(): HiTraceId; @@ -158,6 +177,8 @@ declare namespace hitrace { /** * change the trace id for a trace. * + * @since 8 + * @SysCap SystemCapability.HiviewDFX.HiTrace * @param {HiTraceId} id trace id which will be set into a trace. */ function setId(id: HiTraceId): void; @@ -165,19 +186,25 @@ declare namespace hitrace { /** * clear the id of a trace. * + * @since 8 + * @SysCap SystemCapability.HiviewDFX.HiTrace */ function clearId(): void; /** * create span for a trace. - * + * + * @since 8 + * @SysCap SystemCapability.HiviewDFX.HiTrace * @return {HiTraceId} trace id of the trace which has created a span. */ function createSpan(): HiTraceId; /** * set a trace point - * + * + * @since 8 + * @SysCap SystemCapability.HiviewDFX.HiTrace * @param {HiTraceCommunicationMode} mode communication mode. * @param {HiTraceTracePointType} type trace point type. * @param {HiTraceId} id trace id of the trace. @@ -187,7 +214,9 @@ declare namespace hitrace { /** * check whether a trace id is valid. - * + * + * @since 8 + * @SysCap SystemCapability.HiviewDFX.HiTrace * @param {HiTraceId} id the trace id to check. * @return {boolean} true if trace id is valid. */ @@ -195,7 +224,9 @@ declare namespace hitrace { /** * check whether a trace id has enabled the designative trace flag. - * + * + * @since 8 + * @SysCap SystemCapability.HiviewDFX.HiTrace * @param {HiTraceId} id the trace id to check. * @param {HiTraceFlag} flag the trace flag to check. * @return {boolean} true if the flag has been enabled in a trace. @@ -204,7 +235,9 @@ declare namespace hitrace { /** * enable a designative trace flag for a trace id. - * + * + * @since 8 + * @SysCap SystemCapability.HiviewDFX.HiTrace * @param {HiTraceId} id trace id which need enable a flag. * @param {HiTraceFlag} flag the designative trace flag which will be enabled. */ -- Gitee From b4d55e729a4ae575a353c1d1a5e8347fefca18f6 Mon Sep 17 00:00:00 2001 From: xuyong Date: Tue, 8 Feb 2022 11:47:38 +0800 Subject: [PATCH 03/11] =?UTF-8?q?hitrace=20js=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xuyong --- api/@ohos.hitrace.d.ts | 58 ++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/api/@ohos.hitrace.d.ts b/api/@ohos.hitrace.d.ts index af1126b058..70437f6867 100644 --- a/api/@ohos.hitrace.d.ts +++ b/api/@ohos.hitrace.d.ts @@ -133,7 +133,7 @@ declare namespace hitrace { } /** - * trace id + * trace id, for tracing process. * * @since 8 * @SysCap SystemCapability.HiviewDFX.HiTrace @@ -150,41 +150,43 @@ declare namespace hitrace { * * @since 8 * @SysCap SystemCapability.HiviewDFX.HiTrace - * @param {string} name trace name. - * @param {number} flags trace flags. - * @return {HiTraceId} id of the trace. + * @param {string} name Process name. + * @param {number} flags Trace function flag. + * @return {HiTraceId} Valid if first call, otherwise invalid. */ function begin(name: string, flags: number = HiTraceFlag.DEFAULT): HiTraceId; /** - * end a trace by trace id. + * Stop process tracing and clear trace id of current thread if the given trace + * id is valid, otherwise do nothing. * * @since 8 * @SysCap SystemCapability.HiviewDFX.HiTrace - * @param {HiTraceId} id trace id of the trace. + * @param {HiTraceId} id The trace id that need to stop. */ function end(id: HiTraceId): void; /** - * get the trace id of a trace. + * Get trace id of current thread, and return a invalid trace id if no + * trace id belong to current thread * * @since 8 * @SysCap SystemCapability.HiviewDFX.HiTrace - * @return {HiTraceId} trace id of a trace. + * @return {HiTraceId} Valid if current thread have a trace id, otherwise invalid. */ function getId(): HiTraceId; /** - * change the trace id for a trace. + * Set id as trace iod of current thread. Do nothing if id is invalid. * * @since 8 * @SysCap SystemCapability.HiviewDFX.HiTrace - * @param {HiTraceId} id trace id which will be set into a trace. + * @param {HiTraceId} id Set id as trace id of current thread. */ function setId(id: HiTraceId): void; /** - * clear the id of a trace. + * Clear trace id of current thread and set it invalid. * * @since 8 * @SysCap SystemCapability.HiviewDFX.HiTrace @@ -192,54 +194,54 @@ declare namespace hitrace { function clearId(): void; /** - * create span for a trace. + * Create a new span Id according to the trace id of current thread. * * @since 8 * @SysCap SystemCapability.HiviewDFX.HiTrace - * @return {HiTraceId} trace id of the trace which has created a span. + * @return {HiTraceId} A valid span trace id. Otherwise trace id of current thread if do not allow create span. */ function createSpan(): HiTraceId; /** - * set a trace point + * Print hitrace info, include trace id info. * * @since 8 * @SysCap SystemCapability.HiviewDFX.HiTrace - * @param {HiTraceCommunicationMode} mode communication mode. - * @param {HiTraceTracePointType} type trace point type. - * @param {HiTraceId} id trace id of the trace. - * @param {string} msg description about this trace point. + * @param {HiTraceCommunicationMode} mode Trace communication mode. + * @param {HiTraceTracePointType} type Trace info type. + * @param {HiTraceId} id Trace id that need to print. + * @param {string} msg Customized info that need to print. */ function tracepoint(mode: HiTraceCommunicationMode, type: HiTraceTracePointType, id: HiTraceId, msg?: string): void; /** - * check whether a trace id is valid. + * Judge whether the trace id is valid. * * @since 8 * @SysCap SystemCapability.HiviewDFX.HiTrace - * @param {HiTraceId} id the trace id to check. - * @return {boolean} true if trace id is valid. + * @param {HiTraceId} id Trace id that need to judge. + * @return {boolean} True for a valid trace id, otherwise false. */ function isValid(id: HiTraceId): boolean; /** - * check whether a trace id has enabled the designative trace flag. + * Judge whether the trace id has enabled a flag or not. * * @since 8 * @SysCap SystemCapability.HiviewDFX.HiTrace - * @param {HiTraceId} id the trace id to check. - * @param {HiTraceFlag} flag the trace flag to check. - * @return {boolean} true if the flag has been enabled in a trace. + * @param {HiTraceId} id Trace id that need to judge. + * @param {HiTraceFlag} flag Trace flag that need to judge. + * @return {boolean} true if the trace id has enabled the flag. */ function isFlagEnabled(id: HiTraceId, flag: HiTraceFlag): boolean; /** - * enable a designative trace flag for a trace id. + * Enable the designative trace flag for the trace id. * * @since 8 * @SysCap SystemCapability.HiviewDFX.HiTrace - * @param {HiTraceId} id trace id which need enable a flag. - * @param {HiTraceFlag} flag the designative trace flag which will be enabled. + * @param {HiTraceId} id Trace id that need to enable a flag. + * @param {HiTraceFlag} flag the designative trace flag that need to be enabled in the trace id. */ function enableFlag(id: HiTraceId, flag: HiTraceFlag): void; } -- Gitee From ac70ebd468b561afcb1d4c5aa30340ac43c886cf Mon Sep 17 00:00:00 2001 From: xuyong Date: Thu, 10 Feb 2022 15:43:18 +0800 Subject: [PATCH 04/11] =?UTF-8?q?HiTrace=20JS=20API=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xuyong --- ...s.hitrace.d.ts => @ohos.hiTraceChain.d.ts} | 4 +- api/@ohos.hiTraceMeter.d.ts | 72 +++++++++++++++++++ 2 files changed, 74 insertions(+), 2 deletions(-) rename api/{@ohos.hitrace.d.ts => @ohos.hiTraceChain.d.ts} (99%) create mode 100644 api/@ohos.hiTraceMeter.d.ts diff --git a/api/@ohos.hitrace.d.ts b/api/@ohos.hiTraceChain.d.ts similarity index 99% rename from api/@ohos.hitrace.d.ts rename to api/@ohos.hiTraceChain.d.ts index 70437f6867..ccbce6ca6b 100644 --- a/api/@ohos.hitrace.d.ts +++ b/api/@ohos.hiTraceChain.d.ts @@ -22,7 +22,7 @@ * @since 8 * @SysCap SystemCapability.HiviewDFX.HiTrace */ -declare namespace hitrace { +declare namespace hiTraceChain { /** * Enumerate trace flag * @@ -246,4 +246,4 @@ declare namespace hitrace { function enableFlag(id: HiTraceId, flag: HiTraceFlag): void; } -export default hitrace; +export default hiTraceChain; diff --git a/api/@ohos.hiTraceMeter.d.ts b/api/@ohos.hiTraceMeter.d.ts new file mode 100644 index 0000000000..7d5a4cd4c9 --- /dev/null +++ b/api/@ohos.hiTraceMeter.d.ts @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import bytrace from './@ohos.bytrace' + +/** + * Provides interfaces to trace a task for performance measure, the logs can be capture by the + * bytrace cmdline available on the device. + * + * @since 8 + * @SysCap SystemCapability.HiviewDFX.HiTrace + */ + declare namespace hiTraceMeter { + /** + * Records a trace marking it as the start of a task, can with the expected completion time between + * startTrace and finishTrace. + * + * This method is invoked at the start of a transaction to indicate that a task has started, whose name + * is specified by {@code name}, and the taskId is used to distinguish the tasks. It must be followed by + * {@link #finishTrace}, the name and taskId need to be the same. + * + * @since 8 + * @SysCap SystemCapability.HiviewDFX.HiTrace + * @param name Indicates the task name. + * @param taskId The unique id used to distinguish the tasks and match with the id in follow finishTrace. + * @param expectedTime Indicates the expected time required for completing the task, in milliseconds. + */ + function startTrace(name: string, taskId: number, expectedTime?: number): void { + bytrace.startTrace(name, taskId, expectedTime); + } + + /** + * Records a trace and marks it as the end of a task. + * + * This method is invoked at the end of a transaction to indicate that a task has ended, whose name + * is specified by {@code name}. This method must be invoked after the the startTrace. + * + * @since 8 + * @SysCap SystemCapability.HiviewDFX.HiTrace + * @param name Indicates the task name. It must be the same whith the {@code name} of startTrace. + * @param taskId The unique id used to distinguish the tasks and must be the same whith the . + * {@code taskId} of startTrace. + */ + function finishTrace(name: string, taskId: number): void { + bytrace.finishTrace(name, taskId); + } + + /** + * Records a trace for generating a count, such as clock pulse and the number of layers. + * + * @since 8 + * @SysCap SystemCapability.HiviewDFX.HiTrace + * @param name Indicates the name used to identify the count. + * @param count Indicates the number of the count. + */ + function traceByValue(name: string, count: number): void { + bytrace.traceByValue(name, count); + } + } + export default hiTraceMeter; \ No newline at end of file -- Gitee From 866e0ff3b11e6bd8c35394fee4f32c6cc449ae56 Mon Sep 17 00:00:00 2001 From: xuyong Date: Thu, 10 Feb 2022 20:52:54 +0800 Subject: [PATCH 05/11] HiTrace Js Api Signed-off-by: xuyong --- api/@ohos.hiTraceMeter.d.ts | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/api/@ohos.hiTraceMeter.d.ts b/api/@ohos.hiTraceMeter.d.ts index 7d5a4cd4c9..95b1984c12 100644 --- a/api/@ohos.hiTraceMeter.d.ts +++ b/api/@ohos.hiTraceMeter.d.ts @@ -13,8 +13,6 @@ * limitations under the License. */ -import bytrace from './@ohos.bytrace' - /** * Provides interfaces to trace a task for performance measure, the logs can be capture by the * bytrace cmdline available on the device. @@ -22,7 +20,7 @@ import bytrace from './@ohos.bytrace' * @since 8 * @SysCap SystemCapability.HiviewDFX.HiTrace */ - declare namespace hiTraceMeter { +declare namespace hiTraceMeter { /** * Records a trace marking it as the start of a task, can with the expected completion time between * startTrace and finishTrace. @@ -35,11 +33,8 @@ import bytrace from './@ohos.bytrace' * @SysCap SystemCapability.HiviewDFX.HiTrace * @param name Indicates the task name. * @param taskId The unique id used to distinguish the tasks and match with the id in follow finishTrace. - * @param expectedTime Indicates the expected time required for completing the task, in milliseconds. */ - function startTrace(name: string, taskId: number, expectedTime?: number): void { - bytrace.startTrace(name, taskId, expectedTime); - } + function startTrace(name: string, taskId: number): void; /** * Records a trace and marks it as the end of a task. @@ -53,9 +48,7 @@ import bytrace from './@ohos.bytrace' * @param taskId The unique id used to distinguish the tasks and must be the same whith the . * {@code taskId} of startTrace. */ - function finishTrace(name: string, taskId: number): void { - bytrace.finishTrace(name, taskId); - } + function finishTrace(name: string, taskId: number): void; /** * Records a trace for generating a count, such as clock pulse and the number of layers. @@ -65,8 +58,7 @@ import bytrace from './@ohos.bytrace' * @param name Indicates the name used to identify the count. * @param count Indicates the number of the count. */ - function traceByValue(name: string, count: number): void { - bytrace.traceByValue(name, count); - } - } - export default hiTraceMeter; \ No newline at end of file + function traceByValue(name: string, count: number): void; +} + +export default hiTraceMeter; \ No newline at end of file -- Gitee From 1e84162f47582b7e1b1a2be86b1820453611cd57 Mon Sep 17 00:00:00 2001 From: xuyong Date: Fri, 11 Feb 2022 13:56:38 +0800 Subject: [PATCH 06/11] HiTrace Js Api Signed-off-by: xuyong --- api/@ohos.bytrace.d.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/api/@ohos.bytrace.d.ts b/api/@ohos.bytrace.d.ts index dcc5ba1bf0..93c004030a 100644 --- a/api/@ohos.bytrace.d.ts +++ b/api/@ohos.bytrace.d.ts @@ -34,9 +34,9 @@ *

Each {@code startTrace} matches one {@code finishTrace}, and they must have the same name * and taskId. * - * @SysCap SystemCapability.Developtools.Bytrace - * @devices phone, tablet + * @deprecated * @since 7 + * @SysCap SystemCapability.Developtools.Bytrace */ declare namespace bytrace { /** @@ -47,10 +47,12 @@ declare namespace bytrace { * is specified by {@code name}, and the taskId is used to distinguish the tasks. It must be followed by * {@link #finishTrace}, the name and taskId need to be the same. * + * @deprecated + * @since 7 + * @SysCap SystemCapability.Developtools.Bytrace * @param name Indicates the task name. * @param taskId The unique id used to distinguish the tasks and match with the id in follow finishTrace. * @param expectedTime Indicates the expected time required for completing the task, in milliseconds. - * @since 7 */ function startTrace(name: string, taskId: number, expectedTime?: number): void; @@ -60,6 +62,9 @@ declare namespace bytrace { * This method is invoked at the end of a transaction to indicate that a task has ended, whose name * is specified by {@code name}. This method must be invoked after the the startTrace. * + * @deprecated + * @since 7 + * @SysCap SystemCapability.Developtools.Bytrace * @param name Indicates the task name. It must be the same whith the {@code name} of startTrace. * @param taskId The unique id used to distinguish the tasks and must be the same whith the . * {@code taskId} of startTrace. -- Gitee From c3e42b14f8e8dcb7ebb20d1dd4a945ebabf20b45 Mon Sep 17 00:00:00 2001 From: xuyong Date: Fri, 11 Feb 2022 15:17:07 +0800 Subject: [PATCH 07/11] HiTrace Js Api Signed-off-by: xuyong --- api/@ohos.bytrace.d.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/api/@ohos.bytrace.d.ts b/api/@ohos.bytrace.d.ts index 93c004030a..1acc5cc2a9 100644 --- a/api/@ohos.bytrace.d.ts +++ b/api/@ohos.bytrace.d.ts @@ -68,16 +68,17 @@ declare namespace bytrace { * @param name Indicates the task name. It must be the same whith the {@code name} of startTrace. * @param taskId The unique id used to distinguish the tasks and must be the same whith the . * {@code taskId} of startTrace. - * @since 7 */ function finishTrace(name: string, taskId: number): void; /** * Records a trace for generating a count, such as clock pulse and the number of layers. * + * @deprecated + * @since 7 + * @SysCap SystemCapability.Developtools.Bytrace * @param name Indicates the name used to identify the count. * @param count Indicates the number of the count. - * @since 7 */ function traceByValue(name: string, count: number): void; } -- Gitee From b287a5d3202337eeb89e0884831a48e443e00d69 Mon Sep 17 00:00:00 2001 From: xuyong Date: Fri, 11 Feb 2022 17:10:03 +0800 Subject: [PATCH 08/11] HiTrace Js Api Signed-off-by: xuyong --- api/@ohos.hiTraceMeter.d.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/api/@ohos.hiTraceMeter.d.ts b/api/@ohos.hiTraceMeter.d.ts index 95b1984c12..1d624ced5b 100644 --- a/api/@ohos.hiTraceMeter.d.ts +++ b/api/@ohos.hiTraceMeter.d.ts @@ -17,6 +17,23 @@ * Provides interfaces to trace a task for performance measure, the logs can be capture by the * bytrace cmdline available on the device. * + *

This interfaces trace the start, end, and value changes of key processes that last for at least 3 ms. + * + *

Example: + * To trace a name verification that is expected to complete within 5 ms: + *

{@code
+ * bytrace.startTrace("checkName", 111, 5);
+ * //your process
+ * bytrace.finishTrace("checkName", 111);
+ * }
+ * To trace the number of layers, which is 3: + *
{@code
+ * bytrace.traceByValue("curLayer", 3);
+ * }
+ * + *

Each {@code startTrace} matches one {@code finishTrace}, and they must have the same name + * and taskId. + * * @since 8 * @SysCap SystemCapability.HiviewDFX.HiTrace */ -- Gitee From 6550831b8f94be62ef3e0c327b66b19ddad1c1c5 Mon Sep 17 00:00:00 2001 From: xuyong Date: Sat, 12 Feb 2022 11:51:40 +0800 Subject: [PATCH 09/11] HiTrace Js Api Signed-off-by: xuyong --- api/@ohos.hiTraceChain.d.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/api/@ohos.hiTraceChain.d.ts b/api/@ohos.hiTraceChain.d.ts index ccbce6ca6b..bdbd9ea02d 100644 --- a/api/@ohos.hiTraceChain.d.ts +++ b/api/@ohos.hiTraceChain.d.ts @@ -133,20 +133,20 @@ declare namespace hiTraceChain { } /** - * trace id, for tracing process. + * Trace id, for tracing process. * * @since 8 * @SysCap SystemCapability.HiviewDFX.HiTrace */ interface HiTraceId { chainId: bigint; /* 0n: invalid */ - spandId?: number; + spanId?: number; parentSpanId?: number; flags?: number; } /** - * begin a new trace. + * Start tracing a process impl. * * @since 8 * @SysCap SystemCapability.HiviewDFX.HiTrace @@ -177,7 +177,7 @@ declare namespace hiTraceChain { function getId(): HiTraceId; /** - * Set id as trace iod of current thread. Do nothing if id is invalid. + * Set id as trace id of current thread. Do nothing if id is invalid. * * @since 8 * @SysCap SystemCapability.HiviewDFX.HiTrace @@ -194,7 +194,7 @@ declare namespace hiTraceChain { function clearId(): void; /** - * Create a new span Id according to the trace id of current thread. + * Create a new span id according to the trace id of current thread. * * @since 8 * @SysCap SystemCapability.HiviewDFX.HiTrace @@ -215,7 +215,7 @@ declare namespace hiTraceChain { function tracepoint(mode: HiTraceCommunicationMode, type: HiTraceTracePointType, id: HiTraceId, msg?: string): void; /** - * Judge whether the trace id is valid. + * Judge whether the trace id is valid or not. * * @since 8 * @SysCap SystemCapability.HiviewDFX.HiTrace @@ -225,7 +225,7 @@ declare namespace hiTraceChain { function isValid(id: HiTraceId): boolean; /** - * Judge whether the trace id has enabled a flag or not. + * Judge whether the trace id has enabled a trace flag or not. * * @since 8 * @SysCap SystemCapability.HiviewDFX.HiTrace -- Gitee From e00dab4bbcbd1f3e8e59541cd9da4d5b946a0fdd Mon Sep 17 00:00:00 2001 From: xuyong Date: Tue, 15 Feb 2022 14:48:09 +0800 Subject: [PATCH 10/11] =?UTF-8?q?HiTrace=20NAPI=20=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xuyong --- api/@ohos.hiTraceChain.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/@ohos.hiTraceChain.d.ts b/api/@ohos.hiTraceChain.d.ts index bdbd9ea02d..8b7ba82fdd 100644 --- a/api/@ohos.hiTraceChain.d.ts +++ b/api/@ohos.hiTraceChain.d.ts @@ -58,7 +58,7 @@ declare namespace hiTraceChain { /** * do not add id to log. default: add id to log. */ - DONOT_ENABLE_LOG = 1 << 4, + DISABLE_LOG = 1 << 4, /** * the trace is triggered by fault. -- Gitee From 4c6ed64b40d4d1f8aa362952f7053d7a475c40a6 Mon Sep 17 00:00:00 2001 From: xuyong Date: Tue, 15 Feb 2022 16:39:43 +0800 Subject: [PATCH 11/11] =?UTF-8?q?HiTrace=20JS=20=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xuyong --- api/@ohos.hiTraceChain.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/@ohos.hiTraceChain.d.ts b/api/@ohos.hiTraceChain.d.ts index 8b7ba82fdd..cd0b78fc53 100644 --- a/api/@ohos.hiTraceChain.d.ts +++ b/api/@ohos.hiTraceChain.d.ts @@ -77,7 +77,7 @@ declare namespace hiTraceChain { * @since 8 * @SysCap SystemCapability.HiviewDFX.HiTrace */ - enum HiTraceTracePointType { + enum HiTraceTracepointType { /** * client send */ @@ -208,11 +208,11 @@ declare namespace hiTraceChain { * @since 8 * @SysCap SystemCapability.HiviewDFX.HiTrace * @param {HiTraceCommunicationMode} mode Trace communication mode. - * @param {HiTraceTracePointType} type Trace info type. + * @param {HiTraceTracepointType} type Trace info type. * @param {HiTraceId} id Trace id that need to print. * @param {string} msg Customized info that need to print. */ - function tracepoint(mode: HiTraceCommunicationMode, type: HiTraceTracePointType, id: HiTraceId, msg?: string): void; + function tracepoint(mode: HiTraceCommunicationMode, type: HiTraceTracepointType, id: HiTraceId, msg?: string): void; /** * Judge whether the trace id is valid or not. -- Gitee