Effect CommunityEC
Effect Community6mo ago
1 reply
justin

Sentry tracing

Hey guys, I'm trying to setup tracing with Sentry using the official example from docs https://effect.website/docs/observability/tracing/#tutorial-visualizing-traces:
import { NodeSdk } from "@effect/opentelemetry"
import { SentrySpanProcessor } from "@sentry/opentelemetry"

const NodeSdkLive = NodeSdk.layer(() => ({
  resource: { serviceName: "example" },
  spanProcessor: new SentrySpanProcessor()
}))

But nothing seems to work. According to Sentry docs https://docs.sentry.io/platforms/javascript/guides/nextjs/opentelemetry/custom-setup/ there is quite a different setup for the Sentry client.

How can I initialize the client correctly? Where do I initialize it? I tried something like this to no avail:
export const NodeSdkLive = Layer.unwrapEffect(
  Effect.gen(function* () {
    const sentryClient = Sentry.init({
      dsn: "",
      tracesSampleRate: 1.0,
      skipOpenTelemetrySetup: true,
    });

    if (!sentryClient) {
      return NodeSdk.layer(() => ({}));
    }

    const layer = NodeSdk.layer(() => ({
      resource: {
        serviceName: "example",
      },
      spanProcessors: [new SentrySpanProcessor()],
      textMapPropagator: new SentryPropagator(),
      instrumentations: [getNodeAutoInstrumentations()],
    }));

    return layer;
  }),
);
Learn how to use your existing custom OpenTelemetry setup with Sentry.
Was this page helpful?