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
96904b02
Commit
96904b02
authored
Aug 29, 2018
by
Sean McGivern
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ignore API requests in performance bar
These don't have performance data saved as they use Grape.
parent
e30e54b9
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
83 additions
and
6 deletions
+83
-6
app/assets/javascripts/performance_bar/services/performance_bar_service.js
...ripts/performance_bar/services/performance_bar_service.js
+15
-6
changelogs/unreleased/50801-error-getting-performance-bar-results-for-uuid.yml
.../50801-error-getting-performance-bar-results-for-uuid.yml
+5
-0
spec/javascripts/performance_bar/services/performance_bar_service_spec.js
.../performance_bar/services/performance_bar_service_spec.js
+63
-0
No files found.
app/assets/javascripts/performance_bar/services/performance_bar_service.js
View file @
96904b02
...
...
@@ -11,13 +11,10 @@ export default class PerformanceBarService {
static
registerInterceptor
(
peekUrl
,
callback
)
{
const
interceptor
=
response
=>
{
const
requestId
=
response
.
headers
[
'
x-request-id
'
];
// Get the request URL from response.config for Axios, and response for
// Vue Resource.
const
requestUrl
=
(
response
.
config
||
response
).
url
;
const
cachedResponse
=
response
.
headers
[
'
x-gitlab-from-cache
'
]
===
'
true
'
;
const
[
fireCallback
,
requestId
,
requestUrl
]
=
PerformanceBarService
.
callbackParams
(
response
,
peekUrl
);
if
(
requestUrl
!==
peekUrl
&&
requestId
&&
!
cachedResponse
)
{
if
(
fireCallback
)
{
callback
(
requestId
,
requestUrl
);
}
...
...
@@ -38,4 +35,16 @@ export default class PerformanceBarService {
vueResourceInterceptor
,
);
}
static
callbackParams
(
response
,
peekUrl
)
{
const
requestId
=
response
.
headers
&&
response
.
headers
[
'
x-request-id
'
];
// Get the request URL from response.config for Axios, and response for
// Vue Resource.
const
requestUrl
=
(
response
.
config
||
response
).
url
;
const
apiRequest
=
requestUrl
&&
requestUrl
.
match
(
/^
\/
api
\/
/
);
const
cachedResponse
=
response
.
headers
&&
response
.
headers
[
'
x-gitlab-from-cache
'
]
===
'
true
'
;
const
fireCallback
=
requestUrl
!==
peekUrl
&&
requestId
&&
!
apiRequest
&&
!
cachedResponse
;
return
[
fireCallback
,
requestId
,
requestUrl
];
}
}
changelogs/unreleased/50801-error-getting-performance-bar-results-for-uuid.yml
0 → 100644
View file @
96904b02
---
title
:
Don't show flash messages for performance bar errors
merge_request
:
21411
author
:
type
:
other
spec/javascripts/performance_bar/services/performance_bar_service_spec.js
0 → 100644
View file @
96904b02
import
PerformanceBarService
from
'
~/performance_bar/services/performance_bar_service
'
;
describe
(
'
PerformanceBarService
'
,
()
=>
{
describe
(
'
callbackParams
'
,
()
=>
{
describe
(
'
fireCallback
'
,
()
=>
{
function
fireCallback
(
response
,
peekUrl
)
{
return
PerformanceBarService
.
callbackParams
(
response
,
peekUrl
)[
0
];
}
it
(
'
returns false when the request URL is the peek URL
'
,
()
=>
{
expect
(
fireCallback
({
headers
:
{
'
x-request-id
'
:
'
123
'
},
url
:
'
/peek
'
},
'
/peek
'
))
.
toBeFalsy
();
});
it
(
'
returns false when there is no request ID
'
,
()
=>
{
expect
(
fireCallback
({
headers
:
{},
url
:
'
/request
'
},
'
/peek
'
))
.
toBeFalsy
();
});
it
(
'
returns false when the request is an API request
'
,
()
=>
{
expect
(
fireCallback
({
headers
:
{
'
x-request-id
'
:
'
123
'
},
url
:
'
/api/
'
},
'
/peek
'
))
.
toBeFalsy
();
});
it
(
'
returns false when the response is from the cache
'
,
()
=>
{
expect
(
fireCallback
({
headers
:
{
'
x-request-id
'
:
'
123
'
,
'
x-gitlab-from-cache
'
:
'
true
'
},
url
:
'
/request
'
},
'
/peek
'
))
.
toBeFalsy
();
});
it
(
'
returns true when all conditions are met
'
,
()
=>
{
expect
(
fireCallback
({
headers
:
{
'
x-request-id
'
:
'
123
'
},
url
:
'
/request
'
},
'
/peek
'
))
.
toBeTruthy
();
});
});
describe
(
'
requestId
'
,
()
=>
{
function
requestId
(
response
,
peekUrl
)
{
return
PerformanceBarService
.
callbackParams
(
response
,
peekUrl
)[
1
];
}
it
(
'
gets the request ID from the headers
'
,
()
=>
{
expect
(
requestId
({
headers
:
{
'
x-request-id
'
:
'
123
'
}
},
'
/peek
'
))
.
toEqual
(
'
123
'
);
});
});
describe
(
'
requestUrl
'
,
()
=>
{
function
requestUrl
(
response
,
peekUrl
)
{
return
PerformanceBarService
.
callbackParams
(
response
,
peekUrl
)[
2
];
}
it
(
'
gets the request URL from the response object
'
,
()
=>
{
expect
(
requestUrl
({
headers
:
{},
url
:
'
/request
'
},
'
/peek
'
))
.
toEqual
(
'
/request
'
);
});
it
(
'
gets the request URL from response.config if present
'
,
()
=>
{
expect
(
requestUrl
({
headers
:
{},
config
:
{
url
:
'
/config-url
'
},
url
:
'
/request
'
},
'
/peek
'
))
.
toEqual
(
'
/config-url
'
);
});
});
});
});
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