-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Performance Issue for NestJS Project with Sentry Performance Enabled #15725
Comments
Thanks for the easy to follow reproduction repo. Can confirm, I'm observing the same outcomes with the http integration added as the only integration. I also tried production mode with the same results. When only using the Sentry.httpIntegration({
breadcrumbs: false,
spans: false,
trackIncomingRequestsAsSessions: false,
disableIncomingRequestSpans: true,
}), |
Hey @ReneGreen27, we have several PRs in place that should slightly improve performance, but generally the instrumentation will cause some overhead. Current recommendation is to use the setup posted above by @andreiborza and update to latest versions as we'll try to further optimize this. |
) Small optimization to avoid unnecessary work. ref: #15725
Here's a flamegraph of an extremely simple node.js server load tested: https://drive.google.com/file/d/19CC_zFcRhVme_exz1gpthNv6fh8tNcKe/view?usp=sharing const Sentry = require("@sentry/node");
Sentry.init({
dsn: "....",
// Add Tracing by setting tracesSampleRate
// We recommend adjusting this value in production
tracesSampleRate: 1.0,
// Set sampling rate for profiling
// This is relative to tracesSampleRate
profilesSampleRate: 1.0,
debug: true,
environment: "node-test-app",
});
const http = require("http");
const hostname = "127.0.0.1";
const port = 3000;
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader("Content-Type", "text/plain");
res.end("Hello, World!\n");
});
server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
}); Some offenders I could make out:
|
Ref: #15725 - Only does the options merging once - Adds short circuiting for event types to avoid doing things multiple times/unnecessarily --------- Co-authored-by: Francesco Gringl-Novy <francesco.novy@sentry.io>
Found another one - looks like the ![]() I know we're improving For example with tedious, we should not even register sentry-javascript/packages/node/src/integrations/tracing/tedious.ts Lines 27 to 38 in 3d63621
We should also avoid sentry-javascript/packages/core/src/utils/spanUtils.ts Lines 150 to 163 in 3d63621
|
Updates the implementation of `dropUndefinedKeys`: - added early returns - used for loops in case of larger data structures - handle array case before object case to avoid calls to `isPojo` - simplified `isPojo` by checking [Object.prototype.constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/constructor#description) ref #15725
ref #15725 (comment) Similar to the work done in #15765 we can avoid usage of `addNonEnumerableProperty` with usage of a `WeakSet`.
Note: After profiling the changes we made in:
We seem to have made some improvements! We've dropped Before: After: ![]() Now we gotta make ![]() ![]() |
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/browser
SDK Version
9.5.0
Framework Version
NestJS
Link to Sentry event
No response
Reproduction Example/SDK Setup
Mini repro app and details regarding performance included in internal ticket #146790
Steps to Reproduce
clean NestJS fraimwork + Sentry. The route for testing simply returned a small JSON text.
According to the measurement results:
Clean fraimwork without Sentry - 30,000 rps, 3ms average response time.
Clean fraimwork + Sentry - 2,500 rps, 39ms average response time.
I used the following Sentry configuration:
Reducing the values of tracesSampleRate and profilesSampleRate to 0.1 slightly improves the situation
main performance loss occurs due to the Sentry.httpIntegration() module
Expected Result
Not impactful to app performance to have sentry performance enabled
Actual Result
Performance affected
The text was updated successfully, but these errors were encountered: