I recently realized @sentry/remix wasn’t fully instrumented on the Remix server. I added an instrumentation.ts file and started simply with some logging:
import * as Sentry from '@sentry/remix';
console.log('VERCEL INSTRUMENTATION FILE');
export function register() {
console.log('VERCEL INSTRUMENTATION FILE REGISTERED');
Sentry.init({
dsn: process.env.SENTRY_DSN,
environment: process.env.NODE_ENV,
tracesSampleRate: 1.0
});
}
However, I don’t see these logs appear in the Vercel logs, and I do not see the instrumentation file in any of the build artifacts under Sources (in either Source or Output).
I’m using the @vercel/remix package and the remix vite vercel preset. Not sure what I need to do to ensure the instrumentation file is included in the build artifacts. Couldn’t find any documentation for Other frameworks other than examples of the file structure.
Sentry has docs here for how to instrument a Remix app. If you don’t have entry.server.tsx in your codebase, you can run npx remix reveal to make it appear
The key detail Sentry calls out for its instrumentation is that it runs before the application runtime begins. The problem with adding it in entry.server.tsx is that the module has already been loaded by Vercel’s server entrypoint, and instrumentation is applied too late.
I could solve this if i can get an instrumentation file to belong as part of the build output, and instruct vercel import it before the application module is loaded, but I’m not sure if this is possible