Skip to content

Commit f33b40b

Browse files
committed
feat(remix): Update remix SDK to be OTEL-powered
1 parent 2333b3f commit f33b40b

36 files changed

+91
-220
lines changed

dev-packages/e2e-tests/test-applications/create-remix-app-express-vite-dev/app/entry.server.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import './tracing';
2+
13
import { PassThrough } from 'node:stream';
24

35
import type { AppLoadContext, EntryContext } from '@remix-run/node';
@@ -12,13 +14,6 @@ installGlobals();
1214

1315
const ABORT_DELAY = 5_000;
1416

15-
Sentry.init({
16-
environment: 'qa', // dynamic sampling bias to keep transactions
17-
dsn: process.env.E2E_TEST_DSN,
18-
// Performance Monitoring
19-
tracesSampleRate: 1.0, // Capture 100% of the transactions, reduce in production!
20-
});
21-
2217
export const handleError = Sentry.wrapRemixHandleError;
2318

2419
export default function handleRequest(
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import * as Sentry from '@sentry/remix';
2+
3+
Sentry.init({
4+
environment: 'qa', // dynamic sampling bias to keep transactions
5+
dsn: process.env.E2E_TEST_DSN,
6+
// Performance Monitoring
7+
tracesSampleRate: 1.0, // Capture 100% of the transactions, reduce in production!
8+
});

dev-packages/e2e-tests/test-applications/create-remix-app-v2/app/entry.server.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import './tracing';
2+
13
/**
24
* By default, Remix will handle generating the HTTP Response for you.
35
* You are free to delete this file if you'd like to, but if you ever want it revealed again, you can run `npx remix reveal` ✨
@@ -18,13 +20,6 @@ installGlobals();
1820

1921
const ABORT_DELAY = 5_000;
2022

21-
Sentry.init({
22-
environment: 'qa', // dynamic sampling bias to keep transactions
23-
dsn: process.env.E2E_TEST_DSN,
24-
// Performance Monitoring
25-
tracesSampleRate: 1.0, // Capture 100% of the transactions, reduce in production!
26-
});
27-
2823
export const handleError = Sentry.wrapRemixHandleError;
2924

3025
export default function handleRequest(
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import * as Sentry from '@sentry/remix';
2+
3+
Sentry.init({
4+
tracesSampleRate: 1.0, // Capture 100% of the transactions, reduce in production!
5+
environment: 'qa', // dynamic sampling bias to keep transactions
6+
dsn: process.env.E2E_TEST_DSN,
7+
// Performance Monitoring
8+
});

dev-packages/e2e-tests/test-applications/create-remix-app/app/entry.server.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import './tracing';
2+
13
/**
24
* By default, Remix will handle generating the HTTP Response for you.
35
* You are free to delete this file if you'd like to, but if you ever want it revealed again, you can run `npx remix reveal` ✨
@@ -15,13 +17,6 @@ import { renderToPipeableStream } from 'react-dom/server';
1517

1618
const ABORT_DELAY = 5_000;
1719

18-
Sentry.init({
19-
environment: 'qa', // dynamic sampling bias to keep transactions
20-
dsn: process.env.E2E_TEST_DSN,
21-
// Performance Monitoring
22-
tracesSampleRate: 1.0, // Capture 100% of the transactions, reduce in production!
23-
});
24-
2520
export const handleError = Sentry.wrapRemixHandleError;
2621

2722
export default function handleRequest(
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import * as Sentry from '@sentry/remix';
2+
3+
Sentry.init({
4+
environment: 'qa', // dynamic sampling bias to keep transactions
5+
dsn: process.env.E2E_TEST_DSN,
6+
// Performance Monitoring
7+
tracesSampleRate: 1.0, // Capture 100% of the transactions, reduce in production!
8+
});

packages/astro/src/index.types.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,10 @@ export declare function flush(timeout?: number | undefined): PromiseLike<boolean
2424

2525
// eslint-disable-next-line deprecation/deprecation
2626
export declare const makeMain: typeof clientSdk.makeMain;
27-
export declare const getActiveSpan: typeof clientSdk.getActiveSpan;
2827
// eslint-disable-next-line deprecation/deprecation
2928
export declare const getCurrentHub: typeof clientSdk.getCurrentHub;
3029
export declare const getClient: typeof clientSdk.getClient;
31-
export declare const startSpan: typeof clientSdk.startSpan;
32-
export declare const startInactiveSpan: typeof clientSdk.startInactiveSpan;
33-
export declare const startSpanManual: typeof clientSdk.startSpanManual;
34-
export declare const withActiveSpan: typeof clientSdk.withActiveSpan;
35-
export declare const getRootSpan: typeof clientSdk.getRootSpan;
30+
3631
export declare const Span: clientSdk.Span;
3732

3833
export declare const metrics: typeof clientSdk.metrics & typeof serverSdk.metrics;

packages/remix/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"@remix-run/router": "1.x",
4949
"@sentry/cli": "^2.30.0",
5050
"@sentry/core": "8.0.0-alpha.2",
51-
"@sentry/node-experimental": "8.0.0-alpha.2",
51+
"@sentry/node": "8.0.0-alpha.2",
5252
"@sentry/react": "8.0.0-alpha.2",
5353
"@sentry/types": "8.0.0-alpha.2",
5454
"@sentry/utils": "8.0.0-alpha.2",
@@ -82,10 +82,9 @@
8282
"fix": "eslint . --format stylish --fix",
8383
"lint": "eslint . --format stylish",
8484
"test": "yarn test:unit",
85-
"test:integration": "run-s test:integration:v1 test:integration:v2 test:integration:tracingIntegration",
85+
"test:integration": "run-s test:integration:v1 test:integration:v2",
8686
"test:integration:v1": "run-s test:integration:clean test:integration:prepare test:integration:client test:integration:server",
8787
"test:integration:v2": "export REMIX_VERSION=2 && run-s test:integration:v1",
88-
"test:integration:tracingIntegration": "export TRACING_INTEGRATION=true && run-s test:integration:v2",
8988
"test:integration:ci": "run-s test:integration:clean test:integration:prepare test:integration:client:ci test:integration:server",
9089
"test:integration:prepare": "(cd test/integration && yarn install)",
9190
"test:integration:clean": "(cd test/integration && rimraf .cache node_modules build)",

packages/remix/src/index.server.ts

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { applySdkMetadata } from '@sentry/core';
2-
import type { NodeOptions } from '@sentry/node-experimental';
3-
import { getClient, init as nodeInit, setTag } from '@sentry/node-experimental';
1+
import { applySdkMetadata, isInitialized } from '@sentry/core';
2+
import type { NodeOptions } from '@sentry/node';
3+
import { init as nodeInit, setTag } from '@sentry/node';
44
import { logger } from '@sentry/utils';
55

66
import { DEBUG_BUILD } from './utils/debug-build';
@@ -10,8 +10,6 @@ import type { RemixOptions } from './utils/remixOptions';
1010
// We need to explicitly export @sentry/node as they end up under `default` in ESM builds
1111
// See: https://github.com/getsentry/sentry-javascript/issues/8474
1212
export {
13-
// eslint-disable-next-line deprecation/deprecation
14-
addGlobalEventProcessor,
1513
addEventProcessor,
1614
addBreadcrumb,
1715
addIntegration,
@@ -22,8 +20,6 @@ export {
2220
captureMessage,
2321
createTransport,
2422
// eslint-disable-next-line deprecation/deprecation
25-
getActiveTransaction,
26-
// eslint-disable-next-line deprecation/deprecation
2723
getCurrentHub,
2824
getClient,
2925
getCurrentScope,
@@ -46,7 +42,6 @@ export {
4642
setHttpStatus,
4743
withScope,
4844
withIsolationScope,
49-
autoDiscoverNodePerformanceMonitoringIntegrations,
5045
makeNodeTransport,
5146
getDefaultIntegrations,
5247
defaultStackParser,
@@ -56,7 +51,6 @@ export {
5651
addRequestDataToEvent,
5752
DEFAULT_USER_INCLUDES,
5853
extractRequestData,
59-
Integrations,
6054
consoleIntegration,
6155
onUncaughtExceptionIntegration,
6256
onUnhandledRejectionIntegration,
@@ -68,7 +62,6 @@ export {
6862
functionToStringIntegration,
6963
inboundFiltersIntegration,
7064
linkedErrorsIntegration,
71-
Handlers,
7265
setMeasurement,
7366
getActiveSpan,
7467
getRootSpan,
@@ -83,15 +76,29 @@ export {
8376
parameterize,
8477
metrics,
8578
createGetModuleFromFilename,
86-
hapiErrorPlugin,
8779
SEMANTIC_ATTRIBUTE_SENTRY_OP,
8880
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
8981
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
9082
SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE,
91-
} from '@sentry/node-experimental';
83+
expressIntegration,
84+
expressErrorHandler,
85+
setupExpressErrorHandler,
86+
fastifyIntegration,
87+
graphqlIntegration,
88+
mongoIntegration,
89+
mongooseIntegration,
90+
mysqlIntegration,
91+
mysql2Integration,
92+
nestIntegration,
93+
postgresIntegration,
94+
prismaIntegration,
95+
hapiIntegration,
96+
setupHapiErrorHandler,
97+
spotlightIntegration,
98+
} from '@sentry/node';
9299

93100
// Keeping the `*` exports for backwards compatibility and types
94-
export * from '@sentry/node-experimental';
101+
export * from '@sentry/node';
95102

96103
export { captureRemixServerException, wrapRemixHandleError } from './utils/instrumentServer';
97104
export { ErrorBoundary, withErrorBoundary } from '@sentry/react';
@@ -102,15 +109,11 @@ export { wrapExpressCreateRequestHandler } from './utils/serverAdapters/express'
102109

103110
export type { SentryMetaArgs } from './utils/types';
104111

105-
function sdkAlreadyInitialized(): boolean {
106-
return !!getClient();
107-
}
108-
109112
/** Initializes Sentry Remix SDK on Node. */
110113
export function init(options: RemixOptions): void {
111114
applySdkMetadata(options, 'remix', ['remix', 'node']);
112115

113-
if (sdkAlreadyInitialized()) {
116+
if (isInitialized()) {
114117
DEBUG_BUILD && logger.log('SDK already initialized');
115118

116119
return;

packages/remix/src/index.types.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export declare function init(options: RemixOptions): void;
1414

1515
// We export a merged Integrations object so that users can (at least typing-wise) use all integrations everywhere.
1616
// eslint-disable-next-line deprecation/deprecation
17-
export declare const Integrations: typeof clientSdk.Integrations & typeof serverSdk.Integrations;
17+
export declare const Integrations: typeof clientSdk.Integrations;
1818

1919
export declare const linkedErrorsIntegration: typeof clientSdk.linkedErrorsIntegration;
2020
export declare const contextLinesIntegration: typeof clientSdk.contextLinesIntegration;
@@ -27,6 +27,12 @@ export declare const defaultStackParser: StackParser;
2727
// methods from `@sentry/core`.
2828
declare const runtime: 'client' | 'server';
2929

30+
// eslint-disable-next-line deprecation/deprecation
31+
export declare const makeMain: typeof clientSdk.makeMain;
32+
// eslint-disable-next-line deprecation/deprecation
33+
export declare const getCurrentHub: typeof clientSdk.getCurrentHub;
34+
export declare const getClient: typeof clientSdk.getClient;
35+
3036
export const close = runtime === 'client' ? clientSdk.close : serverSdk.close;
3137
export const flush = runtime === 'client' ? clientSdk.flush : serverSdk.flush;
3238

packages/remix/src/utils/instrumentServer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
startSpan,
1515
withIsolationScope,
1616
} from '@sentry/core';
17-
import { captureException, getActiveSpan, getRootSpan } from '@sentry/node-experimental';
17+
import { captureException, getActiveSpan, getRootSpan } from '@sentry/node';
1818
import type { Span, TransactionSource, WrappedFunction } from '@sentry/types';
1919
import {
2020
addExceptionMechanism,

packages/remix/src/utils/remixOptions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { NodeOptions } from '@sentry/node-experimental';
1+
import type { NodeOptions } from '@sentry/node';
22
import type { BrowserOptions } from '@sentry/react';
33
import type { Options } from '@sentry/types';
44

packages/remix/src/utils/serverAdapters/express.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { getClient, getCurrentHub, hasTracingEnabled, setHttpStatus, withIsolationScope } from '@sentry/core';
2-
import { flush } from '@sentry/node-experimental';
2+
import { flush } from '@sentry/node';
33
import type { Hub, Span } from '@sentry/types';
44
import { extractRequestData, fill, isString, logger } from '@sentry/utils';
55

packages/remix/test/index.server.test.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import * as SentryNode from '@sentry/node-experimental';
1+
import * as SentryNode from '@sentry/node';
22

3-
import { Integrations, init } from '../src/index.server';
3+
import { init } from '../src/index.server';
44

55
const nodeInit = jest.spyOn(SentryNode, 'init');
66

@@ -55,9 +55,4 @@ describe('Server init()', () => {
5555

5656
expect(SentryNode.getIsolationScope().getScopeData().tags).toEqual({ runtime: 'node' });
5757
});
58-
59-
it('has both node and tracing integrations', () => {
60-
expect(Integrations.Apollo).not.toBeUndefined();
61-
expect(Integrations.Http).not.toBeUndefined();
62-
});
6358
});

packages/remix/test/integration/app_v1/entry.server.tsx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
1+
import './tracing.server';
2+
// it is important this is first!
3+
14
import type { EntryContext } from '@remix-run/node';
25
import { RemixServer } from '@remix-run/react';
3-
import * as Sentry from '@sentry/remix';
46
import { renderToString } from 'react-dom/server';
57

6-
Sentry.init({
7-
dsn: 'https://public@dsn.ingest.sentry.io/1337',
8-
tracesSampleRate: 1,
9-
tracePropagationTargets: ['example.org'],
10-
// Disabling to test series of envelopes deterministically.
11-
autoSessionTracking: false,
12-
});
13-
148
export default function handleRequest(
159
request: Request,
1610
responseStatusCode: number,
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import * as Sentry from '@sentry/remix';
2+
3+
Sentry.init({
4+
dsn: 'https://public@dsn.ingest.sentry.io/1337',
5+
tracesSampleRate: 1,
6+
tracePropagationTargets: ['example.org'],
7+
// Disabling to test series of envelopes deterministically.
8+
autoSessionTracking: false,
9+
});

packages/remix/test/integration/app_v2/entry.server.tsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
1+
import './tracing.server';
2+
// it is important this is first!
3+
14
import type { EntryContext } from '@remix-run/node';
25
import { RemixServer } from '@remix-run/react';
36
import * as Sentry from '@sentry/remix';
47
import { renderToString } from 'react-dom/server';
58

6-
Sentry.init({
7-
dsn: 'https://public@dsn.ingest.sentry.io/1337',
8-
tracesSampleRate: 1,
9-
tracePropagationTargets: ['example.org'],
10-
// Disabling to test series of envelopes deterministically.
11-
autoSessionTracking: false,
12-
});
13-
149
export const handleError = Sentry.wrapRemixHandleError;
1510

1611
export default function handleRequest(
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import * as Sentry from '@sentry/remix';
2+
3+
Sentry.init({
4+
dsn: 'https://public@dsn.ingest.sentry.io/1337',
5+
tracesSampleRate: 1,
6+
tracePropagationTargets: ['example.org'],
7+
// Disabling to test series of envelopes deterministically.
8+
autoSessionTracking: false,
9+
});

packages/remix/test/integration/app_v2_tracingIntegration/entry.client.tsx

Lines changed: 0 additions & 12 deletions
This file was deleted.

packages/remix/test/integration/app_v2_tracingIntegration/entry.server.tsx

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)