Overview

API Introduction

The Trace module provides C++ APIs for Trace data monitoring.

For details about the functions and usage examples of the Trace APIs, see msServiceProfiler Trace Data Monitoring.

Header file: ${INSTALL_DIR}/include/msServiceProfiler/Tracer.h

Library file: ${INSTALL_DIR}/lib64/libms_service_profiler.so

Replace ${INSTALL_DIR} with the CANN component directory. For example, if the installation is performed by the root user, the default file storage path is /usr/local/Ascend/cann.

APIs

The APIs are as follows.

Table 1 Trace APIs (C++)

API

Description

TraceContext Class

Manages thread-level Trace information as the Trace context management class.

GetTraceCtx

Obtains the Trace context instance of the current thread.

addResAttribute

Adds global resource attributes.

ExtractAndAttach

Parses HTTP Trace information and adds it to the current context.

Attach

Adds Trace information to the current context.

Unattach

Cancels the Trace context of a specified index.

GetCurrent

Obtains the current Trace context.

Span Class

Represents a specific operation or request.

Span

Creates a Span.

Activate

Activates a Span and starts timing.

SetAttribute

Sets the Span attributes.

SetStatus

Sets the Span status.

End

Ends a Span.

Tracer Class

Provides APIs for creating Spans.

StartSpanAsActive

Creates and activates a Span.

IsEnable

Checks whether the Trace function is enabled.