sentry-javascript icon indicating copy to clipboard operation
sentry-javascript copied to clipboard

Sentry Performance Metrics Cite Incorrect http Request Times

Open lux-capacitor opened this issue 1 year ago • 3 comments

Environment

SaaS (https://sentry.io/)

Steps to Reproduce

  1. Install sentry on any angular application and run it in production
  2. Ensure tracing is set to 100% so you capture everything
  3. Ensure you have Trace IDs being sent in http requests so you can verify that it is exactly the same one you are looking at in sentry
  4. Go to that application website and open the network tab - i used chrome and firefox to verify it happens regardless of browser
  5. Find the same page load in sentry and compare the times chromes network captured timing vs sentry

Expected Result

The timings should be nearly identical, if not somewhat close - if chrome network said a request took 125ms, I'd expect sentry to be at least close to that.

Actual Result

Sentry cites times 5x higher than any other network inspector. Each http timing metric is multiple times higher than any other tool checking network traffic timings I've found, making timing metrics from Sentry unreliable. I built a dashboard in Sentry to measure our apps timings from various regions and realized that even when I filter to a single transaction, that Sentry cites each http request as nearly 5x longer timing than both Checkly automation logging and manually checking requests in Chrome on a cache-free and incognito session browser were citing.

Attached is a screenshot of just one http request as a sample where the timing diverged, but it happens on every single http request - this is captured in the middle of a page load transaction, which did not get closed early or otherwise interrupted in any way, and got a 200 response. The timing difference is 5.6x higher than the reality in the Network inspector.

Left is sentry, Right is the Network Tab Image

Product Area

Performance

Link

No response

DSN

No response

Version

No response

lux-capacitor avatar Oct 11 '24 00:10 lux-capacitor

Assigning to @getsentry/support for routing ⏲️

getsantry[bot] avatar Oct 11 '24 00:10 getsantry[bot]

Routing to @getsentry/product-owners-performance for triage ⏲️

getsantry[bot] avatar Oct 11 '24 05:10 getsantry[bot]

Hey, these numbers will generally not be the same, because they are calculated in different ways - ours include some processing etc. and are based off monkey patching certain APIs. The difference you posted does feel especially large, though 🤔 To clarify, is this a fetch or XmlHttpRequest?

Also, could you give more information on your setup - what SDK and version are you using, and how does your Sentry.init() config look like?

I will transfer this issue to sentry-javascript repository, as this is more of an SDK question :)

mydea avatar Oct 15 '24 17:10 mydea

This specific request highlighted is a fetch request grabbing down a token to use with the app. For the most part the majority of the traffic is done via fetch requests.

Sentry Version Info :

"@sentry/angular": "^7.12.1",
"@sentry/tracing": "^7.12.1",

Sentry Init script: *Note - in here we are only sampling 100% of traces on specific test users for timing analysis from our various region-located test nodes, which is why the trace sampler is so codified.

if (environment.sentry.enable) {
  const userId = get(window, 'sessionUserId')
  const email = get(window, 'sessionUserEmail')
  const code = get(window, 'sessionClientCode')
  Sentry.setUser({
    id: userId,
    email,
    clientCode: code,
  })
  Sentry.init({
    dsn: environment.sentry.dsn,
    environment: `${environment.releaseStage || 'develop'}`,
    integrations: [
      new BrowserTracing({
        tracingOrigins: environment.sentry.hosts,
        routingInstrumentation: Sentry.routingInstrumentation,
        tracePropagationTargets: []
      }),
    ],
    tracesSampler: () => {
      if (environment.sentry.alwaysSampleUserEmails.includes(email.toLowerCase())) {
        return 1
      }
      return environment.sentry.traceSampleRate
    },
    sampleRate: environment.sentry.sampleRate || 0
  })
}

lux-capacitor avatar Oct 23 '24 16:10 lux-capacitor

Hello, I see that you are on v7 of the SDK. The current version is 8.35.0, can you try to upgrade with the Migration Guide? Also, @sentry/tracing is deprecated since 7.47.0. If upgrading to v8 is not possible, can you try upgrading to the latest version of v7 without using @sentry/tracing?

We are continuously improving the tracing functionality and your problem could've already been fixed by now.

s1gr1d avatar Oct 24 '24 08:10 s1gr1d

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you remove the label Waiting for: Community, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

getsantry[bot] avatar Nov 23 '24 08:11 getsantry[bot]