Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
shields
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GitHub Mirror
shields.io
shields
Commits
9d31aa05
Unverified
Commit
9d31aa05
authored
8 months ago
by
Pierre-Yves Bigourdan
Committed by
GitHub
8 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Add CF-Ray header value to Sentry errors if available (#10339)
parent
e685b1a8
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
core/base-service/check-error-response.js
+13
-1
13 additions, 1 deletion
core/base-service/check-error-response.js
core/base-service/check-error-response.spec.js
+5
-1
5 additions, 1 deletion
core/base-service/check-error-response.spec.js
core/server/log.js
+4
-2
4 additions, 2 deletions
core/server/log.js
with
22 additions
and
4 deletions
core/base-service/check-error-response.js
+
13
−
1
View file @
9d31aa05
...
...
@@ -6,6 +6,8 @@ const defaultErrorMessages = {
429
:
'
rate limited by upstream service
'
,
}
const
headersToInclude
=
[
'
cf-ray
'
]
export
default
function
checkErrorResponse
(
httpErrors
=
{},
logErrors
=
[
429
])
{
return
async
function
({
buffer
,
res
})
{
let
error
...
...
@@ -28,7 +30,17 @@ export default function checkErrorResponse(httpErrors = {}, logErrors = [429]) {
}
if
(
logErrors
.
includes
(
res
.
statusCode
))
{
log
.
error
(
new
Error
(
`
${
res
.
statusCode
}
calling
${
res
.
requestUrl
.
origin
}
`
))
const
tags
=
{}
for
(
const
headerKey
of
headersToInclude
)
{
const
headerValue
=
res
.
headers
[
headerKey
]
if
(
headerValue
)
{
tags
[
`header-
${
headerKey
}
`
]
=
headerValue
}
}
log
.
error
(
new
Error
(
`
${
res
.
statusCode
}
calling
${
res
.
requestUrl
.
origin
}
`
),
tags
,
)
}
if
(
error
)
{
...
...
This diff is collapsed.
Click to expand it.
core/base-service/check-error-response.spec.js
+
5
−
1
View file @
9d31aa05
...
...
@@ -47,7 +47,11 @@ describe('async error handler', function () {
context
(
'
when status is 429
'
,
function
()
{
const
buffer
=
Buffer
.
from
(
'
some stuff
'
)
const
res
=
{
statusCode
:
429
,
requestUrl
:
new
URL
(
'
https://example.com/
'
)
}
const
res
=
{
statusCode
:
429
,
headers
:
{
'
some-key
'
:
'
some-value
'
},
requestUrl
:
new
URL
(
'
https://example.com/
'
),
}
it
(
'
throws InvalidResponse
'
,
async
function
()
{
try
{
...
...
This diff is collapsed.
Click to expand it.
core/server/log.js
+
4
−
2
View file @
9d31aa05
...
...
@@ -28,10 +28,12 @@ const log = (...msg) => {
console
.
log
(
d
,
...
msg
)
}
const
error
=
err
=>
{
const
error
=
(
err
,
tags
)
=>
{
const
d
=
date
()
listeners
.
forEach
(
f
=>
f
(
d
,
err
))
Sentry
.
captureException
(
err
)
Sentry
.
captureException
(
err
,
{
tags
,
})
console
.
error
(
d
,
err
)
}
...
...
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