Skip to content

Commit

Permalink
ADM-983 [frontend][backend]: rename dev mean time to recovery and dev…
Browse files Browse the repository at this point in the history
… change failure rate to pipeline mean time to recovery and pipeline change failure rate
  • Loading branch information
zhou-yinyuan committed Jul 29, 2024
1 parent 3adb17f commit 6093183
Show file tree
Hide file tree
Showing 57 changed files with 595 additions and 544 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package heartbeat.controller.report.dto.request;

import lombok.Getter;

@Getter
public enum MetricEnum {

VELOCITY("velocity"), CYCLE_TIME("cycle time"), CLASSIFICATION("classification"),
DEPLOYMENT_FREQUENCY("deployment frequency"), DEV_CHANGE_FAILURE_RATE("dev change failure rate"),
DEV_MEAN_TIME_TO_RECOVERY("dev mean time to recovery"), LEAD_TIME_FOR_CHANGES("lead time for changes"),
DEPLOYMENT_FREQUENCY("deployment frequency"), PIPELINE_CHANGE_FAILURE_RATE("pipeline change failure rate"),
PIPELINE_MEAN_TIME_TO_RECOVERY("pipeline mean time to recovery"), LEAD_TIME_FOR_CHANGES("lead time for changes"),
REWORK_TIMES("rework times");

private final String value;
Expand All @@ -13,8 +16,4 @@ public enum MetricEnum {
this.value = value;
}

public String getValue() {
return value;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class AvgDevChangeFailureRate {
public class AvgPipelineChangeFailureRate {

@Builder.Default
private String name = "Average";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class AvgDevMeanTimeToRecovery {
public class AvgPipelineMeanTimeToRecovery {

@Builder.Default
private String name = "Total";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class DevChangeFailureRate {
public class PipelineChangeFailureRate {

private AvgDevChangeFailureRate avgDevChangeFailureRate;
private AvgPipelineChangeFailureRate avgPipelineChangeFailureRate;

private List<DevChangeFailureRateOfPipeline> devChangeFailureRateOfPipelines;
private List<PipelineChangeFailureRateOfPipeline> pipelineChangeFailureRateOfPipelines;

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class DevChangeFailureRateOfPipeline {
public class PipelineChangeFailureRateOfPipeline {

private String name;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class DevMeanTimeToRecovery {
public class PipelineMeanTimeToRecovery {

private AvgDevMeanTimeToRecovery avgDevMeanTimeToRecovery;
private AvgPipelineMeanTimeToRecovery avgPipelineMeanTimeToRecovery;

private List<DevMeanTimeToRecoveryOfPipeline> devMeanTimeToRecoveryOfPipelines;
private List<PipelineMeanTimeToRecoveryOfPipeline> pipelineMeanTimeToRecoveryOfPipelines;

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class DevMeanTimeToRecoveryOfPipeline {
public class PipelineMeanTimeToRecoveryOfPipeline {

private String name;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ public class ReportResponse {

private DeploymentFrequency deploymentFrequency;

private DevChangeFailureRate devChangeFailureRate;
private PipelineChangeFailureRate pipelineChangeFailureRate;

private DevMeanTimeToRecovery devMeanTimeToRecovery;
private PipelineMeanTimeToRecovery pipelineMeanTimeToRecovery;

private LeadTimeForChanges leadTimeForChanges;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import heartbeat.client.dto.pipeline.buildkite.BuildKiteBuildInfo;
import heartbeat.controller.report.dto.response.PipelineChangeFailureRateOfPipeline;
import heartbeat.controller.report.dto.response.PipelineMeanTimeToRecovery;
import heartbeat.repository.FilePrefixType;
import heartbeat.controller.board.dto.response.JiraCardDTO;
import heartbeat.controller.report.dto.request.ReportType;
import heartbeat.controller.report.dto.response.AvgDeploymentFrequency;
import heartbeat.controller.report.dto.response.AvgDevChangeFailureRate;
import heartbeat.controller.report.dto.response.AvgDevMeanTimeToRecovery;
import heartbeat.controller.report.dto.response.AvgPipelineChangeFailureRate;
import heartbeat.controller.report.dto.response.AvgPipelineMeanTimeToRecovery;
import heartbeat.controller.report.dto.response.AvgLeadTimeForChanges;
import heartbeat.controller.report.dto.response.BoardCSVConfig;
import heartbeat.controller.report.dto.response.BoardCSVConfigEnum;
Expand All @@ -18,10 +20,8 @@
import heartbeat.controller.report.dto.response.CycleTimeForSelectedStepItem;
import heartbeat.controller.report.dto.response.DeploymentFrequency;
import heartbeat.controller.report.dto.response.DeploymentFrequencyOfPipeline;
import heartbeat.controller.report.dto.response.DevChangeFailureRate;
import heartbeat.controller.report.dto.response.DevChangeFailureRateOfPipeline;
import heartbeat.controller.report.dto.response.DevMeanTimeToRecovery;
import heartbeat.controller.report.dto.response.DevMeanTimeToRecoveryOfPipeline;
import heartbeat.controller.report.dto.response.PipelineChangeFailureRate;
import heartbeat.controller.report.dto.response.PipelineMeanTimeToRecoveryOfPipeline;
import heartbeat.controller.report.dto.response.LeadTimeForChanges;
import heartbeat.controller.report.dto.response.LeadTimeForChangesOfPipelines;
import heartbeat.controller.report.dto.response.LeadTimeInfo;
Expand Down Expand Up @@ -367,13 +367,13 @@ private List<String[]> convertReportResponseToCSVRows(ReportResponse reportRespo
if (leadTimeForChanges != null)
rows.addAll(getRowsFromLeadTimeForChanges(leadTimeForChanges));

DevChangeFailureRate devChangeFailureRate = reportResponse.getDevChangeFailureRate();
if (devChangeFailureRate != null)
rows.addAll(getRowsFromDevChangeFailureRate(devChangeFailureRate));
PipelineChangeFailureRate pipelineChangeFailureRate = reportResponse.getPipelineChangeFailureRate();
if (pipelineChangeFailureRate != null)
rows.addAll(getRowsFromPipelineChangeFailureRate(pipelineChangeFailureRate));

DevMeanTimeToRecovery devMeanTimeToRecovery = reportResponse.getDevMeanTimeToRecovery();
if (devMeanTimeToRecovery != null)
rows.addAll(getRowsFromDevMeanTimeToRecovery(devMeanTimeToRecovery));
PipelineMeanTimeToRecovery pipelineMeanTimeToRecovery = reportResponse.getPipelineMeanTimeToRecovery();
if (pipelineMeanTimeToRecovery != null)
rows.addAll(getRowsFromPipelineMeanTimeToRecovery(pipelineMeanTimeToRecovery));

return rows;
}
Expand Down Expand Up @@ -520,38 +520,44 @@ private List<String[]> getRowsFromLeadTimeForChanges(LeadTimeForChanges leadTime
return rows;
}

private List<String[]> getRowsFromDevChangeFailureRate(DevChangeFailureRate devChangeFailureRate) {
private List<String[]> getRowsFromPipelineChangeFailureRate(PipelineChangeFailureRate pipelineChangeFailureRate) {
List<String[]> rows = new ArrayList<>();
List<DevChangeFailureRateOfPipeline> devChangeFailureRateOfPipelines = devChangeFailureRate
.getDevChangeFailureRateOfPipelines();
devChangeFailureRateOfPipelines.forEach(pipeline -> rows.add(new String[] { "Dev change failure rate",
pipeline.getName() + " / " + extractPipelineStep(pipeline.getStep()) + " / Dev change failure rate",
List<PipelineChangeFailureRateOfPipeline> pipelineChangeFailureRateOfPipelines = pipelineChangeFailureRate
.getPipelineChangeFailureRateOfPipelines();
pipelineChangeFailureRateOfPipelines.forEach(pipeline -> rows.add(new String[] { "Pipeline change failure rate",
pipeline.getName() + " / " + extractPipelineStep(pipeline.getStep())
+ " / Pipeline change failure rate",
DecimalUtil.formatDecimalFour(pipeline.getFailureRate()) }));

AvgDevChangeFailureRate avgDevChangeFailureRate = devChangeFailureRate.getAvgDevChangeFailureRate();
if (devChangeFailureRateOfPipelines.size() > 1)
rows.add(new String[] { "Dev change failure rate",
avgDevChangeFailureRate.getName() + " / Dev change failure rate",
DecimalUtil.formatDecimalTwo(avgDevChangeFailureRate.getFailureRate() * 100) });
AvgPipelineChangeFailureRate avgPipelineChangeFailureRate = pipelineChangeFailureRate
.getAvgPipelineChangeFailureRate();
if (pipelineChangeFailureRateOfPipelines.size() > 1)
rows.add(new String[] { "Pipeline change failure rate",
avgPipelineChangeFailureRate.getName() + " / Pipeline change failure rate",
DecimalUtil.formatDecimalTwo(avgPipelineChangeFailureRate.getFailureRate() * 100) });

return rows;
}

private List<String[]> getRowsFromDevMeanTimeToRecovery(DevMeanTimeToRecovery devMeanTimeToRecovery) {
private List<String[]> getRowsFromPipelineMeanTimeToRecovery(
PipelineMeanTimeToRecovery pipelineMeanTimeToRecovery) {
List<String[]> rows = new ArrayList<>();
List<DevMeanTimeToRecoveryOfPipeline> devMeanTimeToRecoveryOfPipelines = devMeanTimeToRecovery
.getDevMeanTimeToRecoveryOfPipelines();
devMeanTimeToRecoveryOfPipelines.forEach(pipeline -> rows.add(new String[] { "Dev mean time to recovery",
pipeline.getName() + " / " + extractPipelineStep(pipeline.getStep()) + " / Dev mean time to recovery",
DecimalUtil
.formatDecimalTwo(TimeUtils.millisToUnit(pipeline.getTimeToRecovery().doubleValue(), HOURS)) }));

AvgDevMeanTimeToRecovery avgDevMeanTimeToRecovery = devMeanTimeToRecovery.getAvgDevMeanTimeToRecovery();
if (devMeanTimeToRecoveryOfPipelines.size() > 1)
rows.add(new String[] { "Dev mean time to recovery",
avgDevMeanTimeToRecovery.getName() + " / Dev mean time to recovery",
List<PipelineMeanTimeToRecoveryOfPipeline> pipelineMeanTimeToRecoveryOfPipelines = pipelineMeanTimeToRecovery
.getPipelineMeanTimeToRecoveryOfPipelines();
pipelineMeanTimeToRecoveryOfPipelines
.forEach(pipeline -> rows.add(new String[] { "Pipeline mean time to recovery",
pipeline.getName() + " / " + extractPipelineStep(pipeline.getStep())
+ " / Pipeline mean time to recovery",
DecimalUtil.formatDecimalTwo(
TimeUtils.millisToUnit(pipeline.getTimeToRecovery().doubleValue(), HOURS)) }));

AvgPipelineMeanTimeToRecovery avgPipelineMeanTimeToRecovery = pipelineMeanTimeToRecovery
.getAvgPipelineMeanTimeToRecovery();
if (pipelineMeanTimeToRecoveryOfPipelines.size() > 1)
rows.add(new String[] { "Pipeline mean time to recovery",
avgPipelineMeanTimeToRecovery.getName() + " / Pipeline mean time to recovery",
DecimalUtil.formatDecimalTwo(TimeUtils
.millisToUnit(avgDevMeanTimeToRecovery.getTimeToRecovery().doubleValue(), HOURS)) });
.millisToUnit(avgPipelineMeanTimeToRecovery.getTimeToRecovery().doubleValue(), HOURS)) });

return rows;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
import heartbeat.service.report.calculator.ClassificationCalculator;
import heartbeat.service.report.calculator.CycleTimeCalculator;
import heartbeat.service.report.calculator.DeploymentFrequencyCalculator;
import heartbeat.service.report.calculator.DevChangeFailureRateCalculator;
import heartbeat.service.report.calculator.PipelineChangeFailureRateCalculator;
import heartbeat.service.report.calculator.LeadTimeForChangesCalculator;
import heartbeat.service.report.calculator.MeanToRecoveryCalculator;
import heartbeat.service.report.calculator.PipelineMeanToRecoveryCalculator;
import heartbeat.service.report.calculator.ReworkCalculator;
import heartbeat.service.report.calculator.VelocityCalculator;
import heartbeat.service.report.calculator.model.FetchedData;
Expand Down Expand Up @@ -60,9 +60,9 @@ public class GenerateReporterService {

private final DeploymentFrequencyCalculator deploymentFrequency;

private final DevChangeFailureRateCalculator devChangeFailureRate;
private final PipelineChangeFailureRateCalculator pipelineChangeFailureRate;

private final MeanToRecoveryCalculator meanToRecoveryCalculator;
private final PipelineMeanToRecoveryCalculator pipelineMeanToRecoveryCalculator;

private final CycleTimeCalculator cycleTimeCalculator;

Expand Down Expand Up @@ -184,9 +184,9 @@ private synchronized ReportResponse generatePipelineReporter(GenerateReportReque
deploymentFrequency.calculate(fetchedData.getBuildKiteData().getDeployTimesList(),
Long.parseLong(request.getStartTime()), Long.parseLong(request.getEndTime()),
request.getCalendarType(), request.getTimezoneByZoneId()));
case "dev change failure rate" -> reportResponse.setDevChangeFailureRate(
devChangeFailureRate.calculate(fetchedData.getBuildKiteData().getDeployTimesList()));
default -> reportResponse.setDevMeanTimeToRecovery(meanToRecoveryCalculator
case "pipeline change failure rate" -> reportResponse.setPipelineChangeFailureRate(
pipelineChangeFailureRate.calculate(fetchedData.getBuildKiteData().getDeployTimesList()));
default -> reportResponse.setPipelineMeanTimeToRecovery(pipelineMeanToRecoveryCalculator
.calculate(fetchedData.getBuildKiteData().getDeployTimesList(), request));
}
});
Expand Down Expand Up @@ -363,8 +363,10 @@ private ReportResponse getComposedReportResponse(String uuid, String timeRangeAn
.rework(getValueOrNull(boardReportResponse, ReportResponse::getRework))
.exportValidityTime(fileRepository.getExpiredTime())
.deploymentFrequency(getValueOrNull(pipelineReportResponse, ReportResponse::getDeploymentFrequency))
.devChangeFailureRate(getValueOrNull(pipelineReportResponse, ReportResponse::getDevChangeFailureRate))
.devMeanTimeToRecovery(getValueOrNull(pipelineReportResponse, ReportResponse::getDevMeanTimeToRecovery))
.pipelineChangeFailureRate(
getValueOrNull(pipelineReportResponse, ReportResponse::getPipelineChangeFailureRate))
.pipelineMeanTimeToRecovery(
getValueOrNull(pipelineReportResponse, ReportResponse::getPipelineMeanTimeToRecovery))
.leadTimeForChanges(getValueOrNull(sourceControlReportResponse, ReportResponse::getLeadTimeForChanges))
.boardMetricsCompleted(reportReadyStatus.boardMetricsCompleted())
.doraMetricsCompleted(reportReadyStatus.doraMetricsCompleted())
Expand Down

This file was deleted.

Loading

0 comments on commit 6093183

Please sign in to comment.