HiTraceChain
-
-
-
-
-
-
-
- |
-HiTraceId Begin(const std::string& name, int flags)
- |
-Starts HiTraceChain, generates a HiTraceId object, and sets it in the TLS of the calling thread.
-Input arguments:
-- name: Indicates the name of the service process.
- flags: Indicates tracing flags, which can be used in combination.
- HITRACE_FLAG_INCLUDE_ASYNC: Traces both synchronous and asynchronous calls. By default, only synchronous calls are traced.
- HITRACE_FLAG_DONOT_CREATE_SPAN: Do not create a span. By default, a span is created.
- HITRACE_FLAG_TP_INFO: Outputs the tracepoint information. By default, the information is not output.
- HITRACE_FLAG_NO_BE_INFO: Do not output the start and end information. By default, the information is output.
- HITRACE_FLAG_DONOT_ENABLE_LOG: Do not associate logs for output. By default, logs are associated for output.
- HITRACE_FLAG_FAULT_TRIGGER: Triggers tracing by fault. By default, tracing is triggered normally.
- HITRACE_FLAG_D2D_TP_INFO: Outputs the device-to-device tracepoint information. By default, the information is not output.
- HITRCE_FLAG_DEFAULT: Indicates the default flag.
- - Output arguments: none
- Return value: Returns a valid HiTraceId object if call chain tracing is triggered successfully; returns an invalid object otherwise.
-Note: In nested tracing mode, an invalid object will be returned if tracing is started at the nested layer.
- |
-
-void End(const HiTraceId& id)
- |
-Stops HiTraceChain based on the HiTraceId object returned by the Begin API, and clears the HiTraceId object in the TLS of the calling thread.
-Input arguments:
-- id: Indicates the HiTraceId object.
-Output arguments: none
-Return value: none
- |
-
-HiTraceId GetId();
- |
-Obtains the HiTraceId object from the TLS of the calling thread.
-Input arguments: none
-Output arguments: none
-Return value: Returns the HiTraceId object in the contextual TLS of the calling thread.
- |
-
-void SetId(const HiTraceId& id)
- |
-Purpose: Sets the HiTraceId object in the TLS of the calling thread.
-Input arguments:
-- id: Indicates the HiTraceId object.
-Output arguments: none
-Return value: none
- |
-
-void ClearId()
- |
-Clears the HiTraceId object in the TLS of the current thread.
-Input arguments: none
-Output arguments: none
-Return value: none
- |
-
-HiTraceId CreateSpan()
- |
-Obtains the span ID from the current HiTraceId object.
-Input arguments: none
-Output arguments: none
-Return value: Returns the current span ID.
- |
-
-void Tracepoint(HiTraceTracepointType type, const HiTraceId& id, const char* fmt, ...)
- |
-Outputs HiTraceChain call chain information based on the information type. The information includes the timestamp and HiTraceId object information of the span.
-Input arguments:
-- type: Indicates the information type. The options are as follows:
- HITRACE_TP_CS: Client Send, which indicates the messages sent by the synchronous/asynchronous communication client.
- HITRACE_TP_SR: Server Receive, which indicates the messages received by the server in synchronous/asynchronous communication.
- HITRACE_TP_SS: Server Send, which indicates the response messages sent by the server in synchronous communication.
- HITRACE_TP_CR: Client Receive, which indicates the response messages received by the synchronous communication client.
- HITRACE_TP_GENERAL: Indicates the common output information.
- - id: Indicates the ID of the current span.
- fmt: Indicates the string describing the format variable parameter.
- args: Indicates the variable parameter.
-Output arguments: none
-Return value: none
- |
-
-void Tracepoint(HiTraceCommunicationMode mode, HiTraceTracepointType type, const HiTraceId& id, const char* fmt, ...)
- |
-Outputs HiTraceChain call chain information based on the communication mode and information type. The information includes the timestamp and HiTraceId object information of the span.
-Input arguments:
-- mode: Indicates the communication mode. The options are as follows:
- HITRACE_CM_DEFAULT: default communication mode used when no communication mode is specified
- HITRACE_CM_THREAD: inter-thread communication
- HITRACE_CM_PROCESS: inter-process communication
- HITRACE_CM_DEVICE: inter-device communication
- - type: Indicates the information type. The options are as follows:
- HITRACE_TP_CS: Client Send, which indicates the messages sent by the synchronous/asynchronous communication client.
- HITRACE_TP_SR: Server Receive, which indicates the messages received by the server in synchronous/asynchronous communication.
- HITRACE_TP_SS: Server Send, which indicates the response messages sent by the server in synchronous communication.
- HITRACE_TP_CR: Client Receive, which indicates the response messages received by the synchronous communication client.
- HITRACE_TP_GENERAL: Indicates the common output information.
- - id: Indicates the ID of the current span.
- fmt: Indicates the string describing the format variable parameter.
- args: Indicates the variable parameter.
-Output arguments: none
-Return value: none
- |
-
-HiTraceId
-
-
-
-
-
-
-
-
-
-
-
-
-
- |
-HiTraceId();
- |
-Represents the default constructor used to generate an invalid HiTraceId object.
-Input arguments: none
-Output arguments: none
-Return value: none
- |
-
-HiTraceId(const uint8_t* pIdArray, int len)
- |
-Represents the constructor used to create a HiTraceId object based on the specified byte array.
-Input arguments: - pIdArray: Indicates the pointer to a byte array.
- len: Indicates the length of the byte array.
-
-Output arguments: none
-Return value: none
- |
-
-bool IsValid()
- |
-Checks whether the HiTraceId object is valid.
-Input arguments: none
-Output arguments: none
-Return value: Returns true if the HiTraceId object is valid; returns false otherwise.
- |
-
-bool IsFlagEnabled(HiTraceFlag flag)
- |
-Checks whether the tracing flag of the HiTraceId object is enabled.
-Input arguments:
-- flag: Indicates the tracing flag. For details, see the description in the Begin function.
-Output arguments: none
-Return value: Returns true if the tracing flag is enabled; returns false otherwise.
- |
-
-void EnableFlag(HiTraceFlag flag)
- |
-Enables the tracing flag of the HiTraceId object.
-Input arguments:
-- flag: Indicates the tracing flag. For details, see the description in the Begin function.
-Output arguments: none
-Return value: none
- |
-
-int GetFlags()
- |
-Obtains the tracing flag set in the HiTraceId object.
-Input arguments: none
-Output arguments: none
-Return value: Returns the combination of tracing flags. For details, see the description in the Begin function.
- |
-
-void SetFlags(int flags)
- |
-Sets a tracing flag in the HiTraceId object.
-Input arguments:
-- flags: Indicates the combination of tracing flags. For details, see the description in the Begin function.
-Output arguments: none
-Return value: none
- |
-
-uint64_t GetChainId()
- |
-Obtains the call chain ID.
-Input arguments: none
-Output arguments: none
-Return value: Returns the call chain ID.
- |
-
-void SetChainId(uint64_t chainId)
- |
-Sets the call chain ID in the HiTraceId object.
-Input arguments:
-- chainId: Indicates the call chain ID.
-Output arguments: none
-Return value: none
- |
-
-uint64_t GetSpanId()
- |
-Obtains the span ID from the current HiTraceId object.
-Input arguments: none
-Output arguments: none
-Return value: Returns the current span ID.
- |
-
-void SetSpanId(uint64_t spanId)
- |
-Sets the span ID in the HiTraceId object.
-Input arguments:
-- spanId: Indicates the span ID.
-Output arguments: none
-Return value: none
- |
-
-uint64_t GetParentSpanId()
- |
-Obtains the parent span ID from the current HiTraceId object.
-Input arguments: none
-Output arguments: none
-Return value: Returns the parent span ID.
- |
-
-void SetParentSpanId(uint64_t parentSpanId)
- |
-Sets the parent span ID in the HiTraceId object.
-Input arguments:
-- parentSpanId: Indicates the parent span ID.
-Output arguments: none
-Return value: none
- |
-
-int ToBytes(uint8_t* pIdArray, int len)
- |
-Converts the HiTraceId object into a byte array to facilitate caching or communication transfer.
-Input arguments:
-- pIdArray: Indicates the pointer to a byte array. The minimum length of the byte array is HITRACE_ID_LEN.
- len: Indicates the length of the byte array.
-Output arguments
-- pIdArray: Indicates the pointer to a byte array. If the object is valid, the object data after conversion is stored.
-Return value: Returns a value greater than 0 (indicating a valid array of object data) if the conversion is successful; returns 0 otherwise.
- |
-
-
-