Challenges Implementing Sentry with Effect: No Traces Forwarded Despite Setup

I’m having a hard time implementing Sentry (OpenTelemetry + error monitoring) with Effect.

I’ve tried reading various threads about this, but I haven't been completely successful.

With the setup as shown here: opentelemetryEffect and Sentry Integration: Handling Errors and Issue Creation, I didn’t encounter any errors, but no traces were forwarded.

I ended up with something like this:
export const SentryLive = Effect.all([GadgetConfig, SentryConfig])
  .pipe(
    Effect.map(([gadgetConfig, sentryConfig]) => {
      return Sentry.init({
        dsn: Redacted.value(sentryConfig.dsn),
        environment: gadgetConfig.environment,
        integrations: [nodeProfilingIntegration(), extraErrorDataIntegration()],
        tracesSampleRate: 1.0,
        profilesSampleRate: 1.0,
      });
    }),
  )
  .pipe(Layer.scopedDiscard);

export const OpentelemetrySentryLive = NodeSdk.layer(() => {
  const client = getClient();

  if (client) {
    setupEventContextTrace(client);
  }

  const SentryContextManager = wrapContextManagerClass(
    AsyncLocalStorageContextManager,
  );

  return {
    resource: {
      serviceName: `${APP_NAME}/OpenTelemetrySentryLive`,
    },
    spanProcessor: new SentrySpanProcessor(),
    textMapPropagator: new SentryPropagator(),
    contextManager: new SentryContextManager(),
    sampler: client ? new SentrySampler(client) : undefined,
    traceExporter: new OTLPTraceExporter(),
    instrumentations: [getNodeAutoInstrumentations()],
  };
});


Which are then included in my managed runtime.

export const orderPaymentMethodAssignDefaultHandler = (
  command: OrderPaymentMethodAssignDefaultCommand,
) =>
  Effect.gen(function* () {
    // stuff

    if (!maybePaymentMethod) {
      yield* Effect.logWarning("order/payment_method_default_assignment", {
        orderId,
        details: "The order assigned customer has no payment method.",
      });

      return;
    }

    // stuff

    yield* Effect.logInfo("order/payment_method_default_assigned", {
      orderId,
      assignedPaymentMethodId: orderPaymentMethodId,
    });
  }).pipe(Effect.withSpan("orderPaymentMethodAssignDefaultHandler"));


It seems my traces are now being forwarded, but I don’t see anything related to my logs in Sentry.

Also, I’m not sure how issues should be sent to Sentry from an Effect-based system. I tried to log warning or errors but nothing show up.

I was used to call Sentry.captureException, but I feel like this is not the way in an effect world.

Since my app can’t be fully effectful, I’m unsure how to proceed.
Was this page helpful?