Skip to content

Commit b61b646

Browse files
author
Luca Forstner
committed
Merge remote-tracking branch 'origin/develop' into lforst-nextjs-otel
2 parents 728c086 + 284e90d commit b61b646

File tree

7 files changed

+30
-24
lines changed

7 files changed

+30
-24
lines changed

dev-packages/node-integration-tests/suites/tracing-experimental/prisma-orm/scenario.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Sentry.init({
99
release: '1.0',
1010
tracesSampleRate: 1.0,
1111
transport: loggingTransport,
12+
integrations: [Sentry.prismaIntegration()],
1213
});
1314

1415
// Stop the process from exiting before the transaction is sent

packages/astro/src/server/sdk.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { applySdkMetadata } from '@sentry/core';
22
import type { NodeOptions } from '@sentry/node';
3-
import { getDefaultIntegrations } from '@sentry/node';
43
import { init as initNodeSdk, setTag } from '@sentry/node';
54

65
/**
@@ -10,9 +9,6 @@ import { init as initNodeSdk, setTag } from '@sentry/node';
109
export function init(options: NodeOptions): void {
1110
const opts = {
1211
...options,
13-
// TODO v8: For now, we disable the Prisma integration, because that has weird esm-cjs interop issues
14-
// We should figure these out and fix these before v8 goes stable.
15-
defaultIntegrations: getDefaultIntegrations(options).filter(integration => integration.name !== 'Prisma'),
1612
};
1713
applySdkMetadata(opts, 'astro', ['astro', 'node']);
1814

packages/core/src/utils/spanUtils.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,10 @@ function ensureTimestampInSeconds(timestamp: number): number {
8585

8686
/**
8787
* Convert a span to a JSON representation.
88-
* Note that all fields returned here are optional and need to be guarded against.
89-
*
90-
* Note: Because of this, we currently have a circular type dependency (which we opted out of in package.json).
91-
* This is not avoidable as we need `spanToJSON` in `spanUtils.ts`, which in turn is needed by `span.ts` for backwards compatibility.
92-
* And `spanToJSON` needs the Span class from `span.ts` to check here.
9388
*/
89+
// Note: Because of this, we currently have a circular type dependency (which we opted out of in package.json).
90+
// This is not avoidable as we need `spanToJSON` in `spanUtils.ts`, which in turn is needed by `span.ts` for backwards compatibility.
91+
// And `spanToJSON` needs the Span class from `span.ts` to check here.
9492
export function spanToJSON(span: Span): Partial<SpanJSON> {
9593
if (spanIsSentrySpan(span)) {
9694
return span.getSpanJSON();

packages/nextjs/src/config/webpack.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ export function constructWebpackConfigFunction(
6060
const { isServer, dev: isDev, dir: projectDir } = buildContext;
6161
const runtime = isServer ? (buildContext.nextRuntime === 'edge' ? 'edge' : 'server') : 'client';
6262

63+
if (runtime !== 'client') {
64+
warnAboutDeprecatedConfigFiles(projectDir, runtime);
65+
}
66+
6367
let rawNewConfig = { ...incomingConfig };
6468

6569
// if user has custom webpack config (which always takes the form of a function), run it so we have actual values to
@@ -508,25 +512,23 @@ async function addSentryToClientEntryProperty(
508512
* Searches for old `sentry.(server|edge).config.ts` files and warns if it finds any.
509513
*
510514
* @param projectDir The root directory of the project, where config files would be located
511-
* @param platform Either "server", "client" or "edge", so that we know which file to look for
515+
* @param platform Either "server" or "edge", so that we know which file to look for
512516
*/
513-
export function warnAboutDeprecatedConfigFiles(projectDir: string, platform: 'server' | 'client' | 'edge'): void {
517+
function warnAboutDeprecatedConfigFiles(projectDir: string, platform: 'server' | 'edge'): void {
514518
const possibilities = [`sentry.${platform}.config.ts`, `sentry.${platform}.config.js`];
515519

516520
for (const filename of possibilities) {
517521
if (fs.existsSync(path.resolve(projectDir, filename))) {
518-
if (platform === 'server' || platform === 'edge') {
519-
// eslint-disable-next-line no-console
520-
console.warn(
521-
`[@sentry/nextjs] It seems you have configured a \`${filename}\` file. You need to put this file's content into a Next.js instrumentation hook instead! Read more: https://nextjs.org/docs/app/building-your-application/optimizing/instrumentation`,
522-
);
523-
}
522+
// eslint-disable-next-line no-console
523+
console.warn(
524+
`[@sentry/nextjs] It appears you've configured a \`${filename}\` file. Please ensure to put this file's content into the \`register()\` function of a Next.js instrumentation hook instead. To ensure correct functionality of the SDK, \`Sentry.init\` must be called inside \`instrumentation.ts\`. Learn more about setting up an instrumentation hook in Next.js: https://nextjs.org/docs/app/building-your-application/optimizing/instrumentation. You can safely delete the \`${filename}\` file afterward.`,
525+
);
524526
}
525527
}
526528
}
527529

528530
/**
529-
* Searches for a `sentry.client.config.ts|js` file and returns it's file name if it finds one. (ts being prioritized)
531+
* Searches for a `sentry.client.config.ts|js` file and returns its file name if it finds one. (ts being prioritized)
530532
*
531533
* @param projectDir The root directory of the project, where config files would be located
532534
*/

packages/node-experimental/src/integrations/tracing/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import { mysqlIntegration } from './mysql';
1111
import { mysql2Integration } from './mysql2';
1212
import { nestIntegration } from './nest';
1313
import { postgresIntegration } from './postgres';
14-
import { prismaIntegration } from './prisma';
1514

1615
/**
1716
* With OTEL, all performance integrations will be added, as OTEL only initializes them when the patched package is actually required.
@@ -26,7 +25,10 @@ export function getAutoPerformanceIntegrations(): Integration[] {
2625
mysqlIntegration(),
2726
mysql2Integration(),
2827
postgresIntegration(),
29-
prismaIntegration(),
28+
// For now, we do not include prisma by default because it has ESM issues
29+
// See https://github.com/prisma/prisma/issues/23410
30+
// TODO v8: Figure out a better solution for this, maybe only disable in ESM mode?
31+
// prismaIntegration(),
3032
nestIntegration(),
3133
hapiIntegration(),
3234
koaIntegration(),

packages/opentelemetry/src/spanExporter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ function createTransactionForOtelSpan(span: ReadableSpan): TransactionEvent {
178178
data: attributes,
179179
origin,
180180
op,
181-
status: getStatusMessage(status),
181+
status: getStatusMessage(status), // As per protocol, span status is allowed to be undefined
182182
});
183183

184184
const transactionEvent: TransactionEvent = {
@@ -252,7 +252,7 @@ function createAndFinishSpanForOtelSpan(node: SpanNode, spans: SpanJSON[], remai
252252
start_timestamp: convertOtelTimeToSeconds(startTime),
253253
// This is [0,0] by default in OTEL, in which case we want to interpret this as no end time
254254
timestamp: convertOtelTimeToSeconds(endTime) || undefined,
255-
status: getStatusMessage(status),
255+
status: getStatusMessage(status), // As per protocol, span status is allowed to be undefined
256256
op,
257257
origin,
258258
_metrics_summary: getMetricSummaryJsonForSpan(span as unknown as Span),

packages/opentelemetry/src/trace.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
getDynamicSamplingContextFromClient,
1313
getRootSpan,
1414
handleCallbackErrors,
15+
spanToJSON,
1516
} from '@sentry/core';
1617
import type { Client, Scope } from '@sentry/types';
1718
import { continueTraceAsRemoteSpan, getSamplingDecision, makeTraceState } from './propagator';
@@ -46,7 +47,10 @@ export function startSpan<T>(options: OpenTelemetrySpanContext, callback: (span:
4647
return handleCallbackErrors(
4748
() => callback(span),
4849
() => {
49-
span.setStatus({ code: SpanStatusCode.ERROR });
50+
// Only set the span status to ERROR when there wasn't any status set before, in order to avoid stomping useful span statuses
51+
if (spanToJSON(span).status === undefined) {
52+
span.setStatus({ code: SpanStatusCode.ERROR });
53+
}
5054
},
5155
() => span.end(),
5256
);
@@ -82,7 +86,10 @@ export function startSpanManual<T>(
8286
return handleCallbackErrors(
8387
() => callback(span, () => span.end()),
8488
() => {
85-
span.setStatus({ code: SpanStatusCode.ERROR });
89+
// Only set the span status to ERROR when there wasn't any status set before, in order to avoid stomping useful span statuses
90+
if (spanToJSON(span).status === undefined) {
91+
span.setStatus({ code: SpanStatusCode.ERROR });
92+
}
8693
},
8794
);
8895
});

0 commit comments

Comments
 (0)