setType() function is used to mark custom transaction as either web or background. The default type is web.

Add dependency before starting with the api.

pom.xml

<dependency>
    <groupId>com.atatus.apm</groupId>
    <artifactId>atatus-agent-api</artifactId>
    <version>2.0.0</version>
</dependency>

Compatibility

Compatible with all Java agent versions.

Syntax

copy
icon/buttons/copy
transaction.setType(type);

Parameter

Parameter Type Description
type Enum (Required) TYPE_REQUEST or TYPE_BACKGROUND_JOB

Example

copy
icon/buttons/copy
import com.atatus.apm.api.Atatus;
import com.atatus.apm.api.Transaction;

public class ViewController {

    public String invoke() {

        Transaction transaction = Atatus.startTransaction();
        // default is TYPE_REQUEST. For background transaction, type is TYPE_BACKGROUND_JOB.
        transaction.setType(transaction.TYPE_BACKGROUND_JOB);

        try {
            // Your code here...
        } catch (Exception ex) {
            // This sends an exception event to Atatus
            transaction.captureException(ex);
            throw ex;
        } finally {
            transaction.end();
        }
    }
}