HomeDocumentationAPI Reference
Getting StartedAPI ReferenceBug ReportingCrash ReportingAPMHelp Center

Start Custom Trace

You can start a custom trace using the following APIs while passing a string that defines the name of the trace.

// Start a trace
let trace = APM.startExecutionTrace(withName: "name")
// Start a trace
IBGExecutionTrace *trace = [IBGAPM startExecutionTraceWithName:@"name"];
// Start a trace
ExecutionTrace trace = APM.startExecutionTrace("name");
// Start a trace
val trace: ExecutionTrace? = APM.startExecutionTrace("name")
// Approach #1
APM.startExecutionTrace('name')
.then(trace => {

  //
  // Your code goes here
  //
 
  trace.end();
})
.catch(error => {
  console.log(error);
});

// Approach #2
try {
  const trace = await APM.startExecutionTrace('name');

  //
  // Your code goes here
  //
 
  trace.end();
} catch (error) {
  console.log(error);
}
async {
    trace = await APM.startExecutionTrace('trace_name');
}