Skip to content

feat(v8/bun): Update @sentry/bun to use OTEL node #10997

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,13 @@ const DEPENDENTS: Dependent[] = [
},
{
package: '@sentry/bun',
compareWith: nodeExperimentalExports,
compareWith: nodeExports,
exports: Object.keys(SentryBun),
ignoreExports: [
// not supported in bun:
'Handlers',
'NodeClient',
'hapiErrorPlugin',
'makeNodeTransport',
// TODO: remove these when we switch exports from nodeExperimentalExports to nodeExports
'Integrations',
'addGlobalEventProcessor',
'getActiveTransaction',
'getCurrentHub',
// legacy, to be removed...
'makeMain',
'startTransaction',
],
},
{
Expand Down
8 changes: 4 additions & 4 deletions packages/bun/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"types",
"types-ts3.8"
],
"main": "build/esm/index.js",
"main": "build/cjs/index.js",
"module": "build/esm/index.js",
"types": "build/types/index.d.ts",
"exports": {
Expand All @@ -33,8 +33,8 @@
},
"typesVersions": {
"<4.9": {
"build/npm/types/index.d.ts": [
"build/npm/types-ts3.8/index.d.ts"
"build/types/index.d.ts": [
"build/types-ts3.8/index.d.ts"
]
}
},
Expand All @@ -43,7 +43,7 @@
},
"dependencies": {
"@sentry/core": "8.0.0-alpha.2",
"@sentry/node-experimental": "8.0.0-alpha.2",
"@sentry/node": "8.0.0-alpha.2",
"@sentry/types": "8.0.0-alpha.2",
"@sentry/utils": "8.0.0-alpha.2"
},
Expand Down
5 changes: 1 addition & 4 deletions packages/bun/rollup.npm.config.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import { makeBaseNPMConfig, makeNPMConfigVariants } from '@sentry-internal/rollup-utils';

const config = makeNPMConfigVariants(makeBaseNPMConfig());

// remove cjs from config array config[0].output.format == cjs
export default [config[1]];
export default makeNPMConfigVariants(makeBaseNPMConfig());
3 changes: 1 addition & 2 deletions packages/bun/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as os from 'os';
import type { ServerRuntimeClientOptions } from '@sentry/core';
import { applySdkMetadata } from '@sentry/core';
import { ServerRuntimeClient } from '@sentry/core';
import { ServerRuntimeClient, applySdkMetadata } from '@sentry/core';

import type { BunClientOptions } from './types';

Expand Down
106 changes: 62 additions & 44 deletions packages/bun/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,21 @@ export type {
} from '@sentry/types';
export type { AddRequestDataToEventOptions } from '@sentry/utils';

export type { TransactionNamingScheme } from '@sentry/node-experimental';
export type { BunOptions } from './types';

