Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,32 @@ public void requestMoneyTransfer(int sourceUserId, int targetUserId, int amount)
**Sample output:**
> public void requestMoneyTransfer(int sourceUserId, int targetUserId, int amount) - Args: [sourceUserId={1}, targetUserId={2}, amount={3000}] - 1037 ms ¤ [Threshold Exceed !!: 200 ms]



## Block Tracking with `TimerNinjaBlock`

TimerNinjaBlock allows you to measure arbitrary code blocks within a method without extracting separate methods. This is perfect for tracking specific phases or operations inside a method.

### Basic Usage

```java
public void processOrder(Order order) {
// Regular code not tracked

TimerNinjaBlock.measure("database query", () -> {
database.query("SELECT * FROM orders WHERE id = " + order.getId());
});

// More code not tracked
}
```

Use TimerNinjaBlock for granular tracking within a method without creating separate tracked methods.

For more advanced block tracking usage, see the [User Guide Wiki](https://github.com/thanglequoc/timer-ninja/wiki/User-Guide#block-tracking).



## Reading the time trace output
Once the method is executed, you should be able to find the result similar to this one in the output/log

Expand All @@ -265,6 +291,10 @@ Any sequence execution of other annotated tracker methods inside the parent meth
`Trace timestamp`: The timestamp when the trace context is initiated, in UTC timezone.
`Begin-end of trace context`: The detailed execution time of each method. The `|--` sign indicate the call to this method originated from the above parent method, which help to visualize the execution stacktrace.


## User Guide
For comprehensive documentation, examples, and best practices on using the Timer-Ninja library efficiently, visit the [Wiki page](https://github.com/thanglequoc/timer-ninja/wiki/User-Guide).

## Troubleshooting
If you need to troubleshoot, you can toggle the `DEBUG` log level on logger `io.github.thanglequoc.timerninja.TimerNinjaThreadContext`.

Expand Down
Loading