Skip to content

Commit

Permalink
Added logic to save the error body only for failed requests (#81)
Browse files Browse the repository at this point in the history
Added logic to save the error body only for failed requests
  • Loading branch information
ushklianik authored Dec 6, 2022
1 parent 97b2d1a commit 2a0935a
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ public Point getPoint() {
* @param isToBeSaved set to true if body need to be saved; otherwise false.
* @return the normalized string if parameter @param isToBeSaved set to true; 'noData' string otherwise.
*/
private String getErrorBodyToBeSaved(boolean isToBeSaved)
private String getErrorBodyToBeSaved(boolean isToBeSaved, boolean isSuccessful)
{
String errorResponseBody;

if (isToBeSaved)
if (isToBeSaved && isSuccessful)
{
errorResponseBody = this.getErrorBody();
}
Expand Down Expand Up @@ -107,7 +107,7 @@ private Point getDefaultPoint() {
.addTag(RequestMeasurement.Tags.RESULT_CODE, this.sampleResultContext.getSampleResult().getResponseCode())
.addTag(RequestMeasurement.Tags.ERROR_MSG, this.getAssertionFailure())
.addTag(RequestMeasurement.Tags.SAMPLE_TYPE, this.sampleResultContext.getSamplerType())
.addTag(RequestMeasurement.Tags.ERROR_RESPONSE_BODY, this.getErrorBodyToBeSaved(this.sampleResultContext.isErrorBodyToBeSaved()))
.addTag(RequestMeasurement.Tags.ERROR_RESPONSE_BODY, this.getErrorBodyToBeSaved(this.sampleResultContext.isErrorBodyToBeSaved(), !this.sampleResultContext.getSampleResult().isSuccessful()))
.addField(RequestMeasurement.Fields.ERROR_COUNT, this.sampleResultContext.getSampleResult().getErrorCount())
.addField(RequestMeasurement.Fields.REQUEST_COUNT, this.sampleResultContext.getSampleResult().getSampleCount())
.addField(RequestMeasurement.Fields.RECEIVED_BYTES, this.sampleResultContext.getSampleResult().getBytesAsLong())
Expand Down

0 comments on commit 2a0935a

Please sign in to comment.