Skip to content

Commit cfbb502

Browse files
committed
cleanup
1 parent 0b53508 commit cfbb502

8 files changed

Lines changed: 25 additions & 40 deletions

File tree

packages/remix/src/server/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,4 +145,4 @@ export { init, getRemixDefaultIntegrations } from './sdk';
145145
export { captureRemixServerException } from './errors';
146146
export { sentryHandleError, wrapHandleErrorWithSentry, instrumentBuild } from './instrumentServer';
147147
export { generateSentryServerTimingHeader } from './serverTimingTracePropagation';
148-
export { remixIntegration } from './integrations';
148+
export { remixIntegration } from './integrations/RemixIntegration';

packages/remix/src/server/integrations/index.ts renamed to packages/remix/src/server/integrations/RemixIntegration.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ const _remixIntegration = (() => {
2020
if (isOrchestrionInjected()) {
2121
instrumentRemix(actionFormDataAttributes);
2222
} else {
23-
// `RemixInstrumentation` takes an options object; passing the bare map would leave its
24-
// default `{ _action: 'actionType' }` mapping in place (applying even when capture wasn't
25-
// configured, and ignoring the opted-in keys).
2623
instrumentRemixWithOpenTelemetry({ actionFormDataAttributes });
2724
}
2825
},

packages/remix/src/server/sdk.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { DEBUG_BUILD } from '../utils/debug-build';
66
import type { RemixOptions } from '../utils/remixOptions';
77
import { instrumentServer } from './instrumentServer';
88
import { httpIntegration } from './integrations/http';
9-
import { remixIntegration } from './integrations';
9+
import { remixIntegration } from './integrations/RemixIntegration';
1010

1111
/**
1212
* Returns the default Remix integrations.

packages/remix/test/server/remix-integration-otel.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ vi.mock('../../src/server/integrations/tracing-channel', () => ({
1717
instrumentRemix: vi.fn(),
1818
}));
1919

20-
import { remixIntegration } from '../../src/server/integrations';
20+
import { remixIntegration } from '../../src/server/integrations/RemixIntegration';
2121
import { instrumentRemixWithOpenTelemetry } from '../../src/server/integrations/opentelemetry';
2222
import { instrumentRemix } from '../../src/server/integrations/tracing-channel';
2323

@@ -31,7 +31,7 @@ function mockClient(
3131
} as unknown as NodeClient);
3232
}
3333

34-
describe('remixIntegration (OpenTelemetry path)', () => {
34+
describe('remixIntegration (OpenTelemetry-based)', () => {
3535
afterEach(() => {
3636
vi.clearAllMocks();
3737
vi.restoreAllMocks();

packages/remix/test/server/tracing-channel-no-form-data.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import type { Span } from '@sentry/core';
33
import * as SentryCore from '@sentry/core';
44
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, type MockInstance, vi } from 'vitest';
55
import {
6-
CHANNELS,
76
makeRequest,
87
makeSpan,
9-
setupRemixChannelIntegration,
8+
setupRemixInstrumentation,
109
teardownTestAsyncContextStrategy,
1110
} from './tracing-channel-test-utils';
11+
import { remixChannels } from '@sentry/server-utils/orchestrion';
1212

1313
// Runs in its own file so the channel subscriptions register with NO form-data capture configured -
1414
// the default for most apps. `captureActionFormDataKeys` gates only the optional attribute
@@ -19,7 +19,7 @@ describe('remixIntegration with orchestrion (no form-data capture configured)',
1919
let span: Span;
2020

2121
beforeAll(() => {
22-
setupRemixChannelIntegration(undefined);
22+
setupRemixInstrumentation(undefined);
2323
});
2424

2525
afterAll(() => {
@@ -48,7 +48,7 @@ describe('remixIntegration with orchestrion (no form-data capture configured)',
4848
],
4949
};
5050

51-
await tracingChannel(CHANNELS.CALL_ROUTE_ACTION).tracePromise(async () => ({ status: 201 }), ctx);
51+
await tracingChannel(remixChannels.REMIX_CALL_ROUTE_ACTION).tracePromise(async () => ({ status: 201 }), ctx);
5252

5353
expect(startInactiveSpanSpy).toHaveBeenCalledWith(
5454
expect.objectContaining({

packages/remix/test/server/tracing-channel-test-utils.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,6 @@ import type { NodeClient } from '@sentry/node';
1111
import { vi } from 'vitest';
1212
import { instrumentRemix } from '../../src/server/integrations/tracing-channel';
1313

14-
export const CHANNELS = {
15-
REQUEST_HANDLER: 'orchestrion:@remix-run/server-runtime:requestHandler',
16-
MATCH_SERVER_ROUTES: 'orchestrion:@remix-run/server-runtime:matchServerRoutes',
17-
CALL_ROUTE_LOADER: 'orchestrion:@remix-run/server-runtime:callRouteLoader',
18-
CALL_ROUTE_ACTION: 'orchestrion:@remix-run/server-runtime:callRouteAction',
19-
} as const;
20-
2114
interface TestStore {
2215
scope: Scope;
2316
isolationScope: Scope;
@@ -102,11 +95,11 @@ export function makeRequest(
10295
}
10396

10497
/**
105-
* Install the async-context strategy, mock the client with the given form-data config, and run the
106-
* integration's `setupOnce` so the channel subscriptions register. `captureActionFormDataKeys`
107-
* left undefined mimics an app that hasn't opted into form-data capture.
98+
* Install the async-context strategy, mock the client with the given form-data config, and orchestrion-based remix instrumentation
99+
* so the channel subscriptions register.
100+
* `captureActionFormDataKeys` left undefined mimics an app that hasn't opted into form-data capture.
108101
*/
109-
export function setupRemixChannelIntegration(captureActionFormDataKeys?: Record<string, string | boolean>): void {
102+
export function setupRemixInstrumentation(captureActionFormDataKeys?: Record<string, string | boolean>): void {
110103
installTestAsyncContextStrategy();
111104
vi.spyOn(SentryNode, 'getClient').mockReturnValue({
112105
getOptions: () => ({ captureActionFormDataKeys }),

packages/remix/test/server/tracing-channel.test.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,21 @@ import type { Span } from '@sentry/core';
33
import * as SentryCore from '@sentry/core';
44
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, type MockInstance, vi } from 'vitest';
55
import {
6-
CHANNELS,
76
makeRequest,
87
makeSpan,
9-
setupRemixChannelIntegration,
8+
setupRemixInstrumentation,
109
teardownTestAsyncContextStrategy,
1110
} from './tracing-channel-test-utils';
11+
import { remixChannels } from '@sentry/server-utils/orchestrion';
1212

13-
describe('remixChannelIntegration', () => {
13+
describe('remixIntegration (Orchestrion-based)', () => {
1414
let startInactiveSpanSpy: MockInstance;
1515
let getActiveSpanSpy: MockInstance;
1616
let span: Span;
1717

1818
beforeAll(() => {
1919
// Configure form-data capture so the ACTION span also extracts the mapped keys.
20-
setupRemixChannelIntegration({ _action: 'actionType' });
20+
setupRemixInstrumentation({ _action: 'actionType' });
2121
});
2222

2323
afterAll(() => {
@@ -39,7 +39,7 @@ describe('remixChannelIntegration', () => {
3939
it('requestHandler: builds the http.server span and sets the response status', async () => {
4040
const ctx = { arguments: [makeRequest({ method: 'GET', url: 'http://localhost/users' })] };
4141

42-
await tracingChannel(CHANNELS.REQUEST_HANDLER).tracePromise(async () => ({ status: 200 }), ctx);
42+
await tracingChannel(remixChannels.REMIX_REQUEST_HANDLER).tracePromise(async () => ({ status: 200 }), ctx);
4343

4444
expect(startInactiveSpanSpy).toHaveBeenCalledWith(
4545
expect.objectContaining({
@@ -65,7 +65,7 @@ describe('remixChannelIntegration', () => {
6565
result: [{ route: { path: 'users/:userId', id: 'routes/users.$userId' } }],
6666
};
6767

68-
tracingChannel(CHANNELS.MATCH_SERVER_ROUTES).traceSync(() => ctx.result, ctx);
68+
tracingChannel(remixChannels.REMIX_MATCH_SERVER_ROUTES).traceSync(() => ctx.result, ctx);
6969

7070
expect(span.setAttribute).toHaveBeenCalledWith('http.route', 'users/:userId');
7171
expect(span.setAttribute).toHaveBeenCalledWith('match.route.id', 'routes/users.$userId');
@@ -76,7 +76,7 @@ describe('remixChannelIntegration', () => {
7676
getActiveSpanSpy.mockReturnValue(undefined);
7777
const ctx = { arguments: [], result: [{ route: { path: 'users/:userId', id: 'x' } }] };
7878

79-
tracingChannel(CHANNELS.MATCH_SERVER_ROUTES).traceSync(() => ctx.result, ctx);
79+
tracingChannel(remixChannels.REMIX_MATCH_SERVER_ROUTES).traceSync(() => ctx.result, ctx);
8080

8181
expect(span.setAttribute).not.toHaveBeenCalled();
8282
});
@@ -92,7 +92,7 @@ describe('remixChannelIntegration', () => {
9292
],
9393
};
9494

95-
await tracingChannel(CHANNELS.CALL_ROUTE_LOADER).tracePromise(async () => ({ status: 200 }), ctx);
95+
await tracingChannel(remixChannels.REMIX_CALL_ROUTE_LOADER).tracePromise(async () => ({ status: 200 }), ctx);
9696

9797
expect(startInactiveSpanSpy).toHaveBeenCalledWith(
9898
expect.objectContaining({
@@ -116,7 +116,7 @@ describe('remixChannelIntegration', () => {
116116
getActiveSpanSpy.mockReturnValue(undefined);
117117
const ctx = { arguments: [{ routeId: 'x', request: makeRequest(), params: {} }] };
118118

119-
await tracingChannel(CHANNELS.CALL_ROUTE_LOADER).tracePromise(async () => ({ status: 200 }), ctx);
119+
await tracingChannel(remixChannels.REMIX_CALL_ROUTE_LOADER).tracePromise(async () => ({ status: 200 }), ctx);
120120

121121
expect(startInactiveSpanSpy).not.toHaveBeenCalled();
122122
});
@@ -132,7 +132,7 @@ describe('remixChannelIntegration', () => {
132132
],
133133
};
134134

135-
await tracingChannel(CHANNELS.CALL_ROUTE_ACTION).tracePromise(async () => ({ status: 201 }), ctx);
135+
await tracingChannel(remixChannels.REMIX_CALL_ROUTE_ACTION).tracePromise(async () => ({ status: 201 }), ctx);
136136

137137
expect(startInactiveSpanSpy).toHaveBeenCalledWith(
138138
expect.objectContaining({

packages/server-utils/src/orchestrion/config/remix.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
import type { InstrumentationConfig } from '..';
22

3-
// Ports the vendored `RemixInstrumentation` (an OTel `InstrumentationBase` that patched
4-
// `@remix-run/server-runtime`) to orchestrion channel injection. The subscriber lives in
5-
// `@sentry/remix` (`instrumentRemix`), because it needs remix-specific SDK options.
6-
//
7-
// Four concepts, one channel each. Where a function was renamed across the supported range, both
8-
// names publish to the same channel so the subscriber only ever knows one name per concept:
3+
// Four concepts, one channel each:
94
// - `requestHandler` → the async handler returned by `createRequestHandler` (the server span)
105
// - `matchServerRoutes` → sync route match; enriches the active span (creates no span of its own)
11-
// - `callRouteLoader` → LOADER span. Remix 2.0–2.8 named it `callRouteLoaderRR`.
12-
// - `callRouteAction` → ACTION span. Remix 2.0–2.8 named it `callRouteActionRR`.
6+
// - `callRouteLoader` → LOADER span. Remix 2.0–2.8 named it `callRouteLoaderRR`
7+
// - `callRouteAction` → ACTION span. Remix 2.0–2.8 named it `callRouteActionRR`
138
//
149
// Emitted for both the CJS (`dist/*`) and ESM (`dist/esm/*`) builds, which share function shapes.
1510
const remixInstrumentationConfig = (dir: string): InstrumentationConfig[] => [

0 commit comments

Comments
 (0)