@@ -44,43 +44,34 @@ export function wrapFetchWithSentry(serverEntry: ServerEntry): ServerEntry {
4444 const url = new URL ( request . url ) ;
4545 const method = request . method || 'GET' ;
4646
47- // instrument server functions
47+ let op : string ;
48+ let spanAttributes : SpanAttributes ;
49+
4850 if ( url . pathname . includes ( '_serverFn' ) || url . pathname . includes ( 'createServerFn' ) ) {
51+ // server function call
52+ op = 'function.tanstackstart' ;
4953 const functionSha256 = extractServerFunctionSha256 ( url . pathname ) ;
50- const op = 'function.tanstackstart' ;
51-
52- const serverFunctionSpanAttributes : SpanAttributes = {
54+ spanAttributes = {
5355 [ SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN ] : 'auto.function.tanstackstart.server' ,
5456 [ SEMANTIC_ATTRIBUTE_SENTRY_OP ] : op ,
5557 'tanstackstart.function.hash.sha256' : functionSha256 ,
5658 } ;
57-
58- return startSpan (
59- {
60- op : op ,
61- name : `${ method } ${ url . pathname } ` ,
62- attributes : serverFunctionSpanAttributes ,
63- } ,
64- ( ) => {
65- return target . apply ( thisArg , args ) ;
66- } ,
67- ) ;
59+ } else {
60+ // API route or other server request
61+ op = 'http.server' ;
62+ spanAttributes = {
63+ [ SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN ] : 'auto.http.tanstackstart.server' ,
64+ [ SEMANTIC_ATTRIBUTE_SENTRY_OP ] : op ,
65+ [ SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD ] : method ,
66+ [ SEMANTIC_ATTRIBUTE_SENTRY_SOURCE ] : 'route' ,
67+ } ;
6868 }
6969
70- // instrument other server requests including API routes
71- const op = 'http.server' ;
72- const httpServerSpanAttributes : SpanAttributes = {
73- [ SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN ] : 'auto.http.tanstackstart.server' ,
74- [ SEMANTIC_ATTRIBUTE_SENTRY_OP ] : op ,
75- [ SEMANTIC_ATTRIBUTE_HTTP_REQUEST_METHOD ] : method ,
76- [ SEMANTIC_ATTRIBUTE_SENTRY_SOURCE ] : 'route' ,
77- } ;
78-
7970 return startSpan (
8071 {
81- op : op ,
72+ op,
8273 name : `${ method } ${ url . pathname } ` ,
83- attributes : httpServerSpanAttributes ,
74+ attributes : spanAttributes ,
8475 } ,
8576 ( ) => {
8677 return target . apply ( thisArg , args ) ;
0 commit comments