Skip to content

Commit 7f8bb04

Browse files
authored
Merge pull request #2965 from devtron-labs/feat/app-deployment-metrics
feat: use dora metrics for app from service
2 parents a29704d + 00b5990 commit 7f8bb04

File tree

1 file changed

+35
-21
lines changed

1 file changed

+35
-21
lines changed

src/components/app/details/metrics/deploymentMetrics.service.ts

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,35 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { ChartColorKey, get } from '@devtron-labs/devtron-fe-common-lib'
17+
import { ChartColorKey, get, getUrlWithSearchParams } from '@devtron-labs/devtron-fe-common-lib'
1818
import moment from 'moment'
1919
import { Routes } from '../../../../config'
2020
import { BenchmarkType } from './deploymentMetrics.types'
2121

22-
export function getDeploymentMetrics(startTime, endTime, appId: string | number, envId: string | number): Promise<any> {
22+
export async function getDeploymentMetrics(
23+
startTime: string,
24+
endTime: string,
25+
appId: string | number,
26+
envId: string | number,
27+
): Promise<any> {
2328
startTime += 'Z'
2429
endTime += 'Z'
2530

26-
return get(`${Routes.DEPLOYMENT_METRICS}/?appId=${appId}&envId=${envId}&from=${startTime}&to=${endTime}`).then(
27-
(response) => {
28-
return {
29-
code: response.code,
30-
result: {
31-
...createGraphs(response.result, startTime, endTime),
32-
rows: createDeploymentTableRows(response.result, startTime, endTime),
33-
},
34-
}
31+
const url = getUrlWithSearchParams(Routes.DEPLOYMENT_METRICS, {
32+
appId,
33+
envId,
34+
from: startTime,
35+
to: endTime,
36+
})
37+
38+
const response = await get(url)
39+
return {
40+
...response,
41+
result: {
42+
...createGraphs(response.result, startTime, endTime),
43+
rows: createDeploymentTableRows(response.result, startTime, endTime),
3544
},
36-
)
45+
}
3746
}
3847

3948
export function createGraphs(responseResult, startTime: string, endTime: string) {
@@ -140,20 +149,25 @@ export function createGraphs(responseResult, startTime: string, endTime: string)
140149
const frequencies = frequencyGraph.map((f) => f.frequency)
141150
const frequencyBenchmark = getFrequencyBenchmark(avgFrequency)
142151
const maxFrequency = Math.max(...frequencies, frequencyBenchmark.targetValue)
152+
153+
const meanLeadTime = responseResult.average_lead_time
154+
const meanTimeToRecovery = responseResult.average_recovery_time
155+
const changeFailureRate = responseResult.change_failure_rate
156+
143157
const stats = {
144-
avgFrequency,
158+
avgFrequency: responseResult.average_cycle_time?.toFixed(2) || 0,
145159
totalDeployments: allDeployments.length,
146160
failedDeployments: recoveryTimeGraph.length,
147161
maxFrequency,
148162
frequencyBenchmark,
149-
meanLeadTimeLabel: `${createTimestamp(Math.floor(responseResult.average_lead_time))}`,
150-
meanLeadTime: responseResult.average_lead_time,
151-
leadTimeBenchmark: getLeadTimeBenchmark(responseResult.average_lead_time),
152-
meanRecoveryTime: `${sumRecoveryTime / recoveryTimeGraph.length}`,
153-
meanRecoveryTimeLabel: `${createTimestamp(sumRecoveryTime / recoveryTimeGraph.length)}`,
154-
recoveryTimeBenchmark: getRecoveryTimeBenchmark(sumRecoveryTime / recoveryTimeGraph.length),
155-
failureRate: Math.floor((100 * recoveryTimeGraph.length) / allDeployments.length) || 0,
156-
failureRateBenchmark: getFailureRateBenchmark((100 * recoveryTimeGraph.length) / allDeployments.length),
163+
meanLeadTimeLabel: createTimestamp(meanLeadTime),
164+
meanLeadTime,
165+
leadTimeBenchmark: getLeadTimeBenchmark(meanLeadTime),
166+
meanRecoveryTime: `${meanTimeToRecovery}`,
167+
meanRecoveryTimeLabel: createTimestamp(meanTimeToRecovery),
168+
recoveryTimeBenchmark: getRecoveryTimeBenchmark(meanTimeToRecovery),
169+
failureRate: changeFailureRate,
170+
failureRateBenchmark: getFailureRateBenchmark(changeFailureRate),
157171
}
158172

159173
return {

0 commit comments

Comments
 (0)