export {
addEventProcessor,
addBreadcrumb,
addIntegration,
captureException,
captureEvent,
captureMessage,
close,
captureCheckIn,
startSession,
captureSession,
endSession,
withMonitor,
createTransport,
flush,
// eslint-disable-next-line deprecation/deprecation
getCurrentHub,
getClient,
isInitialized,
getCurrentScope,
Expand All @@ -50,64 +52,80 @@ export {
setHttpStatus,
withScope,
withIsolationScope,
captureCheckIn,
withMonitor,
makeNodeTransport,
NodeClient,
defaultStackParser,
flush,
close,
getSentryRelease,
addRequestDataToEvent,
DEFAULT_USER_INCLUDES,
extractRequestData,
createGetModuleFromFilename,
anrIntegration,
consoleIntegration,
httpIntegration,
nativeNodeFetchIntegration,
onUncaughtExceptionIntegration,
onUnhandledRejectionIntegration,
modulesIntegration,
contextLinesIntegration,
nodeContextIntegration,
localVariablesIntegration,
requestDataIntegration,
functionToStringIntegration,
inboundFiltersIntegration,
linkedErrorsIntegration,
setMeasurement,
getActiveSpan,
getRootSpan,
startSpan,
startInactiveSpan,
startSpanManual,
withActiveSpan,
getRootSpan,
getSpanDescendants,
continueTrace,
metricsDefault as metrics,
functionToStringIntegration,
inboundFiltersIntegration,
linkedErrorsIntegration,
requestDataIntegration,
getAutoPerformanceIntegrations,
cron,
metrics,
parameterize,
SEMANTIC_ATTRIBUTE_SENTRY_OP,
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE,
expressIntegration,
expressErrorHandler,
setupExpressErrorHandler,
fastifyIntegration,
setupFastifyErrorHandler,
graphqlIntegration,
mongoIntegration,
mongooseIntegration,
mysqlIntegration,
mysql2Integration,
nestIntegration,
postgresIntegration,
prismaIntegration,
hapiIntegration,
setupHapiErrorHandler,
spotlightIntegration,
} from '@sentry/node';

export {
captureConsoleIntegration,
debugIntegration,
dedupeIntegration,
extraErrorDataIntegration,
rewriteFramesIntegration,
sessionTimingIntegration,
parameterize,
startSession,
captureSession,
endSession,
} from '@sentry/core';
export {
DEFAULT_USER_INCLUDES,
autoDiscoverNodePerformanceMonitoringIntegrations,
cron,
createGetModuleFromFilename,
defaultStackParser,
extractRequestData,
getSentryRelease,
addRequestDataToEvent,
anrIntegration,
consoleIntegration,
contextLinesIntegration,
hapiIntegration,
httpIntegration,
localVariablesIntegration,
modulesIntegration,
nativeNodeFetchintegration,
nodeContextIntegration,
onUncaughtExceptionIntegration,
onUnhandledRejectionIntegration,
spotlightIntegration,
SEMANTIC_ATTRIBUTE_SENTRY_OP,
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE,
} from '@sentry/node-experimental';

export type { BunOptions } from './types';

export { BunClient } from './client';
export {
getDefaultIntegrations,
init,
} from './sdk';

export { bunServerIntegration } from './integrations/bunserver';
export { makeFetchTransport } from './transports';
7 changes: 3 additions & 4 deletions packages/bun/src/sdk.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable max-lines */
import {
functionToStringIntegration,
inboundFiltersIntegration,
Expand All @@ -11,9 +10,9 @@ import {
httpIntegration,
init as initNode,
modulesIntegration,
nativeNodeFetchintegration,
nativeNodeFetchIntegration,
nodeContextIntegration,
} from '@sentry/node-experimental';
} from '@sentry/node';
import type { Integration, Options } from '@sentry/types';

import { BunClient } from './client';
Expand All @@ -33,7 +32,7 @@ export function getDefaultIntegrations(_options: Options): Integration[] {
// Native Wrappers
consoleIntegration(),
httpIntegration(),
nativeNodeFetchintegration(),
nativeNodeFetchIntegration(),
// Global Handlers # TODO (waiting for https://github.com/oven-sh/bun/issues/5091)
// new NodeIntegrations.OnUncaughtException(),
// new NodeIntegrations.OnUnhandledRejection(),
Expand Down
18 changes: 2 additions & 16 deletions packages/bun/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,7 @@
"include": ["src/**/*"],

"compilerOptions": {
"types": ["bun-types"],
"lib": ["esnext"],
"module": "esnext",
"target": "esnext",

// if TS 4.x or earlier
"moduleResolution": "nodenext",

"jsx": "react-jsx", // support JSX
"allowJs": true, // allow importing `.js` from `.ts`
"esModuleInterop": true, // allow default imports for CommonJS modules

// best practices
"strict": true,
"forceConsistentCasingInFileNames": true,
"skipLibCheck": true
// package-specific options
"types": ["bun-types"]
}
}