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

feat(remix): Export a manual wrapper for custom Express servers.

Open onurtemizkan opened this issue 3 years ago • 1 comments

⚠️ Requires tests

Remix allows custom server declarations and exports createRequestHandler functions from each adapter. In some cases, createRequestHandler functions are used before we have a chance to instrument them.

Also, we wrap the core createRequestHandler from @remix/server-runtime, which all the adapters use. Each adapter may have their own APIs, so we can't directly re-export our already implemented wrapper.

This PR implements and exports a manual wrapper for Express adapters.

Also:

  • Moves Remix-related type declarations to its own file, as it seems it will continue to grow.

onurtemizkan avatar Aug 04 '22 19:08 onurtemizkan

size-limit report 📦

Path Size
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 19.39 KB (+0.02% 🔺)
@sentry/browser - ES5 CDN Bundle (minified) 59.99 KB (0%)
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 17.96 KB (+0.01% 🔺)
@sentry/browser - ES6 CDN Bundle (minified) 52.88 KB (0%)
@sentry/browser - Webpack (gzipped + minified) 19.73 KB (0%)
@sentry/browser - Webpack (minified) 64.21 KB (0%)
@sentry/react - Webpack (gzipped + minified) 19.75 KB (0%)
@sentry/nextjs Client - Webpack (gzipped + minified) 44.16 KB (0%)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 25.79 KB (0%)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 24.04 KB (+0.01% 🔺)

github-actions[bot] avatar Aug 05 '22 10:08 github-actions[bot]

If this wrapper is used when it's not needed, loader, action and documentRequest spans are reported twice. Is there a preferred way to prevent multiple wrapping

We should be able to use __sentry_wrapped__ - just set it on the wrapped function so we don't wrap multiple times. We could also just store some flags internally, and flip them the first time we wrap - then we can just check those again.

AbhiPrasad avatar Aug 10 '22 15:08 AbhiPrasad

@AbhiPrasad, the updated tests do not test the manual wrapper by itself. (As I could not recreate the scenario with the current testing structure). But they are testing when we use a manual wrapper on an already instrumented backend.

onurtemizkan avatar Aug 12 '22 17:08 onurtemizkan

@onurtemizkan That should be fine, we can also dogfood with vanguard to make sure we have added confidence.

AbhiPrasad avatar Aug 12 '22 17:08 AbhiPrasad

Great timing for my company as we are currently implementing Sentry in our newest app which happens to be using Remix (wrapped by express 😄). Looking forward to the next release!

justinwaite avatar Aug 12 '22 21:08 justinwaite

Awesome news @justinwaite - we’ll have a release out early next week!

@onurtemizkan We’ll need to add some docs, can you take care of that?

AbhiPrasad avatar Aug 12 '22 21:08 AbhiPrasad