in dotTrace-server/src/main/java/jetbrains/buildServer/dotTrace/server/DotTraceStatisticTranslator.java [52:102]
public List<BuildMessage1> translate(@NotNull final SRunningBuild runningBuild, @NotNull final BuildMessage1 buildMessage, @NotNull final ServiceMessage serviceMessage) {
List<BuildMessage1> messages = new Vector<BuildMessage1>(Collections.singleton(buildMessage));
final StatisticMessage statisticMessage = StatisticMessage.tryParse(serviceMessage);
if(statisticMessage == null) {
return messages;
}
final SBuildType buildType = runningBuild.getBuildType();
if(buildType == null) {
return messages;
}
final String methodName = statisticMessage.getMethodName();
final Statistic statistic = myStatisticProvider.tryCreateStatistic(statisticMessage, myHistory.getElements(buildType.getHistory()));
if(statistic != null) {
final BigDecimal prevTotalTime = statistic.getPrevTotalTime();
if (prevTotalTime != null && !myMetricComparer.isMeasuredValueWithinThresholds(prevTotalTime, statistic.getMeasuredTotalTime(), statistic.getTotalTimeThreshold())) {
final BigDecimal expectedValue = myMetricComparer.tryGetThresholdValue(prevTotalTime, statistic.getTotalTimeThreshold());
if(expectedValue != null) {
messages.add(
new BuildMessage1(
buildMessage.getSourceId(),
buildMessage.getTypeId(),
Status.FAILURE,
buildMessage.getTimestamp(),
createBuildMessageText(expectedValue, statistic.getMeasuredTotalTime(), methodName, TOTAL_TIME_THRESHOLD_NAME)));
}
}
final BigDecimal prevOwnTime = statistic.getPrevOwnTime();
if (prevOwnTime != null && !myMetricComparer.isMeasuredValueWithinThresholds(prevOwnTime, statistic.getMeasuredOwnTime(), statistic.getOwnTimeThreshold())) {
final BigDecimal expectedValue = myMetricComparer.tryGetThresholdValue(prevOwnTime, statistic.getOwnTimeThreshold());
if(expectedValue != null) {
messages.add(
new BuildMessage1(
buildMessage.getSourceId(),
buildMessage.getTypeId(),
Status.FAILURE,
buildMessage.getTimestamp(),
createBuildMessageText(expectedValue, statistic.getMeasuredOwnTime(), methodName, OWN_TIME_THRESHOLD_NAME)));
}
}
final long buildId = runningBuild.getBuildId();
myStorage.publishValue(myStatisticKeyFactory.createTotalTimeKey(methodName), buildId, statistic.getMeasuredTotalTime());
myStorage.publishValue(myStatisticKeyFactory.createOwnTimeKey(methodName), buildId, statistic.getMeasuredOwnTime());
}
return messages;
}