Skip to content

Commit 5181dd1

Browse files
committed
feat(astro): Update @sentry/astro to use OpenTelemetry
1 parent c7c6bb2 commit 5181dd1

File tree

12 files changed

+76
-35
lines changed

12 files changed

+76
-35
lines changed

dev-packages/e2e-tests/test-applications/node-exports-test-app/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
},
1414
"dependencies": {
1515
"@sentry/node-experimental": "latest || *",
16+
"@sentry/node": "latest || *",
1617
"@sentry/sveltekit": "latest || *",
1718
"@sentry/remix": "latest || *",
1819
"@sentry/astro": "latest || *",

dev-packages/e2e-tests/test-applications/node-exports-test-app/scripts/consistentExports.ts

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,52 @@
11
import * as SentryAstro from '@sentry/astro';
22
import * as SentryBun from '@sentry/bun';
33
import * as SentryNextJs from '@sentry/nextjs';
4-
import * as SentryNode from '@sentry/node-experimental';
4+
import * as SentryNode from '@sentry/node';
5+
import * as SentryNodeExperimental from '@sentry/node-experimental';
56
import * as SentryRemix from '@sentry/remix';
67
import * as SentryServerless from '@sentry/serverless';
78
import * as SentrySvelteKit from '@sentry/sveltekit';
89

910
/* List of exports that are safe to ignore / we don't require in any depending package */
10-
const NODE_EXPORTS_IGNORE = [
11+
const NODE_EXPERIMENTAL_EXPORTS_IGNORE = [
1112
'default',
1213
// Probably generated by transpilation, no need to require it
1314
'__esModule',
14-
// These Node exports were only made for type definition fixes (see #10339)
15-
'Undici',
15+
// These are not re-exported where not needed
1616
'Http',
17-
'DebugSession',
18-
'AnrIntegrationOptions',
19-
'LocalVariablesIntegrationOptions',
17+
'Undici',
18+
];
19+
20+
/* List of exports that are safe to ignore / we don't require in any depending package */
21+
const NODE_EXPORTS_IGNORE = [
22+
'default',
23+
// Probably generated by transpilation, no need to require it
24+
'__esModule',
2025
];
2126

27+
/* Sanitized list of node exports */
28+
const nodeExperimentalExports = Object.keys(SentryNodeExperimental).filter(
29+
e => !NODE_EXPERIMENTAL_EXPORTS_IGNORE.includes(e),
30+
);
31+
const nodeExports = Object.keys(SentryNode).filter(e => !NODE_EXPORTS_IGNORE.includes(e));
32+
2233
type Dependent = {
2334
package: string;
2435
exports: string[];
2536
ignoreExports?: string[];
2637
skip?: boolean;
38+
compareWith: string[];
2739
};
2840

2941
const DEPENDENTS: Dependent[] = [
3042
{
3143
package: '@sentry/astro',
44+
compareWith: nodeExports,
3245
exports: Object.keys(SentryAstro),
3346
},
3447
{
3548
package: '@sentry/bun',
49+
compareWith: nodeExperimentalExports,
3650
exports: Object.keys(SentryBun),
3751
ignoreExports: [
3852
// not supported in bun:
@@ -44,35 +58,36 @@ const DEPENDENTS: Dependent[] = [
4458
},
4559
{
4660
package: '@sentry/nextjs',
61+
compareWith: nodeExperimentalExports,
4762
// Next.js doesn't require explicit exports, so we can just merge top level and `default` exports:
4863
// @ts-expect-error: `default` is not in the type definition but it's defined
4964
exports: Object.keys({ ...SentryNextJs, ...SentryNextJs.default }),
5065
},
5166
{
5267
package: '@sentry/remix',
68+
compareWith: nodeExperimentalExports,
5369
exports: Object.keys(SentryRemix),
5470
},
5571
{
5672
package: '@sentry/serverless',
73+
compareWith: nodeExperimentalExports,
5774
exports: Object.keys(SentryServerless),
5875
ignoreExports: ['cron', 'hapiErrorPlugin'],
5976
},
6077
{
6178
package: '@sentry/sveltekit',
79+
compareWith: nodeExperimentalExports,
6280
exports: Object.keys(SentrySvelteKit),
6381
},
6482
];
6583

66-
/* Sanitized list of node exports */
67-
const nodeExports = Object.keys(SentryNode).filter(e => !NODE_EXPORTS_IGNORE.includes(e));
68-
6984
console.log('🔎 Checking for consistent exports of @sentry/node exports in depending packages');
7085

7186
const missingExports: Record<string, string[]> = {};
7287
const dependentsToCheck = DEPENDENTS.filter(d => !d.skip);
7388

74-
for (const nodeExport of nodeExports) {
75-
for (const dependent of dependentsToCheck) {
89+
for (const dependent of dependentsToCheck) {
90+
for (const nodeExport of dependent.compareWith) {
7691
if (dependent.ignoreExports?.includes(nodeExport)) {
7792
continue;
7893
}

packages/astro/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"dependencies": {
5252
"@sentry/browser": "8.0.0-alpha.2",
5353
"@sentry/core": "8.0.0-alpha.2",
54-
"@sentry/node-experimental": "8.0.0-alpha.2",
54+
"@sentry/node": "8.0.0-alpha.2",
5555
"@sentry/types": "8.0.0-alpha.2",
5656
"@sentry/utils": "8.0.0-alpha.2",
5757
"@sentry/vite-plugin": "^2.14.2"

packages/astro/src/index.server.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Node SDK exports
2-
// Unfortunately, we cannot `export * from '@sentry/node-experimental'` because in prod builds,
2+
// Unfortunately, we cannot `export * from '@sentry/node'` because in prod builds,
33
// Vite puts these exports into a `default` property (Sentry.default) rather than
44
// on the top - level namespace.
55

@@ -37,7 +37,6 @@ export {
3737
setHttpStatus,
3838
withScope,
3939
withIsolationScope,
40-
autoDiscoverNodePerformanceMonitoringIntegrations,
4140
makeNodeTransport,
4241
getDefaultIntegrations,
4342
defaultStackParser,
@@ -47,7 +46,6 @@ export {
4746
addRequestDataToEvent,
4847
DEFAULT_USER_INCLUDES,
4948
extractRequestData,
50-
Integrations,
5149
consoleIntegration,
5250
onUncaughtExceptionIntegration,
5351
onUnhandledRejectionIntegration,
@@ -59,7 +57,6 @@ export {
5957
functionToStringIntegration,
6058
inboundFiltersIntegration,
6159
linkedErrorsIntegration,
62-
Handlers,
6360
setMeasurement,
6461
getActiveSpan,
6562
startSpan,
@@ -74,10 +71,24 @@ export {
7471
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
7572
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
7673
SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE,
77-
} from '@sentry/node-experimental';
74+
expressIntegration,
75+
expressErrorHandler,
76+
setupExpressErrorHandler,
77+
fastifyIntegration,
78+
graphqlIntegration,
79+
mongoIntegration,
80+
mongooseIntegration,
81+
mysqlIntegration,
82+
mysql2Integration,
83+
nestIntegration,
84+
postgresIntegration,
85+
prismaIntegration,
86+
hapiIntegration,
87+
setupHapiErrorHandler,
88+
} from '@sentry/node';
7889

7990
// We can still leave this for the carrier init and type exports
80-
export * from '@sentry/node-experimental';
91+
export * from '@sentry/node';
8192

8293
export { init } from './server/sdk';
8394

packages/astro/src/index.types.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ import sentryAstro from './index.server';
1313
/** Initializes Sentry Astro SDK */
1414
export declare function init(options: Options | clientSdk.BrowserOptions | serverSdk.NodeOptions): void;
1515

16-
// We only export server Integrations for now, until the exports are removed from Svelte and Node SDKs.
17-
// Necessary to avoid type collision.
18-
export declare const Integrations: typeof serverSdk.Integrations;
19-
2016
export declare const linkedErrorsIntegration: typeof clientSdk.linkedErrorsIntegration;
2117
export declare const contextLinesIntegration: typeof clientSdk.contextLinesIntegration;
2218

@@ -26,5 +22,17 @@ export declare const defaultStackParser: StackParser;
2622
export declare function close(timeout?: number | undefined): PromiseLike<boolean>;
2723
export declare function flush(timeout?: number | undefined): PromiseLike<boolean>;
2824

25+
// eslint-disable-next-line deprecation/deprecation
26+
export declare const makeMain: typeof clientSdk.makeMain;
27+
export declare const getActiveSpan: typeof clientSdk.getActiveSpan;
28+
// eslint-disable-next-line deprecation/deprecation
29+
export declare const getCurrentHub: typeof clientSdk.getCurrentHub;
30+
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 Span: clientSdk.Span;
36+
2937
export declare const metrics: typeof clientSdk.metrics & typeof serverSdk.metrics;
3038
export default sentryAstro;

packages/astro/src/integration/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export const sentryAstro = (options: SentryOptions = {}): AstroIntegration => {
9191
// @sentry/node is required in case we have 2 different @sentry/node
9292
// packages installed in the same project.
9393
// Ref: https://github.com/getsentry/sentry-javascript/issues/10121
94-
noExternal: ['@sentry/astro', '@sentry/node-experimental', '@sentry/node'],
94+
noExternal: ['@sentry/astro', '@sentry/node'],
9595
},
9696
},
9797
});

packages/astro/src/server/middleware.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, setHttpStatus } from '@sentry/core';
21
import {
2+
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
3+
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
34
captureException,
45
continueTrace,
56
getActiveSpan,
67
getClient,
78
getCurrentScope,
9+
setHttpStatus,
810
startSpan,
911
withIsolationScope,
10-
} from '@sentry/node-experimental';
12+
} from '@sentry/node';
1113
import type { Client, Scope, Span, SpanAttributes } from '@sentry/types';
1214
import { addNonEnumerableProperty, objectify, stripUrlQueryAndFragment } from '@sentry/utils';
1315
import type { APIContext, MiddlewareResponseHandler } from 'astro';

packages/astro/src/server/sdk.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { applySdkMetadata } from '@sentry/core';
2-
import type { NodeOptions } from '@sentry/node-experimental';
3-
import { init as initNodeSdk, setTag } from '@sentry/node-experimental';
2+
import type { NodeOptions } from '@sentry/node';
3+
import { init as initNodeSdk, setTag } from '@sentry/node';
44

55
/**
66
*

packages/astro/test/client/sdk.test.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
import type { BrowserClient } from '@sentry/browser';
2-
import { getActiveSpan } from '@sentry/browser';
3-
import { browserTracingIntegration } from '@sentry/browser';
2+
import {
3+
browserTracingIntegration,
4+
getActiveSpan,
5+
getCurrentScope,
6+
getGlobalScope,
7+
getIsolationScope,
8+
} from '@sentry/browser';
49
import * as SentryBrowser from '@sentry/browser';
510
import { SDK_VERSION, getClient } from '@sentry/browser';
611
import { vi } from 'vitest';
712

8-
import { getCurrentScope, getGlobalScope, getIsolationScope } from '@sentry/core';
913
import { init } from '../../../astro/src/client/sdk';
1014

1115
const browserInit = vi.spyOn(SentryBrowser, 'init');

packages/astro/test/server/meta.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { vi } from 'vitest';
55

66
import { getTracingMetaTags, isValidBaggageString } from '../../src/server/meta';
77

8-
const TRACE_FLAG_SAMPLED = 0x1;
8+
const TRACE_FLAG_SAMPLED = 1;
99

1010
const mockedSpan = new SentrySpan({
1111
traceId: '12345678901234567890123456789012',

packages/astro/test/server/middleware.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { SEMANTIC_ATTRIBUTE_SENTRY_SOURCE } from '@sentry/core';
2-
import * as SentryNode from '@sentry/node-experimental';
2+
import * as SentryNode from '@sentry/node';
33
import type { Client, Span } from '@sentry/types';
44
import { vi } from 'vitest';
55

packages/astro/test/server/sdk.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import * as SentryNode from '@sentry/node-experimental';
2-
import { SDK_VERSION } from '@sentry/node-experimental';
1+
import * as SentryNode from '@sentry/node';
2+
import { SDK_VERSION } from '@sentry/node';
33
import { vi } from 'vitest';
44

55
import { init } from '../../src/server/sdk';

0 commit comments

Comments
 (0)