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

feat(node): Use `@opentelemetry/instrumentation-undici` for fetch tracing

Open timfish opened this issue 1 year ago • 2 comments

  • Closes #12402
  • Closes #12343

This PR migrates the nativeNodeFetchIntegration to use @opentelemetry/instrumentation-undici instead of opentelemetry-instrumentation-fetch-node.

This now gives us fetch instrumentation all the way back to Node v16.18. This PR also bumps the patch version of @opentelemetry/instrumentation-mongoose which was released at the same time.

There are a couple of outstanding issues:

  • For the outgoing fetch > outgoing sampled fetch requests without active span are correctly instrumented tests, the sentry-trace header has an extra -1 on the end. I have no idea what causes this!

  • For /api/v3 portion of the fetch-unsampled/test.ts and fetch-sampled-no-active-span/test.ts, it fails because the baggage header is not undefined as expected. As far as I can tell, SentryPropagator should be excluding these from header injection but it's not. I guess this is because @opentelemetry/instrumentation-undici is not setting the SEMATTRS_HTTP_URL attribute (http.url). Should the otel instrumentation be setting this or should we also be checking for SemanticAttributes.URL_FULL attribute (url.full) which it already sets? Here are the attributes it is already setting.

timfish avatar Aug 27 '24 22:08 timfish

size-limit report 📦

Path Size % Change Change
@sentry/browser 22.52 KB - -
@sentry/browser - with treeshaking flags 21.3 KB - -
@sentry/browser (incl. Tracing) 34.78 KB - -
@sentry/browser (incl. Tracing, Replay) 71.23 KB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 61.67 KB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 75.57 KB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 88.3 KB - -
@sentry/browser (incl. Tracing, Replay, Feedback, metrics) 90.14 KB - -
@sentry/browser (incl. metrics) 26.83 KB - -
@sentry/browser (incl. Feedback) 39.6 KB - -
@sentry/browser (incl. sendFeedback) 27.19 KB - -
@sentry/browser (incl. FeedbackAsync) 31.9 KB - -
@sentry/react 25.28 KB - -
@sentry/react (incl. Tracing) 37.74 KB - -
@sentry/vue 26.67 KB - -
@sentry/vue (incl. Tracing) 36.61 KB - -
@sentry/svelte 22.65 KB - -
CDN Bundle 23.77 KB - -
CDN Bundle (incl. Tracing) 36.49 KB - -
CDN Bundle (incl. Tracing, Replay) 70.91 KB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 76.22 KB - -
CDN Bundle - uncompressed 69.63 KB - -
CDN Bundle (incl. Tracing) - uncompressed 108.21 KB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 219.87 KB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 233.07 KB - -
@sentry/nextjs (client) 37.51 KB - -
@sentry/sveltekit (client) 35.35 KB - -
@sentry/node 126.36 KB +1.11% +1.38 KB 🔺
@sentry/node - without tracing 98.84 KB +3.5% +3.34 KB 🔺
@sentry/aws-serverless 109.1 KB +1.47% +1.58 KB 🔺

View base workflow run

github-actions[bot] avatar Aug 27 '24 22:08 github-actions[bot]

This suggests that http.url has been deprecated and will be replaced by url.full: https://github.com/open-telemetry/semantic-conventions/blob/3c16c802e8ae8849ae0cf31eac02c3cabf64e4dd/model/registry/deprecated/http.yaml#L25-L30

timfish avatar Aug 27 '24 23:08 timfish

One nextjs-14 e2e test did need a change due to the differing attributes

timfish avatar Sep 05 '24 11:09 timfish