You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Remove the otelExchange from the default exchanges in favour of injecting serverside
The otel api and associated tracing functions add some bundle size to the API client that aren't at all necessary on the browser. The browser can't export spans to our tracing config, so we really don't need this code there. But, we definitely want it server side in the sandbox where it gives us important visibility on how the api client is performing there. Instead of paying the bundle size penalty all the time, we can inject the otel exchange with the new exchange injection facility, and use normal otel monkeypatching to add the other spans.
Before:
```
vite v4.4.7 building for production...
✓ 223 modules transformed.
dist/api-read-stats.html 227.36 kB │ gzip: 48.87 kB
dist/test-bundle-api-read.js 253.91 kB │ gzip: 47.33 kB
dist/api-read-stats.html 227.90 kB │ gzip: 48.94 kB
dist/test-bundle-api-read.cjs 168.40 kB │ gzip: 39.39 kB
✓ built in 1.01s
vite v4.4.7 building for production...
✓ 499 modules transformed.
dist/react-read-stats.html 320.54 kB │ gzip: 59.02 kB
dist/test-bundle-react-read.js 359.09 kB │ gzip: 76.48 kB
dist/react-read-stats.html 323.17 kB │ gzip: 59.05 kB
dist/test-bundle-react-read.cjs 243.18 kB │ gzip: 64.60 kB
✓ built in 1.34s
vite v4.4.7 building for production...
✓ 1033 modules transformed.
dist/shopify-read-stats.html 532.78 kB │ gzip: 79.62 kB
dist/test-bundle-shopify-read.js 678.46 kB │ gzip: 135.16 kB
dist/shopify-read-stats.html 533.31 kB │ gzip: 79.69 kB
dist/test-bundle-shopify-read.cjs 477.27 kB │ gzip: 115.70 kB
```
After:
```
✓ 176 modules transformed.
dist/api-read-stats.html 212.12 kB │ gzip: 47.04 kB
dist/test-bundle-api-read.js 236.85 kB │ gzip: 43.50 kB
dist/api-read-stats.html 212.64 kB │ gzip: 47.09 kB
dist/test-bundle-api-read.cjs 155.96 kB │ gzip: 36.01 kB
✓ built in 861ms
vite v4.4.7 building for production...
✓ 452 modules transformed.
dist/react-read-stats.html 303.58 kB │ gzip: 57.00 kB
dist/test-bundle-react-read.js 342.04 kB │ gzip: 72.64 kB
dist/react-read-stats.html 307.55 kB │ gzip: 57.01 kB
dist/test-bundle-react-read.cjs 230.74 kB │ gzip: 61.17 kB
✓ built in 1.23s
vite v4.4.7 building for production...
✓ 986 modules transformed.
dist/shopify-read-stats.html 517.13 kB │ gzip: 77.52 kB
dist/test-bundle-shopify-read.js 661.41 kB │ gzip: 131.38 kB
dist/shopify-read-stats.html 517.64 kB │ gzip: 77.55 kB
dist/test-bundle-shopify-read.cjs 464.83 kB │ gzip: 112.29 kB
✓ built in 2.39s
```
7% decompressed bundle size savings which seems ok but not great
// The server will error if it receives any operations before the auth dance has been completed, so we block on that happening before sending our first operation. It's important that this happens synchronously after instantiating the client so we don't miss any messages
// super ultra critical option that ensures graphql-ws doesn't automatically close the websocket connection when there are no outstanding operations. this is key so we can start a transaction then make mutations within it
207
+
lazyCloseTimeout: 100000,
208
+
retryAttempts: 0,
209
+
});
210
+
211
+
constclient=newClient({
212
+
url: "/-",// not used because there's no fetch exchange, set for clarity
213
+
requestPolicy: "network-only",// skip any cached data during transactions
// The server will error if it receives any operations before the auth dance has been completed, so we block on that happening before sending our first operation. It's important that this happens synchronously after instantiating the client so we don't miss any messages
// super ultra critical option that ensures graphql-ws doesn't automatically close the websocket connection when there are no outstanding operations. this is key so we can start a transaction then make mutations within it
219
-
lazyCloseTimeout: 100000,
220
-
retryAttempts: 0,
221
-
});
222
-
223
-
constclient=newClient({
224
-
url: "/-",// not used because there's no fetch exchange, set for clarity
225
-
requestPolicy: "network-only",// skip any cached data during transactions
0 commit comments