Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(express): use the same clock for span start and end #1210

Merged
merged 3 commits into from
Sep 28, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -263,22 +263,19 @@ export class ExpressInstrumentation extends InstrumentationBase<
);
}

const startTime = hrTime();
let spanHasEnded = false;
// If we found anything that isnt a middleware, there no point of measuring
// their time since they dont have callback.
if (
metadata.attributes[AttributeNames.EXPRESS_TYPE] !==
ExpressLayerType.MIDDLEWARE
) {
span.end(startTime);
span.end();
spanHasEnded = true;
}
// listener for response.on('finish')
const onResponseFinish = () => {
if (spanHasEnded === false) {
spanHasEnded = true;
span.end(startTime);
span.end();
}
};
// verify we have a callback
Expand Down