Skip to content

Instantly share code, notes, and snippets.

@smith
Last active December 13, 2021 04:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smith/c936ae83b5fea13061f614ba010c9682 to your computer and use it in GitHub Desktop.
Save smith/c936ae83b5fea13061f614ba010c9682 to your computer and use it in GitHub Desktop.
Remix & Elastic APM Client-Side setup

These are instructions on how to use Elastic Observability with Remix.

The easiest way to get a working cluster is with Elastic Cloud. Create a new deployment. Once it's ready you'll want to copy the APM endpoint URL:

CleanShot 2021-12-12 at 22 21 19@2x

In your Remix app, install the Elastic RUM JavaScript agent:

npm install @elastic/apm-rum --save

Add the following to app/entry.client.tsx:

import { hydrate } from "react-dom";
import { RemixBrowser } from "remix";
import { init as initApm } from "@elastic/apm-rum";

initApm({
  // Set required service name (allowed characters: a-z, A-Z, 0-9, -, _, and space)
  serviceName: "remix-example-client",

  // Set custom APM Server URL (default: http://localhost:8200)
  serverUrl: "https://my-elastic-apm-url",

  // Set service version (required for sourcemap feature)
  serviceVersion: "0.1.0",
});

hydrate(<RemixBrowser />, document);

Now you can browse around your APP on localhost, then go back to your Elastic deployment and click "Open Kibana" to go to Kibana. Go to Observability > User Experience on the top-level hamburger menu. You'll see data from your app:

CleanShot 2021-12-12 at 22 31 25@2x

If you go to Observability > APM you'll see your app on the list of services. Clicking on it will go to the service overview:

CleanShot 2021-12-12 at 22 32 53@2x

Here you can see the transactions, and swith between route-change, page-load, or http-request event types. You can click into a transaction to see more data about it, including a trace waterfall.

This setup works pretty well out of the box, but we might need to make some improvements to get the transaction names to show up how you would expect.

This is only client-side monitoring, so we're not looking at any of the server-side transactions directly.

Hopefully this was helpful, and we can improve Elastic's support for Remix and the platforms it runs on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment