Skip to main content

Crate hitrace_sys

Crate hitrace_sys 

Source
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 12
  • api-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§

HiTraceIdapi-12
Defines a HiTraceId instance.
HiTraceId_Validapi-12
Enumerates whether a HiTraceId instance is valid.
HiTrace_Communication_Modeapi-12
Enumerates the trace communication types.
HiTrace_Flagapi-12
Enumerates the HiTrace flags.
HiTrace_Output_Levelapi-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_Versionapi-12
Enumerates the HiTrace versions.
__BindgenBitfieldUnit

Enums§

HiTrace_Tracepoint_Typeapi-12
Enumerates the trace point types.

Functions§

OH_HiTrace_BeginChain⚠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_ClearId⚠api-12
Clears the HiTrace ID in the current thread’s TLS.
OH_HiTrace_CountTrace⚠
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_CountTraceEx⚠api-19
Marks an integer variable trace task with the trace output level specified.
OH_HiTrace_CreateSpan⚠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_EnableFlag⚠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_FinishAsyncTrace⚠
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_FinishAsyncTraceEx⚠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_FinishTrace⚠
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_FinishTraceEx⚠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_GetChainId⚠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_GetParentSpanId⚠api-12
Obtains the parent span ID in HiTraceId.
OH_HiTrace_GetSpanId⚠api-12
Obtains the span ID in HiTraceId.
OH_HiTrace_IdFromBytes⚠api-12
Creates a HiTraceId based on a byte array.
OH_HiTrace_IdToBytes⚠api-12
Converts HiTraceId into a byte array for cache or communication.
OH_HiTrace_InitId⚠api-12
Initializes a HiTraceId.
OH_HiTrace_IsFlagEnabled⚠api-12
Checks whether the trace flag is enabled for the HiTraceId.
OH_HiTrace_IsIdValid⚠api-12
Checks whether the HiTraceId is valid.
OH_HiTrace_IsTraceEnabled⚠api-19
Checks whether trace capture is enabled for an application.
OH_HiTrace_RegisterTraceListener⚠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_SetChainId⚠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_SetParentSpanId⚠api-12
Sets the ParentSpanId in a HiTraceId instance.
OH_HiTrace_SetSpanId⚠api-12
Sets the span ID in HiTraceId.
OH_HiTrace_StartAsyncTrace⚠
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_StartAsyncTraceEx⚠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_StartTrace⚠
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_StartTraceEx⚠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_UnregisterTraceListener⚠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_TraceEventListenerapi-22
Defines a callback to listen for whether the trace capture is enabled.