mvantastic
mvantastic

Reputation: 57

How to measure response times of API calls?

I have implemented an API in Spring Boot which does all the RESTful calls successfully.

As an extra credit part of the assignment, I am required to track response time of all the calls to the RESTful service and be able to visualise the data on a line graph.

They suggested using grafana which I have downloaded.

I'm just not sure on how I would be able to track the response time of each call

Upvotes: 2

Views: 6172

Answers (1)

N3WOS
N3WOS

Reputation: 375

The response time can easily be tracked using the chrome debugger. enter image description here

If you want to compute the response time programmatically then it may be achieved by using the System.currentTimeMillis() method.

The following pseudo snippet may be helpful.

long beginTime = System.currentTimeMillis();

//your code to call the rest api

long responseTime = System.currentTimeMillis() - beginTime;

Upvotes: 4

Related Questions