Skip to content

Commit f65f2f1

Browse files
fix: span emit warnings on express instrumentation (#1891)
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 <[email protected]> Co-authored-by: Jamie Danielson <[email protected]>
1 parent 3156c94 commit f65f2f1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

plugins/node/opentelemetry-instrumentation-express/src/instrumentation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ export class ExpressInstrumentation extends InstrumentationBase<
280280
const isError = ![undefined, null, 'route', 'router'].includes(
281281
maybeError
282282
);
283-
if (isError) {
283+
if (!spanHasEnded && isError) {
284284
const [error, message] = asErrorAndMessage(maybeError);
285285
span.recordException(error);
286286
span.setStatus({

0 commit comments

Comments
 (0)