fix(medusa): Re throw error in instrumentation after reporting it (#11464)
FIXES FRMW-2914 **What** Currently, when the instrumentation is enabled, some instrument catches the errors in order to set the span status and info, unfortunately, these errors are not re throw leading to swallow them and return nothing in the end leading to potential breaks in flows
This commit is contained in:
committed by
GitHub
parent
e769c5afe3
commit
ceb99d073a
5
.changeset/wicked-roses-appear.md
Normal file
5
.changeset/wicked-roses-appear.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@medusajs/medusa": patch
|
||||
---
|
||||
|
||||
fix(medusa): Re throw error in instrumentation after reporting it
|
||||
@@ -148,14 +148,17 @@ export function instrumentRemoteQuery() {
|
||||
span.setAttributes({
|
||||
"query.fields": queryOptions.fields,
|
||||
})
|
||||
return await queryFn()
|
||||
.catch((error) => {
|
||||
span.setStatus({
|
||||
code: SpanStatusCode.ERROR,
|
||||
message: error.message,
|
||||
})
|
||||
try {
|
||||
return await queryFn()
|
||||
} catch (err) {
|
||||
span.setStatus({
|
||||
code: SpanStatusCode.ERROR,
|
||||
message: err.message,
|
||||
})
|
||||
.finally(() => span.end())
|
||||
throw err
|
||||
} finally {
|
||||
span.end()
|
||||
}
|
||||
}
|
||||
)
|
||||
})
|
||||
@@ -176,14 +179,18 @@ export function instrumentRemoteQuery() {
|
||||
span.setAttributes({
|
||||
"query.fields": "fields" in queryOptions ? queryOptions.fields : [],
|
||||
})
|
||||
return await queryFn()
|
||||
.catch((error) => {
|
||||
span.setStatus({
|
||||
code: SpanStatusCode.ERROR,
|
||||
message: error.message,
|
||||
})
|
||||
|
||||
try {
|
||||
return await queryFn()
|
||||
} catch (error) {
|
||||
span.setStatus({
|
||||
code: SpanStatusCode.ERROR,
|
||||
message: error.message,
|
||||
})
|
||||
.finally(() => span.end())
|
||||
throw error
|
||||
} finally {
|
||||
span.end()
|
||||
}
|
||||
}
|
||||
)
|
||||
})
|
||||
@@ -201,14 +208,18 @@ export function instrumentRemoteQuery() {
|
||||
"fetch.select": options.select,
|
||||
"fetch.relations": options.relations,
|
||||
})
|
||||
return await fetchFn()
|
||||
.catch((error) => {
|
||||
span.setStatus({
|
||||
code: SpanStatusCode.ERROR,
|
||||
message: error.message,
|
||||
})
|
||||
|
||||
try {
|
||||
return await fetchFn()
|
||||
} catch (error) {
|
||||
span.setStatus({
|
||||
code: SpanStatusCode.ERROR,
|
||||
message: error.message,
|
||||
})
|
||||
.finally(() => span.end())
|
||||
throw error
|
||||
} finally {
|
||||
span.end()
|
||||
}
|
||||
}
|
||||
)
|
||||
})
|
||||
@@ -251,6 +262,7 @@ export function instrumentWorkflows() {
|
||||
span.setAttribute(`workflow.step.${key}`, value)
|
||||
})
|
||||
|
||||
// TODO: should we report error and re throw it?
|
||||
return await stepHandler().finally(() => span.end())
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user