Skip to content

Commit

Permalink
fix: span emit warnings on express instrumentation (#1891)
Browse files Browse the repository at this point in the history
Fixes Can not execute the operation on ended Span on express-instrumentation #1887
This checks if the span has ended before attemptuing to mutate it by calling span.recordException(...) and span.setStatus(...)

Signed-off-by: San 'rdn' Mônico <san@monico.com.br>
Co-authored-by: Jamie Danielson <jamieedanielson@gmail.com>
  • Loading branch information
ReDemoNBR and JamieDanielson committed Jan 18, 2024
1 parent 3156c94 commit f65f2f1
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ export class ExpressInstrumentation extends InstrumentationBase<
const isError = ![undefined, null, 'route', 'router'].includes(
maybeError
);
if (isError) {
if (!spanHasEnded && isError) {
const [error, message] = asErrorAndMessage(maybeError);
span.recordException(error);
span.setStatus({
Expand Down

0 comments on commit f65f2f1

Please sign in to comment.