wtysos11 / blogWiki

Use to store public paper and organize them.
18 stars 4 forks source link

gatling日志解析 #31

Open wtysos11 opened 4 years ago

wtysos11 commented 4 years ago

如何解析gatling的日志simulation.log是一个问题,目前的参考资料:

经过解析,确定了simulation.log的是在gatling/gatling › gatling-core/src/main/scala/io/gatling/core/stats/writer/LogFileDataWriter.scala处第42行定义并生成的。 其中具体的格式是在183行以后的Serializer定义并输出的。

wtysos11 commented 4 years ago

其中,我所要的响应时间应该为215行的ResponseMessageSerializer 定义:

class ResponseMessageSerializer(writer: BufferedFileChannelWriter) extends DataWriterMessageSerializer[ResponseMessage](writer, RequestRecordHeader.value)

其中日志形式如下: REQUEST 75302 send request 1588144435837 1588144435876 OK 因为每个用户只发送了一个包,所以直接截取一次请求的时间即可。

当前的目标是要弄明白该动作的两个值的单位是多少,因为我计算发现两个数之间的差值可以达到600,但我觉得不可能是600ms(prometheus监控到的应用响应时间约为14ms)。而且我需要弄清楚这个时间戳到底是从什么时候开始记时的,它不像是unix时间戳,因此无法直接转换。如果不弄清楚时间戳的起始时间,我将无法判断请求发送的具体时间,只能使用相对时间估算。

继续追踪,发现日志是在gatling-core/src/main/scala/io/gatling/core/stats/DataWritersStatsEngine.scala处完成ResponseMessage的赋值的,具体位置在101行的logResponse方法内。