# What are transactions on Dr. Droid?

### Definition

A transaction is defined as the transition of a joining key pk\_1 from an initial state (primary event) **tnx\_initiated** to a terminal state (secondary event) **tnx\_completed**.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1689974934787/121bb3f0-4649-4a4d-9600-8117d3789bb3.png align="center")

### Why Transactions?

Transactions help you track the behaviour of your application in the context of the goals it is trying to achieve. Consider an example of a [3rd party payment provider API](https://notes.drdroid.io/how-to-monitor-asynchronous-3rd-party-integrations-proactively) which is a part of your product journey. While it’s important to be able to track the error rate of outgoing API and webhook callbacks by the vendor, tracking [relative behaviour](https://notes.drdroid.io/how-to-track-events-across-multiple-services) helps identify anomalies faster.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1689974948222/284f5860-838a-431b-a32e-40fc9c7d498c.avif align="center")

### Transactions vs events-based metrics:

The key benefit of using “transaction” instead of tracking start and completion separately using 2 different markers is that the correlation is easily tracked. If you do not have any common key between the two states, the only next best option is to add [custom metrics](https://notes.drdroid.io/what-are-custom-metrics-how-to-track-them-with-doctor-droid) at the individual checkpoints.

### Unique Properties of a Transaction:

Compared to individual events, here are some properties, unique to a transaction:

1. **Transaction time:** The time to go from primary state to secondary state in a transaction.
    
2. **Transaction status:** Active or Finished, depending on whether it has reached the terminal state or not.
    
3. **Transaction triggers:** Rule-based alert configured on the transaction time, status or any other attribute associated with the transaction
    

### What can you do with transactions?

Once you define a transaction, here are some out-of-the-box capabilities that we provide:

1. Alert rules on transactions success rate:
    
    1. You can configure triggers on transaction success/failure rates, at both aggregate levels as well as individual transactions. Read more about triggers and their details [here](https://docs.drdroid.io/docs/trigger-examples).
        
        ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1689975826686/7bb8428e-bb8d-4569-9a11-dcb9e3004fa2.png align="center")
        
2. Track metrics related to the transaction and any of its associated attributes:
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1689975031414/c0bbf50c-0a56-45fd-8463-ce2734456768.png align="center")
    
3. Filter transactions
    
    1. What are the currently active transactions?
        
    2. Search transactions by any variable, irrespective of whether they are in the primary event or secondary event
        
        ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1689975036778/bc2de986-567b-41eb-9f16-ad2293c9ffb9.png align="center")
        

To get started with setting up a transaction, click [here](https://app.drdroid.io/signup).
