Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow tracing of request durations #186

Closed
bkircher opened this issue Mar 8, 2021 · 4 comments
Closed

Allow tracing of request durations #186

bkircher opened this issue Mar 8, 2021 · 4 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@bkircher
Copy link
Contributor

bkircher commented Mar 8, 2021

Something that would be nice to have in gsclient-go is a way to easily trace how long an API call needs from request → to fulfillment.

With fulfillment I mean: I'm not interested in timings for each individual API call (e.g. HTTP request → HTTP response) but rather in "create storage" → "storage created"; how long did this take?

I thought about specifying a log-level in the client configuration, e.g., TRACE (or whatever logrus is using). This log-level should only be used for tracing the individual requests and their timings. One line per API request, printed when the request has finished. Output format should be JSON so that it can be processed further easily.

Example: If log level is set to TRACE, you would see something like this on stderr:

{
  "message": "Finished request CreateStorage",
  "requestId": "d8260ce6-7439-4543-85c4-794592a34346",
  "request": "CreateStorage",
  "success": true,
  "timeMs": 3042
}

timeMs is the time in milliseconds that has elapsed. success would be false when this errors, but I would still see timeMs.

What do you guys think? @fkr @nvthongswansea

@bkircher bkircher added discussion Things that need a decision enhancement New feature or request labels Mar 8, 2021
@nvthongswansea
Copy link
Contributor

Good idea 👍

@bkircher
Copy link
Contributor Author

bkircher commented Mar 9, 2021

Let's put this on our plate then

@bkircher bkircher removed the discussion Things that need a decision label Mar 9, 2021
@bkircher bkircher added this to the v3.4.1 milestone Mar 9, 2021
@nvthongswansea
Copy link
Contributor

@fkr @bkircher I've just figured out an interesting thing.
image
we can see that the GetServer() method takes around 1,5 second to finish, while the time it takes to get a response is 0,5 second => we spend around 1 second to do other stuff. Guess what? it because we wait before running the targetFunc (in this case the targetFunc is the function that sends the HTTP request); this affects the successful targetFunc badly.
image
So the line 47 in the image should be moved to the post-execution of the targetFunc.
Result:
image

@bkircher
Copy link
Contributor Author

Looks good, @nvthongswansea . Can you add a small example on how to enable tracing request timings to the README? With example output and how to interpret the value?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants