Skip to content

Commit a55f023

Browse files
committed
update op
1 parent 24a3c3f commit a55f023

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

packages/react-router/src/server/instrumentation/reactRouter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
} from '@sentry/core';
1313
import type * as reactRouter from 'react-router';
1414
import { DEBUG_BUILD } from '../../common/debug-build';
15-
import { getSpanName, isDataRequest } from './util';
15+
import { getOpName, getSpanName, isDataRequest } from './util';
1616

1717
type ReactRouterModuleExports = typeof reactRouter;
1818

@@ -87,7 +87,7 @@ export class ReactRouterInstrumentation extends InstrumentationBase<Instrumentat
8787
attributes: {
8888
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url',
8989
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.react-router',
90-
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'function.react-router.loader',
90+
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: getOpName(url.pathname, request.method),
9191
url: url.pathname,
9292
method: request.method,
9393
},

packages/react-router/src/server/instrumentation/util.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
/**
2+
* Gets the op name for a request based on whether it's a loader or action request.
3+
* @param pathName The URL pathname to check
4+
* @param requestMethod The HTTP request method
5+
*/
6+
export function getOpName(pathName: string, requestMethod: string): string {
7+
return isLoaderRequest(pathName, requestMethod)
8+
? 'function.react-router.loader'
9+
: isActionRequest(pathName, requestMethod)
10+
? 'function.react-router.action'
11+
: 'function.react-router';
12+
}
13+
114
/**
215
* Gets the span name for a request based on whether it's a loader or action request.
316
* @param pathName The URL pathname to check

0 commit comments

Comments
 (0)