Skip to content
Permalink
Browse files
Time consuming builds detection
  • Loading branch information
dspavlov committed Jul 6, 2019
1 parent e0b4e78 commit f5c78023d3f95d791345d509c2e6232d6c28cea7
Show file tree
Hide file tree
Showing 6 changed files with 215 additions and 145 deletions.
@@ -0,0 +1,123 @@
<html>
<head>
<title>Apache Ignite Teamcity Bot - Build Time Analytics</title>
<link rel="icon" href="img/leaf-icon-png-7066.png">

<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">


<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>


<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<!-- production version, optimized for size and speed -->
<!--<script src="https://cdn.jsdelivr.net/npm/vue"></script>-->

<script src="https://cdn.jsdelivr.net/npm/vuetify/dist/vuetify.js"></script>
<link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900|Material+Icons" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/vuetify/dist/vuetify.min.css" rel="stylesheet">

<link rel="stylesheet" href="css/style-1.5.css">

<script src="js/common-1.6.js"></script>
<script>
$(document).ready(function() {
$.getScript("js/common-1.6.js", function(data, textStatus, jqxhr){ });

$( document ).tooltip();
loadData();
});

function loadAnalytics() {
let app = new Vue({
el: '#app',
data () {
return {
headers: [
{ text: 'Build Type', value: 'buildType' },
{ text: 'Average Duration', value: 'averageDuration' },
{ text: 'Duration', value: 'totalDuration' }
],
byBuildType: [
]
}
},
created () {
this.initialize()
},

methods: {
setBuildTimeStat(data) {
this.byBuildType = data.byBuildType;

$("#loadStatus").html("");
},
initialize() {
$.ajax({ url: "/rest/buildtime/analytics",
success: this.setBuildTimeStat,
error: showErrInLoadStatus });
}
}
})
}

function loadData() {
$("#loadStatus").html("<img src='https://www.wallies.com/filebin/images/loading_apple.gif' width=20px height=20px> Please wait");

$("#version").html(" " + "<a href=\"monitoring.html\">TC Bot Moniroting Page</a> <br>");
$.ajax({
url: "rest/branches/version",
success: showVersionInfo,
error: showErrInLoadStatus
});


loadAnalytics();
}


</script>
</head>
<body>

<div id="loadStatus"></div>


<div class="formgroup" id="app">
<v-app id="readyForReview">
<!--<v-expansion-panel>-->
<!--<v-expansion-panel-content-->
<!--v-for="(item,i) in 1"-->
<!--:key="i"-->
<!--&gt;-->
<template v-slot:header>
<div>Build types longest avg.duration</div>
</template>
<v-card>
<v-data-table
:headers="headers"
:items="byBuildType"
class="elevation-1"
>
<template v-slot:items="props">
<!--<td>-->
<!--<a :href="props.item.prHtmlUrl">{{ props.item.prNumber }} </a> {{ props.item.prTitle }}</td>-->
<!--<td class="text-xs-right">{{ props.item.b }}</td>-->
<!--<td class="text-xs-right">-->
<!--<img :src="props.item.prAuthorAvatarUrl" width='20px' height='20px'> {{ props.item.prAuthor }}</td>-->
<td class="text-xs-right">{{ props.item.buildType }}</td>
<td class="text-xs-right">{{ props.item.averageDuration }}</td>
<td class="text-xs-right">{{ props.item.totalDuration }}</td>
</template>
</v-data-table>
</v-card>
<!--</v-expansion-panel-content>-->
<!--</v-expansion-panel>-->

</v-app>
</div>

