From 6355a86ed997ba660a9c9a7a121e6df62baff441 Mon Sep 17 00:00:00 2001 From: wangqing Date: Tue, 24 Jun 2025 10:04:57 +0800 Subject: [PATCH] code sync Signed-off-by: wangqing Change-Id: Ia7c590ae89a5a64cfcbd6798f298dff430088746 --- api/@ohos.hiTraceChain.d.ets | 342 ----------------------------------- api/@ohos.hiTraceChain.d.ts | 108 +++++++---- api/@ohos.hiTraceMeter.d.ets | 308 ------------------------------- api/@ohos.hiTraceMeter.d.ts | 306 +++++++++++++++++++++++++++---- 4 files changed, 342 insertions(+), 722 deletions(-) delete mode 100644 api/@ohos.hiTraceChain.d.ets delete mode 100644 api/@ohos.hiTraceMeter.d.ets diff --git a/api/@ohos.hiTraceChain.d.ets b/api/@ohos.hiTraceChain.d.ets deleted file mode 100644 index 720a7bb6cb..0000000000 --- a/api/@ohos.hiTraceChain.d.ets +++ /dev/null @@ -1,342 +0,0 @@ -/* - * Copyright (c) 2025 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. - */ - -/** - * @file - * @kit PerformanceAnalysisKit - */ - -/** - * 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. - * - * @namespace hiTraceChain - * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 - */ -declare namespace hiTraceChain { - /** - * Enumerate trace flag - * - * @enum { number } - * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 - */ - export enum HiTraceFlag { - /** - * Default value - * - * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 - */ - DEFAULT = 0, - - /** - * Trace sync and async call. default: trace sync call only. - * - * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 - */ - INCLUDE_ASYNC = 1, - - /** - * Do not create child span. default: create child span. - * - * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 - */ - DONOT_CREATE_SPAN = 1 << 1, - - /** - * Output tracepoint info in span. default: do not output tracepoint info. - * - * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 - */ - TP_INFO = 1 << 2, - - /** - * Do not output begin and end info. default: output begin and end info. - * - * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 - */ - NO_BE_INFO = 1 << 3, - - /** - * Do not add id to log. default: add id to log. - * - * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 - */ - DISABLE_LOG = 1 << 4, - - /** - * The trace is triggered by fault. - * - * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 - */ - FAILURE_TRIGGER = 1 << 5, - - /** - * Output device-to-device tracepoint info in span only. default: do not output device-to-device tracepoint info. - * - * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 - */ - D2D_TP_INFO = 1 << 6 - } - - /** - * Enumerate trace point type - * - * @enum { number } - * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 - */ - export enum HiTraceTracepointType { - /** - * Client send - * - * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 - */ - CS = 0, - - /** - * Client receive - * - * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 - */ - CR = 1, - - /** - * Server send - * - * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 - */ - SS = 2, - - /** - * Server receive - * - * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 - */ - SR = 3, - - /** - * General info - * - * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 - */ - GENERAL = 4 - } - - /** - * Enumerate trace communication mode - * - * @enum { number } - * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 - */ - export enum HiTraceCommunicationMode { - /** - * Unspecified - * - * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 - */ - DEFAULT = 0, - - /** - * Thread-to-thread - * - * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 - */ - THREAD = 1, - - /** - * Process-to-process - * - * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 - */ - PROCESS = 2, - - /** - * Device-to-device - * - * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 - */ - DEVICE = 3 - } - - /** - * Trace id, for tracing process. - * - * @interface HiTraceId - * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 - */ - export interface HiTraceId { - /** - * Chain id. - * - * @type { bigint } - * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 - */ - chainId: bigint; - - /** - * Span id. - * - * @type { ?number } - * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 - */ - spanId?: number; - - /** - * Parent span id. - * - * @type { ?number } - * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 - */ - parentSpanId?: number; - - /** - * Trace flag. - * - * @type { ?number } - * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 - */ - flags?: number; - } - - /** - * Start tracing a process impl. - * - * @param { string } name Process name. - * @param { number } flags Trace function flag. - * @returns { HiTraceId } Valid if first call, otherwise invalid. - * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 - */ - export function begin(name: string, flags?: number): HiTraceId; - - /** - * Stop process tracing and clear trace id of current thread if the given trace - * id is valid, otherwise do nothing. - * - * @param { HiTraceId } id The trace id that need to stop. - * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 - */ - export function end(id: HiTraceId): void; - - /** - * Get trace id of current thread, and return a invalid trace id if no - * trace id belong to current thread - * - * @returns { HiTraceId } Valid if current thread have a trace id, otherwise invalid. - * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 - */ - export function getId(): HiTraceId; - - /** - * Set id as trace id of current thread. Do nothing if id is invalid. - * - * @param { HiTraceId } id Set id as trace id of current thread. - * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 - */ - export function setId(id: HiTraceId): void; - - /** - * Clear trace id of current thread and set it invalid. - * - * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 - */ - export function clearId(): void; - - /** - * Create a new span id according to the trace id of current thread. - * - * @returns { HiTraceId } A valid span trace id. Otherwise trace id of current thread if do not allow create span. - * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 - */ - export function createSpan(): HiTraceId; - - /** - * Print hitrace info, include trace id info. - * - * @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. - * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 - */ - export function tracepoint(mode: HiTraceCommunicationMode, - type: HiTraceTracepointType, id: HiTraceId, msg?: string): void; - - /** - * Judge whether the trace id is valid or not. - * - * @param { HiTraceId } id Trace id that need to judge. - * @returns { boolean } True for a valid trace id, otherwise false. - * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 - */ - export function isValid(id: HiTraceId): boolean; - - /** - * Judge whether the trace id has enabled a trace flag or not. - * - * @param { HiTraceId } id Trace id that need to judge. - * @param { HiTraceFlag } flag Trace flag that need to judge. - * @returns { boolean } true if the trace id has enabled the flag. - * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 - */ - export function isFlagEnabled(id: HiTraceId, flag: HiTraceFlag): boolean; - - /** - * Enable the designative trace flag for the trace id. - * - * @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. - * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 - */ - export function enableFlag(id: HiTraceId, flag: HiTraceFlag): void; -} - -export default hiTraceChain; diff --git a/api/@ohos.hiTraceChain.d.ts b/api/@ohos.hiTraceChain.d.ts index 0e3c01da19..e10a356cdc 100644 --- a/api/@ohos.hiTraceChain.d.ts +++ b/api/@ohos.hiTraceChain.d.ts @@ -26,7 +26,8 @@ * * @namespace hiTraceChain * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 + * @since arkts {'1.1':'8','1.2':'20'} + * @arkts 1.1&1.2 */ declare namespace hiTraceChain { /** @@ -34,14 +35,16 @@ declare namespace hiTraceChain { * * @enum { number } * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 + * @since arkts {'1.1':'8','1.2':'20'} + * @arkts 1.1&1.2 */ enum HiTraceFlag { /** * Default value * * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 + * @since arkts {'1.1':'8','1.2':'20'} + * @arkts 1.1&1.2 */ DEFAULT = 0, @@ -49,7 +52,8 @@ declare namespace hiTraceChain { * Trace sync and async call. default: trace sync call only. * * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 + * @since arkts {'1.1':'8','1.2':'20'} + * @arkts 1.1&1.2 */ INCLUDE_ASYNC = 1, @@ -57,7 +61,8 @@ declare namespace hiTraceChain { * Do not create child span. default: create child span. * * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 + * @since arkts {'1.1':'8','1.2':'20'} + * @arkts 1.1&1.2 */ DONOT_CREATE_SPAN = 1 << 1, @@ -65,7 +70,8 @@ declare namespace hiTraceChain { * Output tracepoint info in span. default: do not output tracepoint info. * * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 + * @since arkts {'1.1':'8','1.2':'20'} + * @arkts 1.1&1.2 */ TP_INFO = 1 << 2, @@ -73,7 +79,8 @@ declare namespace hiTraceChain { * Do not output begin and end info. default: output begin and end info. * * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 + * @since arkts {'1.1':'8','1.2':'20'} + * @arkts 1.1&1.2 */ NO_BE_INFO = 1 << 3, @@ -81,7 +88,8 @@ declare namespace hiTraceChain { * Do not add id to log. default: add id to log. * * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 + * @since arkts {'1.1':'8','1.2':'20'} + * @arkts 1.1&1.2 */ DISABLE_LOG = 1 << 4, @@ -89,7 +97,8 @@ declare namespace hiTraceChain { * The trace is triggered by fault. * * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 + * @since arkts {'1.1':'8','1.2':'20'} + * @arkts 1.1&1.2 */ FAILURE_TRIGGER = 1 << 5, @@ -97,7 +106,8 @@ declare namespace hiTraceChain { * Output device-to-device tracepoint info in span only. default: do not output device-to-device tracepoint info. * * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 + * @since arkts {'1.1':'8','1.2':'20'} + * @arkts 1.1&1.2 */ D2D_TP_INFO = 1 << 6 } @@ -107,14 +117,16 @@ declare namespace hiTraceChain { * * @enum { number } * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 + * @since arkts {'1.1':'8','1.2':'20'} + * @arkts 1.1&1.2 */ enum HiTraceTracepointType { /** * Client send * * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 + * @since arkts {'1.1':'8','1.2':'20'} + * @arkts 1.1&1.2 */ CS = 0, @@ -122,7 +134,8 @@ declare namespace hiTraceChain { * Client receive * * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 + * @since arkts {'1.1':'8','1.2':'20'} + * @arkts 1.1&1.2 */ CR = 1, @@ -130,7 +143,8 @@ declare namespace hiTraceChain { * Server send * * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 + * @since arkts {'1.1':'8','1.2':'20'} + * @arkts 1.1&1.2 */ SS = 2, @@ -138,7 +152,8 @@ declare namespace hiTraceChain { * Server receive * * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 + * @since arkts {'1.1':'8','1.2':'20'} + * @arkts 1.1&1.2 */ SR = 3, @@ -146,7 +161,8 @@ declare namespace hiTraceChain { * General info * * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 + * @since arkts {'1.1':'8','1.2':'20'} + * @arkts 1.1&1.2 */ GENERAL = 4 } @@ -156,14 +172,16 @@ declare namespace hiTraceChain { * * @enum { number } * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 + * @since arkts {'1.1':'8','1.2':'20'} + * @arkts 1.1&1.2 */ enum HiTraceCommunicationMode { /** * Unspecified * * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 + * @since arkts {'1.1':'8','1.2':'20'} + * @arkts 1.1&1.2 */ DEFAULT = 0, @@ -171,7 +189,8 @@ declare namespace hiTraceChain { * Thread-to-thread * * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 + * @since arkts {'1.1':'8','1.2':'20'} + * @arkts 1.1&1.2 */ THREAD = 1, @@ -179,7 +198,8 @@ declare namespace hiTraceChain { * Process-to-process * * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 + * @since arkts {'1.1':'8','1.2':'20'} + * @arkts 1.1&1.2 */ PROCESS = 2, @@ -187,7 +207,8 @@ declare namespace hiTraceChain { * Device-to-device * * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 + * @since arkts {'1.1':'8','1.2':'20'} + * @arkts 1.1&1.2 */ DEVICE = 3 } @@ -197,7 +218,8 @@ declare namespace hiTraceChain { * * @interface HiTraceId * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 + * @since arkts {'1.1':'8','1.2':'20'} + * @arkts 1.1&1.2 */ interface HiTraceId { /** @@ -205,7 +227,8 @@ declare namespace hiTraceChain { * * @type { bigint } * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 + * @since arkts {'1.1':'8','1.2':'20'} + * @arkts 1.1&1.2 */ chainId: bigint; @@ -214,7 +237,8 @@ declare namespace hiTraceChain { * * @type { ?number } * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 + * @since arkts {'1.1':'8','1.2':'20'} + * @arkts 1.1&1.2 */ spanId?: number; @@ -223,7 +247,8 @@ declare namespace hiTraceChain { * * @type { ?number } * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 + * @since arkts {'1.1':'8','1.2':'20'} + * @arkts 1.1&1.2 */ parentSpanId?: number; @@ -232,7 +257,8 @@ declare namespace hiTraceChain { * * @type { ?number } * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 + * @since arkts {'1.1':'8','1.2':'20'} + * @arkts 1.1&1.2 */ flags?: number; } @@ -244,7 +270,8 @@ declare namespace hiTraceChain { * @param { number } flags Trace function flag. * @returns { HiTraceId } Valid if first call, otherwise invalid. * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 + * @since arkts {'1.1':'8','1.2':'20'} + * @arkts 1.1&1.2 */ function begin(name: string, flags?: number): HiTraceId; @@ -254,7 +281,8 @@ declare namespace hiTraceChain { * * @param { HiTraceId } id The trace id that need to stop. * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 + * @since arkts {'1.1':'8','1.2':'20'} + * @arkts 1.1&1.2 */ function end(id: HiTraceId): void; @@ -264,7 +292,8 @@ declare namespace hiTraceChain { * * @returns { HiTraceId } Valid if current thread have a trace id, otherwise invalid. * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 + * @since arkts {'1.1':'8','1.2':'20'} + * @arkts 1.1&1.2 */ function getId(): HiTraceId; @@ -273,7 +302,8 @@ declare namespace hiTraceChain { * * @param { HiTraceId } id Set id as trace id of current thread. * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 + * @since arkts {'1.1':'8','1.2':'20'} + * @arkts 1.1&1.2 */ function setId(id: HiTraceId): void; @@ -281,7 +311,8 @@ declare namespace hiTraceChain { * Clear trace id of current thread and set it invalid. * * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 + * @since arkts {'1.1':'8','1.2':'20'} + * @arkts 1.1&1.2 */ function clearId(): void; @@ -290,7 +321,8 @@ declare namespace hiTraceChain { * * @returns { HiTraceId } A valid span trace id. Otherwise trace id of current thread if do not allow create span. * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 + * @since arkts {'1.1':'8','1.2':'20'} + * @arkts 1.1&1.2 */ function createSpan(): HiTraceId; @@ -302,7 +334,8 @@ declare namespace hiTraceChain { * @param { HiTraceId } id Trace id that need to print. * @param { string } msg Customized info that need to print. * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 + * @since arkts {'1.1':'8','1.2':'20'} + * @arkts 1.1&1.2 */ function tracepoint(mode: HiTraceCommunicationMode, type: HiTraceTracepointType, id: HiTraceId, msg?: string): void; @@ -312,7 +345,8 @@ declare namespace hiTraceChain { * @param { HiTraceId } id Trace id that need to judge. * @returns { boolean } True for a valid trace id, otherwise false. * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 + * @since arkts {'1.1':'8','1.2':'20'} + * @arkts 1.1&1.2 */ function isValid(id: HiTraceId): boolean; @@ -323,7 +357,8 @@ declare namespace hiTraceChain { * @param { HiTraceFlag } flag Trace flag that need to judge. * @returns { boolean } true if the trace id has enabled the flag. * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 + * @since arkts {'1.1':'8','1.2':'20'} + * @arkts 1.1&1.2 */ function isFlagEnabled(id: HiTraceId, flag: HiTraceFlag): boolean; @@ -333,7 +368,8 @@ declare namespace hiTraceChain { * @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. * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 + * @since arkts {'1.1':'8','1.2':'20'} + * @arkts 1.1&1.2 */ function enableFlag(id: HiTraceId, flag: HiTraceFlag): void; } diff --git a/api/@ohos.hiTraceMeter.d.ets b/api/@ohos.hiTraceMeter.d.ets deleted file mode 100644 index 86bab093e0..0000000000 --- a/api/@ohos.hiTraceMeter.d.ets +++ /dev/null @@ -1,308 +0,0 @@ -/* - * Copyright (C) 2025 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. - */ - -/** - * @file - * @kit PerformanceAnalysisKit - */ - -/** - * 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: - * Track the beginning of a context: - *

{@code
- * hiTraceMeter.startTrace("checkName", 111);
- * }
- * Track the end of a context: - *
{@code
- * hiTraceMeter.finishTrace("checkName", 111);
- * }
- * To trace the number of layers, which is 3: - *
{@code
- * hiTraceMeter.traceByValue("curLayer", 3);
- * }
- * - *

Each {@code startTrace} matches one {@code finishTrace}, and they must have the same name - * and taskId. - * - * @namespace hiTraceMeter - * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 - */ -/** - * Provides interfaces to trace a task for performance measure, the logs can be capture by the - * hitrace cmdline on the device. - * - *

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

Example: - * Track the beginning of a context: - *

{@code
- * hiTraceMeter.startAsyncTrace(hiTraceMeter.HiTraceOutputLevel.COMMERCIAL, "checkName", 111, "test", "key=value");
- * }
- * Track the end of a context: - *
{@code
- * hiTraceMeter.finishAsyncTrace(hiTraceMeter.HiTraceOutputLevel.COMMERCIAL, "checkName", 111);
- * }
- * To trace the number of layers, which is 3: - *
{@code
- * hiTraceMeter.traceByValue(hiTraceMeter.HiTraceOutputLevel.COMMERCIAL, "curLayer", 3);
- * }
- * - *

Each {@code startTrace} matches one {@code finishTrace}, and they must have the same name - * and taskId. - * - *

Each {@code startSyncTrace} matches one {@code finishSyncTrace}, and they must have the same - * level and name. - * - *

Each {@code startAsyncTrace} matches one {@code finishAsyncTrace}, and they must have the same - * level, name and taskId. - * - * @namespace hiTraceMeter - * @syscap SystemCapability.HiviewDFX.HiTrace - * @atomicservice - * @since 19 - */ -declare namespace hiTraceMeter { - - /** - * Enumerates the HiTrace output levels. The output level threshold system parameter determines - * the minimum output trace. - * - * @enum { number } - * @syscap SystemCapability.HiviewDFX.HiTrace - * @atomicservice - * @since 19 - */ - export enum HiTraceOutputLevel { - /** - * Ouput level only for debug usage. - * - * @syscap SystemCapability.HiviewDFX.HiTrace - * @atomicservice - * @since 19 - */ - DEBUG = 0, - - /** - * Output level for log version usage. - * - * @syscap SystemCapability.HiviewDFX.HiTrace - * @atomicservice - * @since 19 - */ - INFO = 1, - - /** - * Output level for log version usage, with higher priority than INFO. - * - * @syscap SystemCapability.HiviewDFX.HiTrace - * @atomicservice - * @since 19 - */ - CRITICAL = 2, - - /** - * Output level for nolog version usage. - * - * @syscap SystemCapability.HiviewDFX.HiTrace - * @atomicservice - * @since 19 - */ - COMMERCIAL = 3, - - /** - * Output level range limit. - * - * @syscap SystemCapability.HiviewDFX.HiTrace - * @atomicservice - * @since 19 - */ - MAX = 3 - } - - /** - * 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. - * - * @param { string } name Indicates the task name. - * @param { number } taskId The unique id used to distinguish the tasks and match with the id in follow finishTrace. - * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 - */ - /** - * 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. - * - * @param { string } name Indicates the task name. - * @param { number } taskId The unique id used to distinguish the tasks and match with the id in follow finishTrace. - * @syscap SystemCapability.HiviewDFX.HiTrace - * @atomicservice - * @since 19 - */ - export function startTrace(name: string, taskId: number): void; - - /** - * 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. - * - * @param { string } name Indicates the task name. It must be the same with the {@code name} of startTrace. - * @param { number } taskId The unique id used to distinguish the tasks and must be the same with the . - * {@code taskId} of startTrace. - * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 - */ - /** - * 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 {@link #startTrace}. - * - * @param { string } name Indicates the task name. It must be the same with the {@code name} of startTrace. - * @param { number } taskId The unique id used to distinguish the tasks and must be the same with the - * {@code taskId} of startTrace. - * @syscap SystemCapability.HiviewDFX.HiTrace - * @atomicservice - * @since 19 - */ - export function finishTrace(name: string, taskId: number): void; - - /** - * Records a trace for generating a count, such as clock pulse and the number of layers. - * - * @param { string } name Indicates the name used to identify the count. - * @param { number } count Indicates the number of the count. - * @syscap SystemCapability.HiviewDFX.HiTrace - * @since 8 - */ - /** - * Records a trace for generating a count, such as clock pulse and the number of layers. - * - * @param { string } name Indicates the name used to identify the count. - * @param { number } count Indicates the number of the count. - * @syscap SystemCapability.HiviewDFX.HiTrace - * @atomicservice - * @since 19 - */ - export function traceByValue(name: string, count: number): void; - - /** - * Records a trace marking it as the start of a task. - * - * 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 #finishSyncTrace}, called by the same thread with the same level. - * - * @param { HiTraceOutputLevel } level Indicates trace output priority level. - * @param { string } name Indicates the task name. - * @param { string } customArgs Indicates key=value pair to be output in trace; multiple pairs should use comma - * as separator. - * @syscap SystemCapability.HiviewDFX.HiTrace - * @atomicservice - * @since 19 - */ - export function startSyncTrace(level: HiTraceOutputLevel, name: string, customArgs?: string): void; - - /** - * 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 the nearest running task tracked by - * startSyncTrace that has yet to be marked by finishSyncTrace, has ended. - * This method must be invoked after {@link #startSyncTrace}, called by the same thread with the same level. - * - * @param { HiTraceOutputLevel } level Indicates trace output priority level. - * @syscap SystemCapability.HiviewDFX.HiTrace - * @atomicservice - * @since 19 - */ - export function finishSyncTrace(level: HiTraceOutputLevel): void; - - /** - * Records a trace marking it as the start of a task. - * - * 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 a - * corresponding {@link #finishAsyncTrace}, with the same level, name, and taskId. - * - * @param { HiTraceOutputLevel } level Indicates trace output priority level. - * @param { string } name Indicates the task name. - * @param { number } taskId The unique id used to distinguish the task and match with the id of the - * corresponding finishAsyncTrace. - * @param { string } customCategory Indicates the label to aggregate asynchronous task display. - * @param { string } customArgs Indicates key=value pair to be output in trace; multiple pairs should use comma - * as Separator. - * @syscap SystemCapability.HiviewDFX.HiTrace - * @atomicservice - * @since 19 - */ - export function startAsyncTrace(level: HiTraceOutputLevel, name: string, taskId: number, customCategory: string, - customArgs?: string): void; - - /** - * 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 {@link #startAsyncTrace}, with the same level, name, - * and taskId. It is not required to be invoked by the same thread calling startAsyncTrace. - * - * @param { HiTraceOutputLevel } level Indicates trace output priority level. - * @param { string } name Indicates the task name. - * @param { number } taskId The unique id used to distinguish the task and match with the id of the corresponding - * startAsyncTrace. - * @syscap SystemCapability.HiviewDFX.HiTrace - * @atomicservice - * @since 19 - */ - export function finishAsyncTrace(level: HiTraceOutputLevel, name: string, taskId: number): void; - - /** - * Records a trace for generating a count, such as clock pulse and the number of layers. - * - * @param { HiTraceOutputLevel } level Indicates trace output priority level. - * @param { string } name Indicates the name used to identify the count. - * @param { number } count Indicates the number of the count. - * @syscap SystemCapability.HiviewDFX.HiTrace - * @atomicservice - * @since 19 - */ - export function traceByValue(level: HiTraceOutputLevel, name: string, count: number): void; - - /** - * Return whether the current process is allowed to output trace. - * - * @returns { boolean } The status of whether the current process is allowed to output trace. - * @syscap SystemCapability.HiviewDFX.HiTrace - * @atomicservice - * @since 19 - */ - export function isTraceEnabled(): boolean; - -} - -export default hiTraceMeter; \ No newline at end of file diff --git a/api/@ohos.hiTraceMeter.d.ts b/api/@ohos.hiTraceMeter.d.ts index a203466d09..6b1a88c151 100644 --- a/api/@ohos.hiTraceMeter.d.ts +++ b/api/@ohos.hiTraceMeter.d.ts @@ -47,41 +47,95 @@ */ /** * Provides interfaces to trace a task for performance measure, the logs can be capture by the - * bytrace cmdline available on the device. + * hitrace cmdline on the device. * *

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

Example: * Track the beginning of a context: *

{@code
- * hiTraceMeter.startTrace("checkName", 111);
+ * hiTraceMeter.startAsyncTrace(hiTraceMeter.HiTraceOutputLevel.COMMERCIAL, "checkName", 111, "test", "key=value");
  * }
* Track the end of a context: *
{@code
- * hiTraceMeter.finishTrace("checkName", 111);
+ * hiTraceMeter.finishAsyncTrace(hiTraceMeter.HiTraceOutputLevel.COMMERCIAL, "checkName", 111);
  * }
* To trace the number of layers, which is 3: *
{@code
- * hiTraceMeter.traceByValue("curLayer", 3);
+ * hiTraceMeter.traceByValue(hiTraceMeter.HiTraceOutputLevel.COMMERCIAL, "curLayer", 3);
+ * }
+ * + *

Each {@code startTrace} matches one {@code finishTrace}, and they must have the same name + * and taskId. + * + *

Each {@code startSyncTrace} matches one {@code finishSyncTrace}, and they must have the same + * level and name. + * + *

Each {@code startAsyncTrace} matches one {@code finishAsyncTrace}, and they must have the same + * level, name and taskId. + * + * @namespace hiTraceMeter + * @syscap SystemCapability.HiviewDFX.HiTrace + * @atomicservice + * @since 19 + */ +/** + * Provides interfaces to trace a task for performance measure, the logs can be capture by the + * hitrace cmdline on the device. + * + *

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

Example: + * Track the beginning of a context: + *

{@code
+ * hiTraceMeter.startAsyncTrace(hiTraceMeter.HiTraceOutputLevel.COMMERCIAL, "checkName", 111, "test", "key=value");
+ * }
+ * Track the end of a context: + *
{@code
+ * hiTraceMeter.finishAsyncTrace(hiTraceMeter.HiTraceOutputLevel.COMMERCIAL, "checkName", 111);
+ * }
+ * To trace the number of layers, which is 3: + *
{@code
+ * hiTraceMeter.traceByValue(hiTraceMeter.HiTraceOutputLevel.COMMERCIAL, "curLayer", 3);
  * }
* *

Each {@code startTrace} matches one {@code finishTrace}, and they must have the same name * and taskId. * + *

Each {@code startSyncTrace} matches one {@code finishSyncTrace}, and they must have the same + * level and name. + * + *

Each {@code startAsyncTrace} matches one {@code finishAsyncTrace}, and they must have the same + * level, name and taskId. + * * @namespace hiTraceMeter * @syscap SystemCapability.HiviewDFX.HiTrace + * @crossplatform * @atomicservice - * @since 18 + * @since 20 + * @arkts 1.1&1.2 */ declare namespace hiTraceMeter { /** - * Enumerates the HiTrace output levels. The output level threshold system parameter determines the minimum output trace. + * Enumerates the HiTrace output levels. The output level threshold system parameter determines + * the minimum output trace. + * + * @enum { number } + * @syscap SystemCapability.HiviewDFX.HiTrace + * @atomicservice + * @since 19 + */ + /** + * Enumerates the HiTrace output levels. The output level threshold system parameter determines + * the minimum output trace. * * @enum { number } * @syscap SystemCapability.HiviewDFX.HiTrace + * @crossplatform * @atomicservice - * @since 18 + * @since 20 + * @arkts 1.1&1.2 */ enum HiTraceOutputLevel { /** @@ -89,34 +143,70 @@ declare namespace hiTraceMeter { * * @syscap SystemCapability.HiviewDFX.HiTrace * @atomicservice - * @since 18 + * @since 19 + */ + /** + * Ouput level only for debug usage. + * + * @syscap SystemCapability.HiviewDFX.HiTrace + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.1&1.2 */ DEBUG = 0, /** - * Output level for beta version usage. + * Output level for log version usage. + * + * @syscap SystemCapability.HiviewDFX.HiTrace + * @atomicservice + * @since 19 + */ + /** + * Output level for log version usage. * * @syscap SystemCapability.HiviewDFX.HiTrace + * @crossplatform * @atomicservice - * @since 18 + * @since 20 + * @arkts 1.1&1.2 */ INFO = 1, /** - * Output level for beta version usage, with higher priority than INFO. + * Output level for log version usage, with higher priority than INFO. + * + * @syscap SystemCapability.HiviewDFX.HiTrace + * @atomicservice + * @since 19 + */ + /** + * Output level for log version usage, with higher priority than INFO. * * @syscap SystemCapability.HiviewDFX.HiTrace + * @crossplatform * @atomicservice - * @since 18 + * @since 20 + * @arkts 1.1&1.2 */ CRITICAL = 2, /** - * Output level for commercial version usage. + * Output level for nolog version usage. + * + * @syscap SystemCapability.HiviewDFX.HiTrace + * @atomicservice + * @since 19 + */ + /** + * Output level for nolog version usage. * * @syscap SystemCapability.HiviewDFX.HiTrace + * @crossplatform * @atomicservice - * @since 18 + * @since 20 + * @arkts 1.1&1.2 */ COMMERCIAL = 3, @@ -125,7 +215,16 @@ declare namespace hiTraceMeter { * * @syscap SystemCapability.HiviewDFX.HiTrace * @atomicservice - * @since 18 + * @since 19 + */ + /** + * Output level range limit. + * + * @syscap SystemCapability.HiviewDFX.HiTrace + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.1&1.2 */ MAX = COMMERCIAL } @@ -155,7 +254,23 @@ declare namespace hiTraceMeter { * @param { number } taskId The unique id used to distinguish the tasks and match with the id in follow finishTrace. * @syscap SystemCapability.HiviewDFX.HiTrace * @atomicservice - * @since 18 + * @since 19 + */ + /** + * 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. + * + * @param { string } name Indicates the task name. + * @param { number } taskId The unique id used to distinguish the tasks and match with the id in follow finishTrace. + * @syscap SystemCapability.HiviewDFX.HiTrace + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.1&1.2 */ function startTrace(name: string, taskId: number): void; @@ -175,14 +290,29 @@ declare namespace hiTraceMeter { * 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. + * is specified by {@code name}. This method must be invoked after {@link #startTrace}. * * @param { string } name Indicates the task name. It must be the same with the {@code name} of startTrace. - * @param { number } taskId The unique id used to distinguish the tasks and must be the same with the . + * @param { number } taskId The unique id used to distinguish the tasks and must be the same with the * {@code taskId} of startTrace. * @syscap SystemCapability.HiviewDFX.HiTrace * @atomicservice - * @since 18 + * @since 19 + */ + /** + * 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 {@link #startTrace}. + * + * @param { string } name Indicates the task name. It must be the same with the {@code name} of startTrace. + * @param { number } taskId The unique id used to distinguish the tasks and must be the same with the + * {@code taskId} of startTrace. + * @syscap SystemCapability.HiviewDFX.HiTrace + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.1&1.2 */ function finishTrace(name: string, taskId: number): void; @@ -201,7 +331,18 @@ declare namespace hiTraceMeter { * @param { number } count Indicates the number of the count. * @syscap SystemCapability.HiviewDFX.HiTrace * @atomicservice - * @since 18 + * @since 19 + */ + /** + * Records a trace for generating a count, such as clock pulse and the number of layers. + * + * @param { string } name Indicates the name used to identify the count. + * @param { number } count Indicates the number of the count. + * @syscap SystemCapability.HiviewDFX.HiTrace + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.1&1.2 */ function traceByValue(name: string, count: number): void; @@ -214,11 +355,28 @@ declare namespace hiTraceMeter { * * @param { HiTraceOutputLevel } level Indicates trace output priority level. * @param { string } name Indicates the task name. - * @param { string } customArgs Indicates key=value pair to be outputed in trace; multiple pairs should use comma - * as seperator. + * @param { string } [customArgs] Indicates key=value pair to be output in trace; multiple pairs should use comma + * as separator. + * @syscap SystemCapability.HiviewDFX.HiTrace + * @atomicservice + * @since 19 + */ + /** + * Records a trace marking it as the start of a task. + * + * 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 #finishSyncTrace}, called by the same thread with the same level. + * + * @param { HiTraceOutputLevel } level Indicates trace output priority level. + * @param { string } name Indicates the task name. + * @param { string } [customArgs] Indicates key=value pair to be output in trace; multiple pairs should use comma + * as separator. * @syscap SystemCapability.HiviewDFX.HiTrace + * @crossplatform * @atomicservice - * @since 18 + * @since 20 + * @arkts 1.1&1.2 */ function startSyncTrace(level: HiTraceOutputLevel, name: string, customArgs?: string): void; @@ -227,12 +385,26 @@ declare namespace hiTraceMeter { * * This method is invoked at the end of a transaction to indicate that the nearest running task tracked by * startSyncTrace that has yet to be marked by finishSyncTrace, has ended. - * This method must be invoked after the the {@link #startSyncTrace}, by the same thread. + * This method must be invoked after {@link #startSyncTrace}, called by the same thread with the same level. + * + * @param { HiTraceOutputLevel } level Indicates trace output priority level. + * @syscap SystemCapability.HiviewDFX.HiTrace + * @atomicservice + * @since 19 + */ + /** + * 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 the nearest running task tracked by + * startSyncTrace that has yet to be marked by finishSyncTrace, has ended. + * This method must be invoked after {@link #startSyncTrace}, called by the same thread with the same level. * * @param { HiTraceOutputLevel } level Indicates trace output priority level. * @syscap SystemCapability.HiviewDFX.HiTrace + * @crossplatform * @atomicservice - * @since 18 + * @since 20 + * @arkts 1.1&1.2 */ function finishSyncTrace(level: HiTraceOutputLevel): void; @@ -245,28 +417,69 @@ declare namespace hiTraceMeter { * * @param { HiTraceOutputLevel } level Indicates trace output priority level. * @param { string } name Indicates the task name. - * @param { number } taskId The unique id used to distinguish the task and match with the id of the corresponding finishAsyncTrace. + * @param { number } taskId The unique id used to distinguish the task and match with the id of the + * corresponding finishAsyncTrace. * @param { string } customCategory Indicates the label to aggregate asynchronous task display. - * @param { string } customArgs Indicates key=value pair to be outputed in trace; multiple pairs should use comma as seperator. + * @param { string } [customArgs] Indicates key=value pair to be output in trace; multiple pairs should use comma + * as Separator. * @syscap SystemCapability.HiviewDFX.HiTrace * @atomicservice - * @since 18 + * @since 19 */ - function startAsyncTrace(level: HiTraceOutputLevel, name: string, taskId: number, customCategory: string, customArgs?: string): void; + /** + * Records a trace marking it as the start of a task. + * + * 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 a + * corresponding {@link #finishAsyncTrace}, with the same level, name, and taskId. + * + * @param { HiTraceOutputLevel } level Indicates trace output priority level. + * @param { string } name Indicates the task name. + * @param { number } taskId The unique id used to distinguish the task and match with the id of the + * corresponding finishAsyncTrace. + * @param { string } customCategory Indicates the label to aggregate asynchronous task display. + * @param { string } [customArgs] Indicates key=value pair to be output in trace; multiple pairs should use comma + * as Separator. + * @syscap SystemCapability.HiviewDFX.HiTrace + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.1&1.2 + */ + function startAsyncTrace(level: HiTraceOutputLevel, name: string, taskId: number, customCategory: string, + customArgs?: string): void; /** * 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 {@link #startAsyncTrace}, with the same level, name, and taskId. - * It is not required to be invoked by the same thread calling startAsyncTrace. + * by {@code name}. This method must be invoked after {@link #startAsyncTrace}, with the same level, name, + * and taskId. It is not required to be invoked by the same thread calling startAsyncTrace. * * @param { HiTraceOutputLevel } level Indicates trace output priority level. * @param { string } name Indicates the task name. - * @param { number } taskId The unique id used to distinguish the task and match with the id of the corresponding startAsyncTrace. + * @param { number } taskId The unique id used to distinguish the task and match with the id of the corresponding + * startAsyncTrace. * @syscap SystemCapability.HiviewDFX.HiTrace * @atomicservice - * @since 18 + * @since 19 + */ + /** + * 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 {@link #startAsyncTrace}, with the same level, name, + * and taskId. It is not required to be invoked by the same thread calling startAsyncTrace. + * + * @param { HiTraceOutputLevel } level Indicates trace output priority level. + * @param { string } name Indicates the task name. + * @param { number } taskId The unique id used to distinguish the task and match with the id of the corresponding + * startAsyncTrace. + * @syscap SystemCapability.HiviewDFX.HiTrace + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.1&1.2 */ function finishAsyncTrace(level: HiTraceOutputLevel, name: string, taskId: number): void; @@ -278,7 +491,19 @@ declare namespace hiTraceMeter { * @param { number } count Indicates the number of the count. * @syscap SystemCapability.HiviewDFX.HiTrace * @atomicservice - * @since 18 + * @since 19 + */ + /** + * Records a trace for generating a count, such as clock pulse and the number of layers. + * + * @param { HiTraceOutputLevel } level Indicates trace output priority level. + * @param { string } name Indicates the name used to identify the count. + * @param { number } count Indicates the number of the count. + * @syscap SystemCapability.HiviewDFX.HiTrace + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.1&1.2 */ function traceByValue(level: HiTraceOutputLevel, name: string, count: number): void; @@ -288,10 +513,19 @@ declare namespace hiTraceMeter { * @returns { boolean } The status of whether the current process is allowed to output trace. * @syscap SystemCapability.HiviewDFX.HiTrace * @atomicservice - * @since 18 + * @since 19 + */ + /** + * Return whether the current process is allowed to output trace. + * + * @returns { boolean } The status of whether the current process is allowed to output trace. + * @syscap SystemCapability.HiviewDFX.HiTrace + * @crossplatform + * @atomicservice + * @since 20 + * @arkts 1.1&1.2 */ function isTraceEnabled(): boolean; - } export default hiTraceMeter; -- Gitee