-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Note
The pull request "feat(tanstackstart-react): Trace server functions" was created by @nicohrubec but did not reference an issue. Therefore this issue was created for better visibility in external tools like Linear.
This PR adds tracing for tss server functions. To achieve this I added a new withSentry wrapper that can be used to instrument the tss server entry point:
import { withSentry } from '@sentry/tanstackstart-react';
import handler, { createServerEntry } from '@tanstack/react-start/server-entry';
const requestHandler = withSentry({
fetch(request: Request) {
return handler.fetch(request);
},
});
export default createServerEntry(requestHandler);
With this we get spans for server functions executed via fetch calls to the server. A limitation of this approach is that out-of-the-box this will only start a single span for the initial request made to the server. So for instance if a server function calls another server function, we will still only get a single span for the outer server function and users would need to wrap the inner call manually.
Screenshot from my sample app with the current state:

Tests added:
- Basic transaction test to verify that we get spans if a server function is executed.
- Another transaction test documenting that users need to manually wrap "nested" server functions.