Home > OS >  Roll up output by endpoint name when they have unique ids for Locust.io
Roll up output by endpoint name when they have unique ids for Locust.io

Time:10-14

I have a task that has two posts requests. The first post request creates the parent and the second uses the key from the parent to create a child of that parent. However in the output, while all the parent post endpoints are rolled up, the child ones are not because they include the parent ID in the endpoint URL.

How can I have the output roll up by endpoint where it uses a placeholder for the id.

Parent Endpoint /v1/foo/bar

Child Endpoint /v1/foo/bar/{id}/upload

Actual

With the above examples, I get one line in the output for the parent and it shows the number of requests, failures, etc., and I get one line for each child request. So if the parent has 50 requests on it I will have 50 separate lines one for each child request. Something like this is what currently is in the output.

Type Name # Requests # Fails ...
POST /v1/foo/bar 3 0
POST /v1/foo/bar/1/upload 1 0
POST /v1/foo/bar/2/upload 1 0
POST /v1/foo/bar/3/upload 1 0

Would Like

I don't want the web or CLI output to show for each unique ID, just to be rolled up under one like shown with a placeholder. Something similar to this, but anything that shows the two lines with the counts matching is fine.

Type Name # Requests # Fails ...
POST /v1/foo/bar 3 0
POST /v1/foo/bar/{id}/upload 3 0

CodePudding user response:

When you make the request, you can pass in name='/v1/foo/bar/{id}/upload' and that's what Locust will report it as. From the docs:

Each of the methods for making requests also takes two additional optional arguments which are Locust specific and doesn’t exist in python-requests. These are:

Parameters:

name – (optional) An argument that can be specified to use as label in Locust’s statistics instead of the URL path. This can be used to group different URL’s that are requested into a single entry in Locust’s statistics.

  • Related