Skip to content

Commit

Permalink
Avoid division by zero when calculating the average
Browse files Browse the repository at this point in the history
Related to #799

Signed-off-by: Alexander Schwartz <[email protected]>
  • Loading branch information
ahus1 committed May 6, 2024
1 parent 3c0ad5d commit 9a817d7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion .github/actions/prometheus-metrics-calc/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,11 @@ runs:
#calculating the number of xsite requests during the test execution
xsite_reqs_total_duration=$(awk "BEGIN {print ($num2-$num1); exit}")
#calculating the average duration per request in ms
averageXsiteReplicationTimePerReq=$(awk "BEGIN {print int($xsite_reqs_total_duration*1000/$xsite_reqs); exit}")
if [[ $xsite_reqs -gt 0 ]]; then
averageXsiteReplicationTimePerReq=$(awk "BEGIN {print int($xsite_reqs_total_duration*1000/$xsite_reqs); exit}")
else
averageXsiteReplicationTimePerReq=""
fi
#Putting metric into JSON
jq --arg cacheName "${{ inputs.ispnCacheName}}" --arg val "${averageXsiteReplicationTimePerReq}" --arg testName "${{ inputs.performedTestName }}" \
'.[$testName].ispnStatistics |= .+ {"cacheName": ($cacheName), "averageXsiteReplicationTime":($val|tonumber)}' ${HORREUM_OUTPUT_FILE_NAME} > tmp.json && \
Expand Down

0 comments on commit 9a817d7

Please sign in to comment.