Skip to content

Using Sentry with Remix when using Architect (Lambda wrapper) #6062

@AbhiPrasad

Description

@AbhiPrasad

Discussed in #6050

Originally posted by alexmk92 October 26, 2022
We've built a new product at work which is using Remix and deployed to the edge using Architect (wrapper around CloudFormation and Lambda)

It's working great, but we're massively missing out on visibility into the app. I installed the Remix SDK today and it works great for reporting client side metrics; the server-side however receives no information due to the fact we're not using Remix's default server execution handler.

In the interim, I've pulled in the serverless SDK as well as the Remix SDK and exported the remix Lambda handler after initialising the app using the Remix SDK:

 import { createRequestHandler } from "@remix-run/architect";
import * as build from "@remix-run/dev/server-build";
import { env } from "~/utils/env";
import { AWSLambda } from "@sentry/serverless";
import * as Sentry from "@sentry/remix";

Sentry.init({
  dsn: env("SENTRY_DSN") as string,
  environment: env("NODE_ENV") as string,
  tracesSampleRate: parseInt(env("SENTRY_TRACE_SAMPLE_RATE", 1) as string),
  // ...
});

export const handler = AWSLambda.wrapHandler(
  createRequestHandler({
    build,
    mode: env("NODE_ENV", "development") as string,
  })
);

I'm now getting some metrics out of my server-side code, but its very limited in use as all routes are named as AppEnvAnyCatchAllHttpLambda. I'm guessing this is where a dedicated remix wrapper would need to be created to add additional meta information to the trace (such as the route, params etc)

image

What steps would I need to take to provision a Remix Lambda extension? I'm happy to tinker with it, I've just got no idea where to start (the existing Lambda implementation was a bit over my head 🤯)

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions