Skip to content

Commit

Permalink
Refactor MonitorResourceUtil to support ExecutionTime metric in synth…
Browse files Browse the repository at this point in the history
…etic monitors
  • Loading branch information
simlarsen committed Oct 29, 2024
1 parent 809f9a3 commit 9b35836
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 4 deletions.
30 changes: 30 additions & 0 deletions Common/Server/Utils/Monitor/MonitorResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,36 @@ export default class MonitorResourceUtil {
itemsToSave.push(monitorMetricsByMinute);
}

if (
(data.dataToProcess as ProbeMonitorResponse) &&
(data.dataToProcess as ProbeMonitorResponse).syntheticMonitorResponse &&
(
(data.dataToProcess as ProbeMonitorResponse).syntheticMonitorResponse ||
[]
).length > 0
) {
for (const syntheticMonitorResponse of (
data.dataToProcess as ProbeMonitorResponse
).syntheticMonitorResponse || []) {
const monitorMetricsByMinute: MonitorMetricsByMinute =
new MonitorMetricsByMinute();
monitorMetricsByMinute.monitorId = data.monitorId;
monitorMetricsByMinute.projectId = data.projectId;
monitorMetricsByMinute.metricType = CheckOn.ExecutionTime;
monitorMetricsByMinute.metricValue =
syntheticMonitorResponse.executionTimeInMS;
monitorMetricsByMinute.miscData = {
probeId: (
data.dataToProcess as ProbeMonitorResponse
).probeId.toString(),
browserType: syntheticMonitorResponse.browserType,
screenSizeType: syntheticMonitorResponse.screenSizeType,
};

itemsToSave.push(monitorMetricsByMinute);
}
}

if ((data.dataToProcess as ProbeMonitorResponse).responseTimeInMs) {
const monitorMetricsByMinute: MonitorMetricsByMinute =
new MonitorMetricsByMinute();
Expand Down
5 changes: 4 additions & 1 deletion Common/Types/Monitor/CriteriaFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,10 @@ export class CriteriaFilterUtil {
CheckOn.CPUUsagePercent,
CheckOn.MemoryUsagePercent,
];
} else if (monitorType === MonitorType.CustomJavaScriptCode) {
} else if (
monitorType === MonitorType.CustomJavaScriptCode ||
monitorType === MonitorType.SyntheticMonitor
) {
return [CheckOn.ExecutionTime];
}
return [];
Expand Down
16 changes: 13 additions & 3 deletions Dashboard/src/Components/Monitor/MonitorCharts/MonitorChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,11 @@ export class MonitorCharts {
miscData: MonitorMetricsMiscData | undefined;
probes: Array<Probe>;
}): string {
let seriesName: string = data.checkOn;

if (data.miscData) {
if (data.miscData.diskPath) {
return data.miscData.diskPath;
seriesName = data.miscData.diskPath;
}

if (data.miscData.probeId) {
Expand All @@ -100,12 +102,20 @@ export class MonitorCharts {
});

if (probe) {
return probe.name || "Probe";
seriesName = probe.name || "Probe";
}
}

if (data.miscData.browserType) {
seriesName += " " + data.miscData.browserType;
}

if (data.miscData.screenSizeType) {
seriesName += " (" + data.miscData.screenSizeType + ")";
}
}

return data.checkOn;
return seriesName;
}

public static getChartData(data: {
Expand Down

0 comments on commit 9b35836

Please sign in to comment.