summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/pipelines/components/graph_shared
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-02-23 09:14:52 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-02-23 09:14:52 +0000
commit347bf09d6ecf4871da234c06ca8ee541e27b5105 (patch)
tree2ad6943e0c681c22acc8850d1debc6a983b0e006 /app/assets/javascripts/pipelines/components/graph_shared
parent0a51be0866d33273070f535257626a9eb2e10700 (diff)
downloadgitlab-ce-347bf09d6ecf4871da234c06ca8ee541e27b5105.tar.gz
Add latest changes from gitlab-org/gitlab@13-10-stable-eev13.10.0-rc20210223090520
Diffstat (limited to 'app/assets/javascripts/pipelines/components/graph_shared')
-rw-r--r--app/assets/javascripts/pipelines/components/graph_shared/api.js8
-rw-r--r--app/assets/javascripts/pipelines/components/graph_shared/links_inner.vue72
-rw-r--r--app/assets/javascripts/pipelines/components/graph_shared/links_layer.vue5
3 files changed, 84 insertions, 1 deletions
diff --git a/app/assets/javascripts/pipelines/components/graph_shared/api.js b/app/assets/javascripts/pipelines/components/graph_shared/api.js
new file mode 100644
index 00000000000..04ac15ae24c
--- /dev/null
+++ b/app/assets/javascripts/pipelines/components/graph_shared/api.js
@@ -0,0 +1,8 @@
+import axios from '~/lib/utils/axios_utils';
+import { reportToSentry } from '../graph/utils';
+
+export const reportPerformance = (path, stats) => {
+ axios.post(path, stats).catch((err) => {
+ reportToSentry('links_inner_perf', `error: ${err}`);
+ });
+};
diff --git a/app/assets/javascripts/pipelines/components/graph_shared/links_inner.vue b/app/assets/javascripts/pipelines/components/graph_shared/links_inner.vue
index 289e04e02c5..84ca0bf1443 100644
--- a/app/assets/javascripts/pipelines/components/graph_shared/links_inner.vue
+++ b/app/assets/javascripts/pipelines/components/graph_shared/links_inner.vue
@@ -1,8 +1,19 @@
<script>
import { isEmpty } from 'lodash';
+import {
+ PIPELINES_DETAIL_LINKS_MARK_CALCULATE_START,
+ PIPELINES_DETAIL_LINKS_MARK_CALCULATE_END,
+ PIPELINES_DETAIL_LINKS_MEASURE_CALCULATION,
+ PIPELINES_DETAIL_LINK_DURATION,
+ PIPELINES_DETAIL_LINKS_TOTAL,
+ PIPELINES_DETAIL_LINKS_JOB_RATIO,
+} from '~/performance/constants';
+import { performanceMarkAndMeasure } from '~/performance/utils';
import { DRAW_FAILURE } from '../../constants';
import { createJobsHash, generateJobNeedsDict } from '../../utils';
+import { reportToSentry } from '../graph/utils';
import { parseData } from '../parsing_utils';
+import { reportPerformance } from './api';
import { generateLinksData } from './drawing_utils';
export default {
@@ -25,6 +36,15 @@ export default {
type: Array,
required: true,
},
+ totalGroups: {
+ type: Number,
+ required: true,
+ },
+ metricsConfig: {
+ type: Object,
+ required: false,
+ default: () => ({}),
+ },
defaultLinkColor: {
type: String,
required: false,
@@ -43,6 +63,9 @@ export default {
};
},
computed: {
+ shouldCollectMetrics() {
+ return this.metricsConfig.collectMetrics && this.metricsConfig.path;
+ },
hasHighlightedJob() {
return Boolean(this.highlightedJob);
},
@@ -87,23 +110,70 @@ export default {
this.$emit('highlightedJobsChange', jobs);
},
},
+ errorCaptured(err, _vm, info) {
+ reportToSentry(this.$options.name, `error: ${err}, info: ${info}`);
+ },
mounted() {
if (!isEmpty(this.pipelineData)) {
this.prepareLinkData();
}
},
methods: {
+ beginPerfMeasure() {
+ if (this.shouldCollectMetrics) {
+ performanceMarkAndMeasure({ mark: PIPELINES_DETAIL_LINKS_MARK_CALCULATE_START });
+ }
+ },
+ finishPerfMeasureAndSend() {
+ if (this.shouldCollectMetrics) {
+ performanceMarkAndMeasure({
+ mark: PIPELINES_DETAIL_LINKS_MARK_CALCULATE_END,
+ measures: [
+ {
+ name: PIPELINES_DETAIL_LINKS_MEASURE_CALCULATION,
+ start: PIPELINES_DETAIL_LINKS_MARK_CALCULATE_START,
+ },
+ ],
+ });
+ }
+
+ window.requestAnimationFrame(() => {
+ const duration = window.performance.getEntriesByName(
+ PIPELINES_DETAIL_LINKS_MEASURE_CALCULATION,
+ )[0]?.duration;
+
+ if (!duration) {
+ return;
+ }
+
+ const data = {
+ histograms: [
+ { name: PIPELINES_DETAIL_LINK_DURATION, value: duration },
+ { name: PIPELINES_DETAIL_LINKS_TOTAL, value: this.links.length },
+ {
+ name: PIPELINES_DETAIL_LINKS_JOB_RATIO,
+ value: this.links.length / this.totalGroups,
+ },
+ ],
+ };
+
+ reportPerformance(this.metricsConfig.path, data);
+ });
+ },
isLinkHighlighted(linkRef) {
return this.highlightedLinks.includes(linkRef);
},
prepareLinkData() {
+ this.beginPerfMeasure();
try {
const arrayOfJobs = this.pipelineData.flatMap(({ groups }) => groups);
const parsedData = parseData(arrayOfJobs);
this.links = generateLinksData(parsedData, this.containerId, `-${this.pipelineId}`);
- } catch {
+ } catch (err) {
this.$emit('error', DRAW_FAILURE);
+ reportToSentry(this.$options.name, err);
}
+ this.finishPerfMeasureAndSend();
},
getLinkClasses(link) {
return [
diff --git a/app/assets/javascripts/pipelines/components/graph_shared/links_layer.vue b/app/assets/javascripts/pipelines/components/graph_shared/links_layer.vue
index 1c1bc7ecb2a..baf0a4d50de 100644
--- a/app/assets/javascripts/pipelines/components/graph_shared/links_layer.vue
+++ b/app/assets/javascripts/pipelines/components/graph_shared/links_layer.vue
@@ -1,6 +1,7 @@
<script>
import { GlAlert } from '@gitlab/ui';
import { __ } from '~/locale';
+import { reportToSentry } from '../graph/utils';
import LinksInner from './links_inner.vue';
export default {
@@ -50,6 +51,9 @@ export default {
);
},
},
+ errorCaptured(err, _vm, info) {
+ reportToSentry(this.$options.name, `error: ${err}, info: ${info}`);
+ },
methods: {
dismissAlert() {
this.alertDismissed = true;
@@ -66,6 +70,7 @@ export default {
v-if="showLinkedLayers"
:container-measurements="containerMeasurements"
:pipeline-data="pipelineData"
+ :total-groups="numGroups"
v-bind="$attrs"
v-on="$listeners"
>