Unlock Precise Method Timing with Cool Request’s New Trace Feature

The article introduces Cool Request, an IDEA plugin that now supports a Trace feature for measuring execution time of any method, automatic MyBatis function tracing, customizable duration coloring, and script-based environment manipulation, complete with usage examples and code snippets.

Java Tech Enthusiast
Java Tech Enthusiast
Java Tech Enthusiast
Unlock Precise Method Timing with Cool Request’s New Trace Feature

What Is Cool Request

Cool Request is an IDEA plugin for HTTP interface debugging that also offers powerful reflection capabilities, allowing you to bypass interceptors. It can invoke methods annotated with @Scheduled and integrate with xxl-job, making it a versatile tool for Java developers.

What Is Trace

Trace is a new feature that can record the execution time of any package except the core Java packages, which are excluded to avoid instability. When enabled, Trace automatically starts tracking from the controller method of a request.

Depth settings control how deep the tracking goes: depth 1 tracks only the controller method, depth 2 includes all methods called by the controller, depth 3 adds the next level of calls, and so on. Because static code analysis cannot resolve calls made through interfaces, very deep levels may miss some methods; you can manually add methods to the tracking list via a right‑click.

Automatic MyBatis Function Tracing

Trace can selectively monitor MyBatis execution functions—the final functions that run SQL statements. The UI shows the execution time (e.g., 7 ms) for each query, allowing developers to quickly spot slow database calls.

If you understand the source code, you can add any method to the trace list.

Displaying Call Count

The left‑hand side “+100” indicator shows that the current method was called 100 times during the trace, although per‑method duration is not yet aggregated.

Customizing Duration Colors

You can set a threshold (e.g., 5 ms) in the plugin settings; any method exceeding this threshold will be highlighted in red, making performance bottlenecks easy to spot.

Script‑Based Environment Manipulation

When an API requires authentication tokens in the request header, you can write a script under the corresponding interface to fetch the token, store it in an environment variable, and automatically add it to the header of subsequent requests.

The response body is usually JSON; you can parse it directly in the response script.

Calling Arbitrary Java Classes from Scripts

Cool Request allows scripts to invoke any class in your project, including third‑party libraries. For JSON handling, you can use the built‑in ObjectMapper (or Gson/Fastjson if available) without learning another language.

public void handlerResponse(ILog log, HTTPResponse response, IEnv env) {
    String body = new String(response.getResponseBody());
    log.println(body);
    User user = JSON.parseObject(body, User.class);
    log.println(user.getAge() + "");
}
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Performance MonitoringMyBatisIDEA PluginHTTP debuggingCool RequestJava tracing
Java Tech Enthusiast
Written by

Java Tech Enthusiast

Sharing computer programming language knowledge, focusing on Java fundamentals, data structures, related tools, Spring Cloud, IntelliJ IDEA... Book giveaways, red‑packet rewards and other perks await!

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.