Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
renovate
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SmartDataLab
public
applications
renovate
Commits
31a1c116
Commit
31a1c116
authored
6 years ago
by
Rhys Arkins
Browse files
Options
Downloads
Patches
Plain Diff
feat(github): dump request stats per-repo
Closes #1516
parent
c13c4986
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/platform/github/gh-got-wrapper.js
+11
-0
11 additions, 0 deletions
lib/platform/github/gh-got-wrapper.js
with
11 additions
and
0 deletions
lib/platform/github/gh-got-wrapper.js
+
11
−
0
View file @
31a1c116
...
@@ -5,6 +5,7 @@ const parseLinkHeader = require('parse-link-header');
...
@@ -5,6 +5,7 @@ const parseLinkHeader = require('parse-link-header');
const
endpoints
=
require
(
'
../../util/endpoints
'
);
const
endpoints
=
require
(
'
../../util/endpoints
'
);
let
cache
=
{};
let
cache
=
{};
let
stats
=
{};
async
function
get
(
path
,
options
,
retries
=
5
)
{
async
function
get
(
path
,
options
,
retries
=
5
)
{
const
{
host
}
=
URL
.
parse
(
path
);
const
{
host
}
=
URL
.
parse
(
path
);
...
@@ -19,6 +20,7 @@ async function get(path, options, retries = 5) {
...
@@ -19,6 +20,7 @@ async function get(path, options, retries = 5) {
return
cache
[
path
];
return
cache
[
path
];
}
}
logger
.
debug
(
`
${
method
.
toUpperCase
()}
${
path
}
`
);
logger
.
debug
(
`
${
method
.
toUpperCase
()}
${
path
}
`
);
stats
.
requestCount
=
(
stats
.
requestCount
||
0
)
+
1
;
try
{
try
{
if
(
appMode
)
{
if
(
appMode
)
{
const
appAccept
=
'
application/vnd.github.machine-man-preview+json
'
;
const
appAccept
=
'
application/vnd.github.machine-man-preview+json
'
;
...
@@ -37,6 +39,10 @@ async function get(path, options, retries = 5) {
...
@@ -37,6 +39,10 @@ async function get(path, options, retries = 5) {
}
}
}
}
const
res
=
await
ghGot
(
path
,
opts
);
const
res
=
await
ghGot
(
path
,
opts
);
if
(
res
&&
res
.
headers
)
{
stats
.
rateLimit
=
res
.
headers
[
'
x-ratelimit-limit
'
];
stats
.
rateLimitRemaining
=
res
.
headers
[
'
x-ratelimit-remaining
'
];
}
if
(
opts
.
paginate
)
{
if
(
opts
.
paginate
)
{
// Check if result is paginated
// Check if result is paginated
const
pageLimit
=
opts
.
pageLimit
||
10
;
const
pageLimit
=
opts
.
pageLimit
||
10
;
...
@@ -181,6 +187,11 @@ get.setAppMode = function setAppMode(val) {
...
@@ -181,6 +187,11 @@ get.setAppMode = function setAppMode(val) {
get
.
reset
=
function
reset
()
{
get
.
reset
=
function
reset
()
{
cache
=
null
;
cache
=
null
;
cache
=
{};
cache
=
{};
// istanbul ignore if
if
(
stats
.
requestCount
)
{
logger
.
info
({
stats
},
'
Request stats
'
);
}
stats
=
{};
};
};
module
.
exports
=
get
;
module
.
exports
=
get
;
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment