How to save Details about slow response

I wondering how in optimal way show details about slow responses after Simulation.

In my case every request have in header unique UUID and I want to show in any way all UUID where response time is bigger than definied limit.

I have think about that a while and I created below example:

import io.gatling.javaapi.core.ScenarioBuilder;
import io.gatling.javaapi.core.Simulation;
import io.gatling.javaapi.http.HttpProtocolBuilder;

import java.util.*;
import java.util.function.Supplier;
import java.util.stream.Stream;

import static io.gatling.javaapi.core.CoreDsl.*;
import static io.gatling.javaapi.http.HttpDsl.http;

public class Case0027SaveDetailsAboutSlowResponseSimulation extends Simulation {

    int TIME_LIMIT_TO_LOG = 700;
    List<String> listOfSlowUUIDs = new ArrayList<>();

    HttpProtocolBuilder httpProtocol =
            http
                    .baseUrl("https://postman-echo.com");

    Iterator<Map<String, Object>> feederUUID =
            Stream.generate((Supplier<Map<String, Object>>) () -> {
                        String uuidString = UUID.randomUUID().toString();
                        return Collections.singletonMap("uuidString", uuidString);
                    }
            ).iterator();

    ScenarioBuilder scn =
            scenario("GeMi_SaveDetailsAboutSlowResponseSimulation")
                    .feed(feederUUID)
                    .exec(
                            http("GeMi_SaveDetailsAboutSlowResponseSimulation_get")
                                    .get("/get?foo=#{uuidString}")
                                    .check(jmesPath("args.foo").isEL("#{uuidString}"))
                                    .check(responseTimeInMillis().saveAs("responseTimeInMillis"))
                    ).doIf(session -> session.getInt("responseTimeInMillis")>TIME_LIMIT_TO_LOG)
                        .then(
                                exec(session ->{
                                    listOfSlowUUIDs.add(session.getString("uuidString"));
                                    return session;
                                })
                        );
    {
        setUp(scn.injectOpen(atOnceUsers(10)).protocols(httpProtocol));
    }

    @Override
    public void after() {
        System.out.println("Simulation is finished!\nBelow list of Slow UUIDs:");
        listOfSlowUUIDs.forEach(System.out::println);
    }
}

WDYT @slandelle @sbrevet about that?
It’s optimal solution? :slight_smile:
PS. SOUT is only for example, there will be some kind of save to file.

Hi @GeMi ,

Sorry, but we can’t help with building custom analysis and reporting. These fall in the scope of Gatling Enterprise features.

Cheers

@slandelle thank you for information, I understand.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.