Skip to content

Commit 40da10b

Browse files
author
Luca Forstner
authored
feat(astro): Add transactionName to isolation scope for requests (#11786)
1 parent a0415aa commit 40da10b

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

packages/astro/src/server/middleware.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ export const handleRequest: (options?: MiddlewareOptions) => MiddlewareResponseH
6666
if (getActiveSpan()) {
6767
return instrumentRequest(ctx, next, handlerOptions);
6868
}
69-
return withIsolationScope(() => {
70-
return instrumentRequest(ctx, next, handlerOptions);
69+
return withIsolationScope(isolationScope => {
70+
return instrumentRequest(ctx, next, handlerOptions, isolationScope);
7171
});
7272
};
7373
};
@@ -76,6 +76,7 @@ async function instrumentRequest(
7676
ctx: Parameters<MiddlewareResponseHandler>[0],
7777
next: Parameters<MiddlewareResponseHandler>[1],
7878
options: MiddlewareOptions,
79+
isolationScope?: Scope,
7980
): Promise<Response> {
8081
// Make sure we don't accidentally double wrap (e.g. user added middleware and integration auto added it)
8182
const locals = ctx.locals as AstroLocalsWithSentry;
@@ -121,6 +122,8 @@ async function instrumentRequest(
121122
attributes['http.fragment'] = ctx.url.hash;
122123
}
123124

125+
isolationScope?.setTransactionName(`${method} ${interpolatedRoute || ctx.url.pathname}`);
126+
124127
const res = await startSpan(
125128
{
126129
attributes,

0 commit comments

Comments
 (0)