Skip to content

Commit 78d4453

Browse files
authored
Merge branch 'develop' into fix/fetch-not-release
2 parents 7f0c21b + 65531f3 commit 78d4453

File tree

20 files changed

+63
-54
lines changed

20 files changed

+63
-54
lines changed

dev-packages/e2e-tests/test-applications/astro-4/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
},
1414
"dependencies": {
1515
"@astrojs/check": "0.9.2",
16-
"@astrojs/node": "8.3.2",
16+
"@astrojs/node": "8.3.4",
1717
"@playwright/test": "^1.46.0",
1818
"@sentry/astro": "* || latest",
1919
"@sentry-internal/test-utils": "link:../../../test-utils",
2020
"@spotlightjs/astro": "2.1.6",
21-
"astro": "4.13.3",
21+
"astro": "4.16.18",
2222
"typescript": "^5.5.4"
2323
},
2424
"devDependencies": {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
/// <reference path="../.astro/types.d.ts" />
12
/// <reference types="astro/client" />

dev-packages/e2e-tests/test-applications/astro-5/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,10 @@
1717
"@sentry-internal/test-utils": "link:../../../test-utils",
1818
"@sentry/astro": "^8.42.0",
1919
"astro": "^5.0.3"
20+
},
21+
"pnpm": {
22+
"overrides": {
23+
"esbuild": "0.24.0"
24+
}
2025
}
2126
}

dev-packages/e2e-tests/test-applications/react-router-7-spa/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,10 @@
5656
"label": "react-router-7-spa (TS 3.8)"
5757
}
5858
]
59+
},
60+
"pnpm": {
61+
"overrides": {
62+
"esbuild": "0.24.0"
63+
}
5964
}
6065
}

packages/astro/src/index.types.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ export declare function flush(timeout?: number | undefined): PromiseLike<boolean
2626

2727
// eslint-disable-next-line deprecation/deprecation
2828
export declare const getCurrentHub: typeof clientSdk.getCurrentHub;
29-
export declare const getClient: typeof clientSdk.getClient;
30-
export declare const continueTrace: typeof clientSdk.continueTrace;
3129

3230
export declare const Span: clientSdk.Span;
3331

packages/core/src/asyncContext/types.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { Scope } from '../scope';
22
import type { getTraceData } from '../utils/traceData';
33
import type {
4+
continueTrace,
45
startInactiveSpan,
56
startSpan,
67
startSpanManual,
@@ -68,4 +69,11 @@ export interface AsyncContextStrategy {
6869

6970
/** Get trace data as serialized string values for propagation via `sentry-trace` and `baggage`. */
7071
getTraceData?: typeof getTraceData;
72+
73+
/**
74+
* Continue a trace from `sentry-trace` and `baggage` values.
75+
* These values can be obtained from incoming request headers, or in the browser from `<meta name="sentry-trace">`
76+
* and `<meta name="baggage">` HTML tags.
77+
*/
78+
continueTrace?: typeof continueTrace;
7179
}

packages/core/src/tracing/trace.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,15 +192,20 @@ export function startInactiveSpan(options: StartSpanOptions): Span {
192192
* be attached to the incoming trace.
193193
*/
194194
export const continueTrace = <V>(
195-
{
196-
sentryTrace,
197-
baggage,
198-
}: {
195+
options: {
199196
sentryTrace: Parameters<typeof propagationContextFromHeaders>[0];
200197
baggage: Parameters<typeof propagationContextFromHeaders>[1];
201198
},
202199
callback: () => V,
203200
): V => {
201+
const carrier = getMainCarrier();
202+
const acs = getAsyncContextStrategy(carrier);
203+
if (acs.continueTrace) {
204+
return acs.continueTrace(options, callback);
205+
}
206+
207+
const { sentryTrace, baggage } = options;
208+
204209
return withScope(scope => {
205210
const propagationContext = propagationContextFromHeaders(sentryTrace, baggage);
206211
scope.setPropagationContext(propagationContext);

packages/nextjs/src/common/pages-router-instrumentation/wrapApiHandlerWithSentry.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
44
captureException,
55
continueTrace,
6+
getActiveSpan,
67
httpRequestToRequestData,
78
isString,
89
logger,
@@ -59,7 +60,13 @@ export function wrapApiHandlerWithSentry(apiHandler: NextApiHandler, parameteriz
5960
req.__withSentry_applied__ = true;
6061

6162
return withIsolationScope(isolationScope => {
62-
return continueTrace(
63+
// Normally, there is an active span here (from Next.js OTEL) and we just use that as parent
64+
// Else, we manually continueTrace from the incoming headers
65+
const continueTraceIfNoActiveSpan = getActiveSpan()
66+
? <T>(_opts: unknown, callback: () => T) => callback()
67+
: continueTrace;
68+
69+
return continueTraceIfNoActiveSpan(
6370
{
6471
sentryTrace:
6572
req.headers && isString(req.headers['sentry-trace']) ? req.headers['sentry-trace'] : undefined,

packages/nextjs/src/common/withServerActionInstrumentation.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { RequestEventData } from '@sentry/core';
2+
import { getActiveSpan } from '@sentry/core';
23
import {
34
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
45
SPAN_STATUS_ERROR,
@@ -95,7 +96,13 @@ async function withServerActionInstrumentationImplementation<A extends (...args:
9596
} satisfies RequestEventData,
9697
});
9798

98-
return continueTrace(
99+
// Normally, there is an active span here (from Next.js OTEL) and we just use that as parent
100+
// Else, we manually continueTrace from the incoming headers
101+
const continueTraceIfNoActiveSpan = getActiveSpan()
102+
? <T>(_opts: unknown, callback: () => T) => callback()
103+
: continueTrace;
104+
105+
return continueTraceIfNoActiveSpan(
99106
{
100107
sentryTrace: sentryTraceHeader,
101108
baggage: baggageHeader,

packages/nextjs/src/index.types.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ export declare function init(
1919
options: Options | clientSdk.BrowserOptions | serverSdk.NodeOptions | edgeSdk.EdgeOptions,
2020
): Client | undefined;
2121

22-
export declare const getClient: typeof clientSdk.getClient;
23-
export declare const getRootSpan: typeof serverSdk.getRootSpan;
24-
export declare const continueTrace: typeof clientSdk.continueTrace;
25-
2622
export declare const linkedErrorsIntegration: typeof clientSdk.linkedErrorsIntegration;
2723
export declare const contextLinesIntegration: typeof clientSdk.contextLinesIntegration;
2824

0 commit comments

Comments
 (0)