Skip to content

Commit 587e9e2

Browse files
committed
fixup! feat(effect): Remove effectLayer auto composition
1 parent cb6091d commit 587e9e2

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

packages/effect/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const SentryLive = Layer.mergeAll(
2626
}),
2727
Layer.setTracer(Sentry.SentryEffectTracer),
2828
Logger.replace(Logger.defaultLogger, Sentry.SentryEffectLogger),
29+
Sentry.SentryEffectMetricsLayer,
2930
);
3031

3132
const MainLive = HttpLive.pipe(Layer.provide(SentryLive));

packages/effect/test/layer.test.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { describe, expect, it } from '@effect/vitest';
2-
import { getClient, getCurrentScope, getIsolationScope, SDK_VERSION } from '@sentry/core';
2+
import * as sentryCore from '@sentry/core';
3+
import { getClient, getCurrentScope, getIsolationScope, SDK_VERSION, SentrySpan } from '@sentry/core';
34
import { Effect, Layer, Logger, LogLevel } from 'effect';
45
import { afterEach, beforeEach, vi } from 'vitest';
56
import * as sentryClient from '../src/index.client';
@@ -41,6 +42,7 @@ describe.each([
4142

4243
afterEach(() => {
4344
getCurrentScope().setClient(undefined);
45+
vi.restoreAllMocks();
4446
});
4547

4648
it('creates a valid Effect layer', () => {
@@ -91,8 +93,11 @@ describe.each([
9193

9294
it.effect('layer enables tracing when tracer is set', () =>
9395
Effect.gen(function* () {
96+
const startInactiveSpanMock = vi.spyOn(sentryCore, 'startInactiveSpan');
97+
9498
const result = yield* Effect.withSpan('test-span')(Effect.succeed('traced'));
9599
expect(result).toBe('traced');
100+
expect(startInactiveSpanMock).toHaveBeenCalledWith(expect.objectContaining({ name: 'test-span' }));
96101
}).pipe(
97102
Effect.withTracer(SentryEffectTracer),
98103
Effect.provide(
@@ -106,11 +111,14 @@ describe.each([
106111

107112
it.effect('layer can be composed with tracer layer', () =>
108113
Effect.gen(function* () {
114+
const startInactiveSpanMock = vi.spyOn(sentryCore, 'startInactiveSpan');
115+
109116
const result = yield* Effect.succeed(42).pipe(
110117
Effect.map(n => n * 2),
111118
Effect.withSpan('computation'),
112119
);
113120
expect(result).toBe(84);
121+
expect(startInactiveSpanMock).toHaveBeenCalledWith(expect.objectContaining({ name: 'computation' }));
114122
}).pipe(
115123
Effect.provide(
116124
Layer.mergeAll(
@@ -145,13 +153,16 @@ describe.each([
145153

146154
it.effect('layer can be composed with all Effect features', () =>
147155
Effect.gen(function* () {
156+
const startInactiveSpanMock = vi.spyOn(sentryCore, 'startInactiveSpan');
157+
148158
yield* Effect.logInfo('starting computation');
149159
const result = yield* Effect.succeed(42).pipe(
150160
Effect.map(n => n * 2),
151161
Effect.withSpan('computation'),
152162
);
153163
yield* Effect.logInfo('computation complete');
154164
expect(result).toBe(84);
165+
expect(startInactiveSpanMock).toHaveBeenCalledWith(expect.objectContaining({ name: 'computation' }));
155166
}).pipe(
156167
Effect.provide(
157168
Layer.mergeAll(

0 commit comments

Comments
 (0)