<div id="version"></div>
</body>
</html>
@@ -76,9 +76,10 @@ public BuildTimeResultUi analytics(ICredentialsProv prov) {

BuildTimeResultUi resultUi = new BuildTimeResultUi();

long minDuration = Duration.ofHours(1).toMillis();
long minDuration = Duration.ofMinutes(60).toMillis();
int cntToInclude = 50;
BuildTimeResult res = lastRes1d;
List<Map.Entry<Long, BuildTimeRecord>> entries = res.topByBuildTypes(availableServers, minDuration, 5);
List<Map.Entry<Long, BuildTimeRecord>> entries = res.topByBuildTypes(availableServers, minDuration, cntToInclude);

entries.forEach(e -> {
BuildTimeRecordUi buildTimeRecordUi = new BuildTimeRecordUi();
@@ -87,6 +88,8 @@ public BuildTimeResultUi analytics(ICredentialsProv prov) {
buildTimeRecordUi.buildType = compactor.getStringFromId(btId);

buildTimeRecordUi.averageDuration = TimeUtil.millisToDurationPrintable(e.getValue().avgDuration());
buildTimeRecordUi.totalDuration = TimeUtil.millisToDurationPrintable(e.getValue().totalDuration());

resultUi.byBuildType.add(buildTimeRecordUi);
});

@@ -554,6 +554,10 @@ public void addProblems(IStringCompactor compactor,
.forEach(this.problems::add);
}

public Long statisticValue(Integer propCode) {
return statistics == null ? null : statistics.statisticValue(propCode);
}

public Long buildDuration(IStringCompactor compactor) {
return statistics == null ? null : statistics.buildDuration(compactor);
}
@@ -711,4 +715,8 @@ public int totalNotMutedTests() {

return cnt;
}

public long getFinishDateTs() {
return finishDate;
}
}
@@ -29,6 +29,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.annotation.Nullable;

/**
* Statistics values to be saved in compacted form.
*/
@@ -85,10 +87,14 @@ public StatisticsCompacted(IStringCompactor compactor, Statistics statistics) {
public Long buildDuration(IStringCompactor compactor) {
Integer buildDurationId = compactor.getStringIdIfPresent(Statistics.BUILD_DURATION);

if (buildDurationId == null)
return statisticValue(buildDurationId);
}

@Nullable public Long statisticValue(@Nullable Integer propCode) {
if (propCode == null)
return null;

long val = findPropertyValue(buildDurationId);
long val = findPropertyValue(propCode);

return val >= 0 ? val : null;
}
@@ -100,12 +106,7 @@ public Long buildDuration(IStringCompactor compactor) {
public Long buildDurationNetTime(IStringCompactor compactor) {
Integer buildDurationNetId = compactor.getStringIdIfPresent(Statistics.BUILD_DURATION_NET_TIME);

if (buildDurationNetId == null)
return null;

long val = findPropertyValue(buildDurationNetId);

return val >= 0 ? val : null;
return statisticValue(buildDurationNetId);
}

/**
@@ -115,12 +116,7 @@ public Long buildDurationNetTime(IStringCompactor compactor) {
public Long artifcactPublishingDuration(IStringCompactor compactor) {
Integer buildDurationNetId = compactor.getStringIdIfPresent(Statistics.ARTIFACTS_PUBLISHING_DURATION);

if (buildDurationNetId == null)
return null;

long val = findPropertyValue(buildDurationNetId);

return val >= 0 ? val : null;
return statisticValue(buildDurationNetId);
}

/**
@@ -130,12 +126,7 @@ public Long artifcactPublishingDuration(IStringCompactor compactor) {
public Long dependeciesResolvingDuration(IStringCompactor compactor) {
Integer buildDurationNetId = compactor.getStringIdIfPresent(Statistics.DEPENDECIES_RESOLVING_DURATION);

if (buildDurationNetId == null)
return null;

long val = findPropertyValue(buildDurationNetId);

return val >= 0 ? val : null;
return statisticValue(buildDurationNetId);
}

/**
@@ -145,12 +136,7 @@ public Long dependeciesResolvingDuration(IStringCompactor compactor) {
public Long sourceUpdateDuration(IStringCompactor compactor) {
Integer buildDurationNetId = compactor.getStringIdIfPresent(Statistics.SOURCES_UPDATE_DURATION);

if (buildDurationNetId == null)
return null;

long val = findPropertyValue(buildDurationNetId);

return val >= 0 ? val : null;
return statisticValue(buildDurationNetId);
}

public long findPropertyValue(int propCode) {

0 comments on commit f5c7802

Please sign in to comment.