Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Collect errors with Gatling?

Tags:

gatling

In my long, but simple awesome Gatling simulation, I have few responses that ended with error 500. Is it possible to tell gatling to collect these error responses messages in a file during the simulation?

like image 858
igr Avatar asked Feb 05 '15 09:02

igr


2 Answers

No in production mode. You only have them when debug logging is enabled.

like image 169
Stephane Landelle Avatar answered Nov 18 '22 02:11

Stephane Landelle


It is possible to collect what ever you want and save it into simulation.log file. Use extraInfoExtractor method when you define protocol:

val httpProtocol = http
    .baseURL(url)
    .check(status.is(successStatus))
    .extraInfoExtractor { extraInfo => List(getExtraInfo(extraInfo)) }

Then define in your getExtraInfo(extraInfo: ExtraInfo) method whatever criteria you want. Example bellow outputs request and response in case of debug is enables via Java System Property OR response code is not 200 OR status of request is KO (it can be KO if you have setup some max time and this max time gets increased)

private val successStatus: Int = 200
private val isDebug = System.getProperty("debug").toBoolean   
private def getExtraInfo(extraInfo: ExtraInfo): String = {
    if (isDebug
        || extraInfo.response.statusCode.get != successStatus
        || extraInfo.status.eq(Status.valueOf("KO"))) {
        ",URL:" + extraInfo.request.getUrl +
            " Request: " + extraInfo.request.getStringData +
            " Response: " + extraInfo.response.body.string
    } else {
        ""
    }
}
like image 2
llatinov Avatar answered Nov 18 '22 01:11

llatinov