Expand description
Raw bindings for the HiTrace tracing system on OpenHarmony
The official Hitrace NDK guidelines describe the available API. Rust users should likely not use this crate directly, but instead use an abstraction on top of this crate.
§Feature flags
§OpenHarmony API level
This crate by default exposes bindings for API-level 10.
Optionally enable one of the api-* features to get access to bindings for newer
OpenHarmony versions.
api-10(enabled by default) — No effect. API-10 bindings can’t be deselected. The feature exists for internal purposes.api-11— Enables bindings for OpenHarmony API-level 11 (No additions)api-12— Enables bindings for OpenHarmony API-level 12api-13— Enables bindings for OpenHarmony API-level 13 (No changes)api-14— Enables bindings for OpenHarmony API-level 14 (No changes)api-15— Enables bindings for OpenHarmony API-level 15 (No changes)api-16— Enables bindings for OpenHarmony API-level 16 (No changes).api-17— Enables bindings for OpenHarmony API-level 17 (No changes).api-18— Enables bindings for OpenHarmony API-level 18 (No changes).api-19— Enables bindings for OpenHarmony API-level 19. (No changes)api-20— Enables bindings for OpenHarmony API-level 20. (No changes)api-21— Enables bindings for OpenHarmony API-level 21.api-22— Enables bindings for OpenHarmony API-level 22.api-23— Enables bindings for OpenHarmony API-level 23.api-24— Enables bindings for OpenHarmony API-level 24 (No changes).api-25— Enables bindings for OpenHarmony API-level 25 (No changes).api-26— Enables bindings for OpenHarmony API-level 26 (No changes).
Structs§
- HiTrace
Id api-12 - Defines a HiTraceId instance.
- HiTrace
Id_ Valid api-12 - Enumerates whether a HiTraceId instance is valid.
- HiTrace_
Communication_ Mode api-12 - Enumerates the trace communication types.
- HiTrace_
Flag api-12 - Enumerates the HiTrace flags.
- HiTrace_
Output_ Level api-19 - Enumerates the HiTrace output levels. The trace output level lower than the threshold does not take effect. The log version threshold is HITRACE_LEVEL_INFO, and the nolog version threshold is HITRACE_LEVEL_COMMERCIAL.
- HiTrace_
Version api-12 - Enumerates the HiTrace versions.
- __
Bindgen Bitfield Unit
Enums§
- HiTrace_
Tracepoint_ Type api-12 - Enumerates the trace point types.
Functions§
- OH_
HiTrace_ ⚠Begin Chain api-12 - Starts tracing. If the current thread’s TLS does not contain a valid HiTrace ID, this function generates one, stores it in TLS, and returns it. If the current thread’s TLS already contains a valid HiTrace ID, this function does not start tracing and returns an invalid HiTrace ID with all property values being 0.
- OH_
HiTrace_ ⚠Clear Id api-12 - Clears the HiTrace ID in the current thread’s TLS.
- OH_
HiTrace_ ⚠Count Trace - Traces the value change of an integer variable based on its name. This API can be executed for multiple times to trace the value change of a given integer variable at different time points. Since API version 19, you are advised to use the OH_HiTrace_CountTraceEx() API to specify the trace output level.
- OH_
HiTrace_ ⚠Count Trace Ex api-19 - Marks an integer variable trace task with the trace output level specified.
- OH_
HiTrace_ ⚠Create Span api-12 - Creates a trace span. Specifically, create a HiTraceId, use the chainId and spanId in the TLS of the current thread to initialize the chainId and parentSpanId of the HiTraceId, generate a new spanId for the HiTraceId , and return the HiTraceId.
- OH_
HiTrace_ ⚠Enable Flag api-12 - Enables the trace flag specified in HiTraceId.
- OH_
HiTrace_ ⚠EndChain api-12 - Stops tracing.Stops tracing and sets the HiTrace ID in the TLS of the current thread to invalid.
- OH_
HiTrace_ ⚠Finish Async Trace - Marks the end of an asynchronous trace. This API is called in the callback function after an asynchronous trace is complete. It is used with OH_HiTrace_StartAsyncTrace() in pairs. Its name and task ID must be the same as those of ** OH_HiTrace_StartAsyncTrace()**. Since API version 19, you are advised to use the OH_HiTrace_FinishAsyncTraceEx() API to specify the trace output level.
- OH_
HiTrace_ ⚠Finish Async Trace Ex api-19 - Marks the end of an asynchronous trace task with the trace output level specified. This API is used to stop tracing after an asynchronous operation is complete, for example, in a callback function. It is used with OH_HiTrace_StartAsyncTraceEx() in pairs. Its level, name and task ID must be the same as those of OH_HiTrace_StartAsyncTraceEx().
- OH_
HiTrace_ ⚠Finish Trace - Marks the end of a synchronous trace. This API must be used with OH_HiTrace_StartTrace() in pairs. During trace parsing, the system matches it with the latest OH_HiTrace_StartTrace() API in the service process. Since API version 19, you are advised to use the OH_HiTrace_FinishTraceEx() API to specify the trace output level.
- OH_
HiTrace_ ⚠Finish Trace Ex api-19 - Marks the end of a synchronous trace task with the trace output level specified. It must be used with OH_HiTrace_StartTraceEx() in pairs. Its level must be the same as those of ** OH_HiTrace_StartTraceEx()**. During trace data parsing, the system matches it with the OH_HiTrace_StartTraceEx() API recently invoked in the service process.
- OH_
HiTrace_ ⚠GetChain Id api-12 - Obtains the trace chain ID in HiTraceId.
- OH_
HiTrace_ ⚠GetFlags api-12 - Obtains the trace flag set in HiTraceId.
- OH_
HiTrace_ ⚠GetId api-12 - Obtains the HiTrace ID in the TLS of the current thread.
- OH_
HiTrace_ ⚠GetParent Span Id api-12 - Obtains the parent span ID in HiTraceId.
- OH_
HiTrace_ ⚠GetSpan Id api-12 - Obtains the span ID in HiTraceId.
- OH_
HiTrace_ ⚠IdFrom Bytes api-12 - Creates a HiTraceId based on a byte array.
- OH_
HiTrace_ ⚠IdTo Bytes api-12 - Converts HiTraceId into a byte array for cache or communication.
- OH_
HiTrace_ ⚠Init Id api-12 - Initializes a HiTraceId.
- OH_
HiTrace_ ⚠IsFlag Enabled api-12 - Checks whether the trace flag is enabled for the HiTraceId.
- OH_
HiTrace_ ⚠IsId Valid api-12 - Checks whether the HiTraceId is valid.
- OH_
HiTrace_ ⚠IsTrace Enabled api-19 - Checks whether trace capture is enabled for an application.
- OH_
HiTrace_ ⚠Register Trace Listener api-22 - Registers a callback to notify whether the application trace capture is enabled. This API uses a synchronous callback to return the result.
- OH_
HiTrace_ ⚠SetChain Id api-12 - Sets the trace chain ID in HiTraceId.
- OH_
HiTrace_ ⚠SetFlags api-12 - Sets the trace flag to
HiTraceId. - OH_
HiTrace_ ⚠SetId api-12 - Sets the given HiTrace ID to the TLS of the current thread. If the given HiTrace ID is invalid, no operation is performed.
- OH_
HiTrace_ ⚠SetParent Span Id api-12 - Sets the ParentSpanId in a HiTraceId instance.
- OH_
HiTrace_ ⚠SetSpan Id api-12 - Sets the span ID in HiTraceId.
- OH_
HiTrace_ ⚠Start Async Trace - Marks the start of an asynchronous trace. This API is used to start tracing before an asynchronous operation. The start and end of an asynchronous trace do not occur in sequence. Therefore, a unique task ID is required to identify them. It must be used with OH_HiTrace_FinishAsyncTrace() in pairs. The start and end identified by the same name and task ID constitute an asynchronous trace task. If multiple trace tasks with the same name need to be performed at the same time or a trace task needs to be performed multiple times concurrently, different task IDs must be specified. If the trace tasks with the same name are not performed at the same time, the same taskId can be used. Since API version 19, you are advised to use the OH_HiTrace_StartAsyncTraceEx() API to specify the trace output level and category.
- OH_
HiTrace_ ⚠Start Async Trace Ex api-19 - Marks the start of an asynchronous trace task with the trace output level specified. This API is used to start tracing before an asynchronous operation. The start and end of an asynchronous trace do not occur in sequence. Therefore, a unique task ID is required to identify them. It is used with OH_HiTrace_FinishAsyncTraceEx() in pairs. The start and end identified by the same name and task ID constitute an asynchronous trace task. If multiple trace tasks with the same name need to be performed at the same time or a trace task needs to be performed multiple times concurrently, different task IDs must be specified. If the trace tasks with the same name are not performed at the same time, the same taskId can be used. Task IDs of different processes does not interfere with each other.
- OH_
HiTrace_ ⚠Start Trace - Marks the start of a synchronous trace. This API is used with OH_HiTrace_FinishTrace() in pairs. The two APIs can be nested. The stack data structure is used for matching during trace parsing. Since API version 19, you are advised to use the OH_HiTrace_StartTraceEx() API to specify the trace output level.
- OH_
HiTrace_ ⚠Start Trace Ex api-19 - Marks the start of a synchronous trace task with the trace output level specified. This API is used with OH_HiTrace_FinishTraceEx() in pairs. The two APIs can be nested. The stack data structure is used for matching during trace parsing.
- OH_
HiTrace_ ⚠Tracepoint api-12 - Adds a trace point for the HiTraceMeter logging. When type is set to HITRACE_TP_CS and HITRACE_TP_SR, the HiTraceMeter tracing starts. When type is set to HITRACE_TP_CR and HITRACE_TP_SS, the HiTraceMeter tracing ends. When type is set to ** HITRACE_TP_GENERAL**, the HiTraceMeter tracing does not start. The tracing points of HITRACE_TP_CS and HITRACE_TP_CR must be used in pairs; the tracing points of ** HITRACE_TP_SR** and HITRACE_TP_SS must be used in pairs. Otherwise, the start and end trace points of HiTraceMeter cannot match each other.
- OH_
HiTrace_ ⚠Unregister Trace Listener api-22 - Unregisters the callback used to notify whether the application trace capture is enabled.
You can use this function to unregister the callback function associated with the callback index returned by
OH_HiTrace_RegisterTraceListener.
Type Aliases§
- OH_
HiTrace_ Trace Event Listener api-22 - Defines a callback to listen for whether the trace capture is enabled.