Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
0132dc4a
Commit
0132dc4a
authored
Apr 05, 2021
by
Quang-Minh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add more information into the frontend resources in performance bar
Issue
https://gitlab.com/groups/gitlab-org/-/epics/5590
parent
1e26f1e4
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
111 additions
and
11 deletions
+111
-11
app/assets/javascripts/performance_bar/components/detailed_metric.vue
...avascripts/performance_bar/components/detailed_metric.vue
+11
-5
app/assets/javascripts/performance_bar/index.js
app/assets/javascripts/performance_bar/index.js
+20
-6
spec/frontend/performance_bar/components/detailed_metric_spec.js
...ontend/performance_bar/components/detailed_metric_spec.js
+80
-0
No files found.
app/assets/javascripts/performance_bar/components/detailed_metric.vue
View file @
0132dc4a
...
...
@@ -54,11 +54,17 @@ export default {
return
this
.
currentRequest
.
details
[
this
.
metric
];
},
metricDetailsSummary
()
{
return
{
[
s__
(
'
Total
'
)]:
this
.
metricDetails
.
calls
,
[
s__
(
'
PerformanceBar|Total duration
'
)]:
this
.
metricDetails
.
duration
,
...(
this
.
metricDetails
.
summary
||
{}),
};
const
summary
=
{}
if
(
!
this
.
metricDetails
.
summaryOptions
||
!
this
.
metricDetails
.
summaryOptions
.
hideTotal
)
{
summary
[
s__
(
'
Total
'
)]
=
this
.
metricDetails
.
calls
}
if
(
!
this
.
metricDetails
.
summaryOptions
||
!
this
.
metricDetails
.
summaryOptions
.
hideDuration
)
{
summary
[
s__
(
'
PerformanceBar|Total duration
'
)]
=
this
.
metricDetails
.
duration
}
return
{...
summary
,
...(
this
.
metricDetails
.
summary
||
{})}
},
metricDetailsLabel
()
{
if
(
this
.
metricDetails
.
duration
&&
this
.
metricDetails
.
calls
)
{
...
...
app/assets/javascripts/performance_bar/index.js
View file @
0132dc4a
...
...
@@ -75,37 +75,51 @@ const initPerformanceBar = (el) => {
const
resourceEntries
=
performance
.
getEntriesByType
(
'
resource
'
);
let
durationString
=
''
;
let
summary
=
{};
if
(
navigationEntries
.
length
>
0
)
{
durationString
=
`
${
Math
.
round
(
navigationEntries
[
0
].
responseEnd
)}
| `
;
durationString
+=
`
${
Math
.
round
(
paintEntries
[
1
].
startTime
)}
| `
;
durationString
+=
`
${
Math
.
round
(
navigationEntries
[
0
].
domContentLoadedEventEnd
)}
`
;
const
backend
=
Math
.
round
(
navigationEntries
[
0
].
responseEnd
);
const
firstContentfulPaint
=
Math
.
round
(
paintEntries
[
1
].
startTime
);
const
domContentLoaded
=
Math
.
round
(
navigationEntries
[
0
].
domContentLoadedEventEnd
);
summary
=
{
Backend
:
backend
,
'
First contentful paint
'
:
firstContentfulPaint
,
'
Dom content loaded
'
:
domContentLoaded
,
};
durationString
=
`
${
backend
}
|
${
firstContentfulPaint
}
|
${
domContentLoaded
}
`
;
}
let
newEntries
=
resourceEntries
.
map
(
this
.
transformResourceEntry
);
this
.
updateFrontendPerformanceMetrics
(
durationString
,
newEntries
);
this
.
updateFrontendPerformanceMetrics
(
durationString
,
summary
,
newEntries
);
if
(
'
PerformanceObserver
'
in
window
)
{
// We start observing for more incoming timings
const
observer
=
new
PerformanceObserver
((
list
)
=>
{
newEntries
=
newEntries
.
concat
(
list
.
getEntries
().
map
(
this
.
transformResourceEntry
));
this
.
updateFrontendPerformanceMetrics
(
durationString
,
newEntries
);
this
.
updateFrontendPerformanceMetrics
(
durationString
,
summary
,
newEntries
);
});
observer
.
observe
({
entryTypes
:
[
'
resource
'
]
});
}
}
},
updateFrontendPerformanceMetrics
(
durationString
,
requestEntries
)
{
updateFrontendPerformanceMetrics
(
durationString
,
summary
,
requestEntries
)
{
this
.
store
.
setRequestDetailsData
(
this
.
requestId
,
'
total
'
,
{
duration
:
durationString
,
calls
:
requestEntries
.
length
,
details
:
requestEntries
,
summaryOptions
:
{
hideDuration
:
true
,
},
summary
,
});
},
transformResourceEntry
(
entry
)
{
const
nf
=
new
Intl
.
NumberFormat
();
return
{
start
:
entry
.
startTime
,
name
:
entry
.
name
.
replace
(
document
.
location
.
origin
,
''
),
duration
:
Math
.
round
(
entry
.
duration
),
size
:
entry
.
transferSize
?
`
${
nf
.
format
(
entry
.
transferSize
)}
bytes`
:
'
cached
'
,
...
...
spec/frontend/performance_bar/components/detailed_metric_spec.js
View file @
0132dc4a
...
...
@@ -120,6 +120,86 @@ describe('detailedMetric', () => {
});
});
describe
(
'
when the details have summaryOptions > hideTotal option
'
,
()
=>
{
beforeEach
(()
=>
{
createComponent
({
currentRequest
:
{
details
:
{
gitaly
:
{
duration
:
'
123ms
'
,
calls
:
456
,
details
:
requestDetails
,
warnings
:
[
'
gitaly calls: 456 over 30
'
],
summaryOptions
:
{
hideTotal
:
true
}
},
},
},
});
});
it
(
'
displays a summary section
'
,
()
=>
{
expect
(
findAllSummaryItems
()).
toEqual
([
'
Total duration 123ms
'
]);
});
});
describe
(
'
when the details have summaryOptions > hideDuration option
'
,
()
=>
{
beforeEach
(()
=>
{
createComponent
({
currentRequest
:
{
details
:
{
gitaly
:
{
duration
:
'
123ms
'
,
calls
:
456
,
details
:
requestDetails
,
warnings
:
[
'
gitaly calls: 456 over 30
'
],
summaryOptions
:
{
hideDuration
:
true
}
},
},
},
});
});
it
(
'
displays a summary section
'
,
()
=>
{
expect
(
findAllSummaryItems
()).
toEqual
([
'
Total 456
'
]);
});
});
describe
(
'
when the details have both summary and summaryOptions field
'
,
()
=>
{
beforeEach
(()
=>
{
createComponent
({
currentRequest
:
{
details
:
{
gitaly
:
{
duration
:
'
123ms
'
,
calls
:
456
,
details
:
requestDetails
,
warnings
:
[
'
gitaly calls: 456 over 30
'
],
summary
:
{
'
In controllers
'
:
100
,
'
In middlewares
'
:
20
,
},
summaryOptions
:
{
hideDuration
:
true
,
hideTotal
:
true
}
},
},
},
});
});
it
(
'
displays a summary section
'
,
()
=>
{
expect
(
findAllSummaryItems
()).
toEqual
([
'
In controllers 100
'
,
'
In middlewares 20
'
,
]);
});
});
describe
(
"
when the details don't have a start field
"
,
()
=>
{
beforeEach
(()
=>
{
createComponent
({
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment