The only tool you need to know what is happening and how to fix it.
Go alertingexception-trackerissue-trackinglogsmetricsmonitoringobservability-platformopen-telemetryotelsession-replaytelemetrytraces
feat: testing app shop removed tw (#230)
narrow-adventure9c3364f3b9fc
diff --git a/testing/shop/DEMO.md b/testing/shop/DEMO.mdnew file mode 100644index 00000000..ab028d45--- /dev/null+++ b/testing/shop/DEMO.md@@ -0,0 +1,240 @@+# Demo Shop — Live Demo Runbook++Three acts:++1. **Bugs, no observability** — run the app as-is (Traceway stripped out). It's slow and flaky,+ errors are swallowed or buried in the browser console. You have no idea what's breaking.+2. **Add Traceway** — re-instrument both halves. Every bug now surfaces as an issue with a stack+ trace, tags, and a frequency, plus slow transactions.+3. **Symbolication** — the frontend stack traces arrive minified (`index-abc123.js:1:48211`).+ Upload source maps and they turn into real `CheckoutPage.jsx:8` frames in your source.++The bug catalog (numbers `#1`–`#11`) is in [`BUGS.md`](./BUGS.md).++## Prerequisites++- A Traceway instance running (these notes assume **http://localhost:8082**) with a **project** ++ its **project token**.+- Go 1.25+ with CGO, Node 18+.+- The sibling SDK repos the app links against must exist (they were used to build it originally):+ - Go SDK at `../../../go-client` (relative to `backend/`)+ - JS SDK at `../../../js-client` (relative to `frontend/`)++> **Tip:** the current working tree is the *stripped* (no-Traceway) version. If you want to be able+> to return to it after the demo, commit it on a branch first (e.g. `git switch -c shop-no-tw`).+> The fully-instrumented version is preserved in commit **`fd21c509`**, which Act 2 restores from.++---++## Act 1 — Bugs with no observability++```bash+cd testing/shop+./build-and-run.sh+```++Open **http://localhost:8090** and drive it (open the browser devtools console too):++- **Products page** — everything loads *slowly* (N+1, `#1`). Click **Quick view** → "No variants+ available" (`#11`, swallowed). Click **Add to cart** a few times → it occasionally just doesn't+ add and you only see a red error in the console if you're looking (`#9`).+- **Checkout** — type a coupon (`SAVE10`) and **Apply** → it usually errors (`#5`), and the badge+ area shows "Could not display coupon." (`#10`, caught by a local boundary). **Place order** with+ an empty cart → it fails (`#6`); with items it's slow (`#7`) and sometimes declined (`#8`).++Backend bugs from the terminal:++```bash+for i in $(seq 1 8); do curl -s -o /dev/null -w "%{http_code} " -X POST localhost:8090/api/coupon \+ -H 'Content-Type: application/json' -d '{"code":"SAVE10"}'; done; echo # ~75% 500+curl -s -o /dev/null -w "%{http_code}\n" -X POST localhost:8090/api/checkout \+ -H 'Content-Type: application/json' -d '{"name":"A","email":"[email protected]","card_last4":"4242"}' # 500+```++**The point:** the app is clearly unhealthy, but the failures are swallowed, intermittent, or+lost in the console. You can't see *what* is breaking, *how often*, or *where*.++Stop the server (`Ctrl-C`) before Act 2.++---++## Act 2 — Add Traceway++The instrumented version of every handler and React component lives in commit `fd21c509`. Restore+those, keep the new "serve frontend from backend" wiring, and point the SDKs at your instance.++**1. Restore the instrumented handlers + frontend + Go deps** (everything except `main.go`, which+needs the new static-serving line):++```bash+cd testing/shop+git checkout fd21c509 -- \+ backend/cart.go backend/products.go backend/checkout.go backend/coupon.go \+ backend/go.mod backend/go.sum \+ frontend/src/main.jsx frontend/src/ProductsPage.jsx frontend/src/CheckoutPage.jsx \+ frontend/package.json+```++This brings back the Go `tracewaygin` middleware deps, the per-handler `tracewaydb` spans and+manual captures (`#8`), and the React `TracewayProvider` / `useTraceway` / `TracewayErrorBoundary`+usage (`#9`, `#10`, `#11`).++**2. Put `backend/main.go` back to instrumented *and* keep serving the embedded frontend.** Replace+the whole file with:++```go+package main++import (+ "database/sql"+ "net/http"+ "os"++ tracewaygin "go.tracewayapp.com/tracewaygin"++ "github.com/gin-gonic/gin"+ _ "github.com/mattn/go-sqlite3"+)++var db *sql.DB++func main() {+ initDB()++ endpoint := os.Getenv("TRACEWAY_ENDPOINT")+ if endpoint == "" {+ endpoint = "default_token_change_me@http://localhost:8082/api/report"+ }++ router := gin.Default()+ router.Use(corsMiddleware())+ router.Use(tracewaygin.New(+ endpoint,+ tracewaygin.WithDebug(true),+ tracewaygin.WithServerName("shop-demo"),+ tracewaygin.WithVersion("0.1.0"),+ tracewaygin.WithOnErrorRecording(tracewaygin.RecordingUrl|tracewaygin.RecordingQuery|tracewaygin.RecordingHeader|tracewaygin.RecordingBody),+ ))++ router.GET("/api/health", func(c *gin.Context) {+ c.JSON(http.StatusOK, gin.H{"status": "ok"})+ })++ router.GET("/api/products", listProducts)+ router.GET("/api/products/:id", getProduct)+ router.GET("/api/cart", getCart)+ router.POST("/api/cart", addToCart)+ router.DELETE("/api/cart/:id", removeFromCart)+ router.POST("/api/coupon", applyCoupon)+ router.POST("/api/checkout", checkout)++ registerFrontend(router)++ router.Run(":8090")+}++func corsMiddleware() gin.HandlerFunc {+ return func(c *gin.Context) {+ c.Header("Access-Control-Allow-Origin", "*")+ c.Header("Access-Control-Allow-Methods", "GET, POST, DELETE, OPTIONS")+ c.Header("Access-Control-Allow-Headers", "Content-Type, Authorization")+ if c.Request.Method == http.MethodOptions {+ c.AbortWithStatus(http.StatusNoContent)+ return+ }+ c.Next()+ }+}+```++**3. Point both SDKs at your instance + project token.** Use the **same** project token for both.++Frontend — Vite reads this at build time (baked into the bundle):++```bash+echo 'VITE_TW_CONNECTION=<PROJECT_TOKEN>@http://localhost:8082/api/report' > frontend/.env+```++Backend — read at runtime from the environment.++**4. Rebuild and run** (the env var is inherited by the embedded `./shop`):++```bash+TRACEWAY_ENDPOINT="<PROJECT_TOKEN>@http://localhost:8082/api/report" ./build-and-run.sh+```++`build-and-run.sh` reinstalls the now-restored `@tracewayapp/react` dep and rebuilds the bundle+(with source maps). If the Go build complains about the restored modules, run+`cd backend && go mod tidy` once and re-run the script.++**5. Re-drive the same actions** from Act 1 (UI + the curl loops). Now open the Traceway dashboard+for your project:++- **Issues** — the nil-map panic (`assignment to entry in nil map`, `#5`), the+ `index out of range [0] with length 0` panic (`#6`), the declined-card capture (`#8`), and the+ three frontend errors (`#9`, `#10`, `#11`) — each with a count and a stack trace.+- **Endpoints / transactions** — `GET /api/products` is slow with the N+1 fan-out; checkout shows+ the `payment.charge` span.+- Filter by server **`shop-demo`**, version **`0.1.0`**.++---++## Act 3 — Symbolication of the frontend errors++Open one of the **frontend** issues (`#10` CouponBadge, `#11` Quick view, or `#9` add-to-cart). The+stack trace is minified gibberish — something like `index-DSxfDYbG.js:1:48211`. That's because the+browser only ever sees the production bundle. Fix it by uploading the source maps.++**How matching works (no version juggling):** Traceway matches a frame to a map by **filename**+(`index-<hash>.js` → `index-<hash>.js.map`), or by embedded debug-id. The SDK's `version: 0.1.0` is+just metadata for filtering — it is **not** used for map matching. The only rule that matters:+**upload the maps from the exact build you are serving.** `build-and-run.sh` already emitted them+to `frontend/dist/assets/*.map`, and it embedded that same `dist` into the running binary, so the+hashes line up. (If you rebuild, re-upload.)++**1. Get a source-map upload token** — in the dashboard (Project settings → source maps), or via+the API with your dashboard JWT:++```bash+curl -s -X POST http://localhost:8082/api/projects/source-map-token \+ -H "Authorization: Bearer <DASHBOARD_JWT>" -H 'Content-Type: application/json' \+ -d '{}' # -> {"sourceMapToken":"..."}+```++**2. Upload the maps** (and their sibling `.js`, which lets Traceway resolve function names too):++```bash+npx @tracewayapp/sourcemap-upload \+ --url http://localhost:8082 \+ --token "<SOURCEMAP_TOKEN>" \+ --directory frontend/dist+```++Dependency-free alternative with `curl` (single entry bundle):++```bash+cd frontend/dist/assets+curl -sS -X POST http://localhost:8082/api/sourcemaps/upload \+ -H "Authorization: Bearer <SOURCEMAP_TOKEN>" \+ -F "files=@$(ls index-*.js)" \+ -F "files=@$(ls index-*.js.map)" # -> {"uploaded":2}+cd ../../..+```++**3. Trigger the frontend bug again** (e.g. apply a bad coupon for `#10`, or Quick view for `#11`)+so a fresh event arrives, then open that issue. The same frame now reads+`CheckoutPage.jsx:8:...` / `ProductsPage.jsx:...` — your actual source, function names and all.++> Upload the maps **before** the event you want to show symbolicated. A nice narrative is: trigger+> once to show the minified trace, upload, trigger again, open the new event to show it resolved.++---++## Reset++- Back to "bugs, no observability": discard the Act 2 restores+ (`git checkout fd21c509^ -- ...` won't help — restore your stripped branch, or+ `git restore --source=<your-no-tw-commit> -- <files>`), or just keep the `shop-no-tw` branch you+ made in the prereqs and `git switch` to it.+- The SQLite DB is in-memory and reseeded on every start, so cart/orders reset whenever you restart+ the server.diff --git a/testing/shop/README.md b/testing/shop/README.mdindex f44ed3e8..6ad444dc 100644--- a/testing/shop/README.md+++ b/testing/shop/README.md@@ -1,61 +1,56 @@# Demo Shop-A tiny, intentionally-buggy shop app for demoing Traceway. React (Vite) frontend + Go/Gin-backend with in-memory SQLite. No auth, single shared cart. Three pages: products, cart, checkout.+A tiny, intentionally-buggy shop app. React (Vite) frontend + Go/Gin backend with in-memory+SQLite. No auth, single shared cart. Three pages: products, cart, checkout.The app is built to **look like it works** but be mostly **slow**, with a few actions that throwexceptions. Every intentional bug is cataloged in [`BUGS.md`](./BUGS.md).+> **Traceway instrumentation has been removed** from both halves on purpose — it gets re-added+> live during the demo. The bugs in [`BUGS.md`](./BUGS.md) are all still here; right now panics+> are recovered by Gin's own middleware (still 500s) and frontend errors surface in the console+> instead of being reported.+```shop/+├── build-and-run.sh build the frontend, embed it in the backend, compile + run+├── DEMO.md live-demo runbook (bugs first, then add Traceway + symbolication)├── BUGS.md the demo script (what's wrong and where)-├── backend/ Go / Gin / SQLite, serves :8090, reports as "shop-demo"-└── frontend/ React + Vite, serves :5175, proxies /api -> :8090+├── backend/ Go / Gin / SQLite, serves the API + the built frontend on :8090+└── frontend/ React + Vite source```## Prerequisites-- A Traceway backend running locally on **:8082** (the `/api/report` ingestion endpoint).-- A Traceway **project token** — create a project in the dashboard and copy its token.- Go 1.25+ with **CGO enabled** (`mattn/go-sqlite3` needs a C compiler; clang ships with macOS).- Node 18+ and npm.-The backend and frontend share one connection string: `<token>@http://localhost:8082/api/report`.-Use the **same token** on both so backend traces and frontend errors land in the same project.--## Run the backend+## Run```bash-cd backend-go mod tidy # first time only-TRACEWAY_ENDPOINT="<token>@http://localhost:8082/api/report" CGO_ENABLED=1 go run .+./build-and-run.sh```-Serves on **http://localhost:8090**. Without `TRACEWAY_ENDPOINT` it falls back to a-`default_token_change_me@...` placeholder and telemetry won't be accepted.+The script `npm install`s and builds the frontend (with source maps), copies the built `dist/`+into `backend/dist` (embedded into the Go binary at compile time via `//go:embed`), then builds+and starts the backend. Everything is served from a single origin at **http://localhost:8090** —+open it and click around. There is no separate frontend dev server and no CORS to configure.++For the live demo (show bugs first, then add Traceway and watch them get symbolicated on the+dashboard), follow [`DEMO.md`](./DEMO.md).-## Run the frontend+### Frontend dev server (optional)++For hot-reload while editing the frontend, run Vite separately. It serves on **:5175** and+proxies `/api/*` to the backend on `:8090`, so start the backend (via `./run.sh`) first.```bashcd frontend-npm install # first time only-cp .env.example .env # then set VITE_TW_CONNECTION to your token+npm installnpm run dev```-Serves on **http://localhost:5175**. The dev server proxies `/api/*` to the backend on `:8090`,-so there is no CORS to configure. Open the URL and click around.--`.env`:--```-VITE_TW_CONNECTION=<token>@http://localhost:8082/api/report-VITE_API_BASE=/api-```--## Reproduce the telemetry--With both halves running and Traceway up on :8082:+## Reproduce the bugs```bash# 1. Health@@ -75,7 +70,7 @@ curl -s -o /dev/null -w "%{http_code}\n" -X POST localhost:8090/api/checkout \-H 'Content-Type: application/json' -d '{"name":"A","email":"[email protected]","card_last4":"4242"}'```-In the browser at http://localhost:5175:+In the browser at http://localhost:8090:- **Products** load slowly (N+1). "Quick view" throws a frontend exception (#11). "Add to cart"can fail silently when the backend slow path 500s (#9).@@ -83,13 +78,8 @@ In the browser at http://localhost:5175:by the error boundary (#10). "Place order" with an empty cart 500s (#6); with items it is slow(#7) and occasionally declined (#8, a 402).-Then in the Traceway dashboard (:8082): find server **`shop-demo`** / version **`0.1.0`**.-Transactions show slow `GET /api/products` with the N+1 DB-span fan-out; Exceptions show the-nil-map panic, the index-out-of-range panic, the declined-card capture, and the three frontend-errors. Cross-reference each against [`BUGS.md`](./BUGS.md).-## Notes- The in-memory SQLite DB is reseeded on every backend start, so the cart and orders reset on restart.- The slow/fast split is `rand.IntN(4) == 0` per request (see `backend/slow.go`) — about 1 in 4 fast.-- Panics are recovered; the server stays up and returns 500 while still capturing the exception.+- Panics are recovered, so the server stays up and returns 500.diff --git a/testing/shop/backend/.gitignore b/testing/shop/backend/.gitignoreindex 8d55cbd7..719a48b8 100644--- a/testing/shop/backend/.gitignore+++ b/testing/shop/backend/.gitignore@@ -1,2 +1,4 @@/shop/shop-backend+/dist/*+!/dist/.gitkeepdiff --git a/testing/shop/backend/cart.go b/testing/shop/backend/cart.goindex 806a596d..2770ceb9 100644--- a/testing/shop/backend/cart.go+++ b/testing/shop/backend/cart.go@@ -3,34 +3,31 @@ package mainimport ("database/sql""errors"+ "fmt""net/http"- traceway "go.tracewayapp.com"- tracewaydb "go.tracewayapp.com/tracewaydb"-"github.com/gin-gonic/gin")func getCart(c *gin.Context) {ctx := c.Request.Context()- twdb := tracewaydb.NewTwDB(ctx, db)lines := []CartLine{}if fastPath() {- rows, err := twdb.QueryContext(ctx, `+ rows, err := db.QueryContext(ctx, `SELECT ci.id, ci.product_id, p.name, p.price_cents, p.image_url, ci.qtyFROM cart_items ciJOIN products p ON p.id = ci.product_idORDER BY ci.id`)if err != nil {- c.AbortWithError(http.StatusInternalServerError, traceway.NewStackTraceErrorf("load cart (fast): %w", err))+ c.AbortWithError(http.StatusInternalServerError, fmt.Errorf("load cart (fast): %w", err))return}for rows.Next() {var l CartLineif err := rows.Scan(&l.Id, &l.ProductId, &l.Name, &l.PriceCents, &l.ImageUrl, &l.Qty); err != nil {rows.Close()- c.AbortWithError(http.StatusInternalServerError, traceway.NewStackTraceErrorf("scan cart line (fast): %w", err))+ c.AbortWithError(http.StatusInternalServerError, fmt.Errorf("scan cart line (fast): %w", err))return}l.LineTotal = l.PriceCents * l.Qty@@ -38,16 +35,16 @@ func getCart(c *gin.Context) {}rows.Close()} else {- rows, err := twdb.QueryContext(ctx, `SELECT id, product_id, qty FROM cart_items ORDER BY id`)+ rows, err := db.QueryContext(ctx, `SELECT id, product_id, qty FROM cart_items ORDER BY id`)if err != nil {- c.AbortWithError(http.StatusInternalServerError, traceway.NewStackTraceErrorf("load cart: %w", err))+ c.AbortWithError(http.StatusInternalServerError, fmt.Errorf("load cart: %w", err))return}for rows.Next() {var l CartLineif err := rows.Scan(&l.Id, &l.ProductId, &l.Qty); err != nil {rows.Close()- c.AbortWithError(http.StatusInternalServerError, traceway.NewStackTraceErrorf("scan cart line: %w", err))+ c.AbortWithError(http.StatusInternalServerError, fmt.Errorf("scan cart line: %w", err))return}lines = append(lines, l)@@ -56,7 +53,7 @@ func getCart(c *gin.Context) {for i := range lines {slowJitter(10, 40)- prow := twdb.QueryRowContext(ctx, `SELECT name, price_cents, image_url FROM products WHERE id = ?`, lines[i].ProductId)+ prow := db.QueryRowContext(ctx, `SELECT name, price_cents, image_url FROM products WHERE id = ?`, lines[i].ProductId)_ = prow.Scan(&lines[i].Name, &lines[i].PriceCents, &lines[i].ImageUrl)lines[i].LineTotal = lines[i].PriceCents * lines[i].Qty}@@ -80,27 +77,23 @@ func addToCart(c *gin.Context) {req.Qty = 1}- twdb := tracewaydb.NewTwDB(ctx, db)-var existing int- prow := twdb.QueryRowContext(ctx, `SELECT id FROM products WHERE id = ?`, req.ProductId)+ prow := db.QueryRowContext(ctx, `SELECT id FROM products WHERE id = ?`, req.ProductId)if err := prow.Scan(&existing); err != nil {if errors.Is(err, sql.ErrNoRows) {c.JSON(http.StatusNotFound, gin.H{"error": "product not found"})return}- c.AbortWithError(http.StatusInternalServerError, traceway.NewStackTraceErrorf("lookup product: %w", err))+ c.AbortWithError(http.StatusInternalServerError, fmt.Errorf("lookup product: %w", err))return}if !fastPath() {- span := traceway.StartSpan(ctx, "inventory.check")slowJitter(150, 500)- span.End()}- if _, err := twdb.ExecContext(ctx, `INSERT INTO cart_items (product_id, qty) VALUES (?, ?)`, req.ProductId, req.Qty); err != nil {- c.AbortWithError(http.StatusInternalServerError, traceway.NewStackTraceErrorf("add to cart: %w", err))+ if _, err := db.ExecContext(ctx, `INSERT INTO cart_items (product_id, qty) VALUES (?, ?)`, req.ProductId, req.Qty); err != nil {+ c.AbortWithError(http.StatusInternalServerError, fmt.Errorf("add to cart: %w", err))return}c.JSON(http.StatusCreated, gin.H{"status": "added"})@@ -109,15 +102,14 @@ func addToCart(c *gin.Context) {func removeFromCart(c *gin.Context) {ctx := c.Request.Context()id := c.Param("id")- twdb := tracewaydb.NewTwDB(ctx, db)if !fastPath() {slowJitter(50, 150)}- res, err := twdb.ExecContext(ctx, `DELETE FROM cart_items WHERE id = ?`, id)+ res, err := db.ExecContext(ctx, `DELETE FROM cart_items WHERE id = ?`, id)if err != nil {- c.AbortWithError(http.StatusInternalServerError, traceway.NewStackTraceErrorf("remove from cart: %w", err))+ c.AbortWithError(http.StatusInternalServerError, fmt.Errorf("remove from cart: %w", err))return}affected, _ := res.RowsAffected()diff --git a/testing/shop/backend/checkout.go b/testing/shop/backend/checkout.goindex 402d2a86..268c7f87 100644--- a/testing/shop/backend/checkout.go+++ b/testing/shop/backend/checkout.go@@ -5,9 +5,6 @@ import ("math/rand/v2""net/http"- traceway "go.tracewayapp.com"- tracewaydb "go.tracewayapp.com/tracewaydb"-"github.com/gin-gonic/gin")@@ -19,15 +16,13 @@ func checkout(c *gin.Context) {return}- twdb := tracewaydb.NewTwDB(ctx, db)-- rows, err := twdb.QueryContext(ctx, `+ rows, err := db.QueryContext(ctx, `SELECT ci.id, ci.product_id, p.name, p.price_cents, p.image_url, ci.qtyFROM cart_items ciJOIN products p ON p.id = ci.product_idORDER BY ci.id`)if err != nil {- c.AbortWithError(http.StatusInternalServerError, traceway.NewStackTraceErrorf("load cart for checkout: %w", err))+ c.AbortWithError(http.StatusInternalServerError, fmt.Errorf("load cart for checkout: %w", err))return}lines := []CartLine{}@@ -35,7 +30,7 @@ func checkout(c *gin.Context) {var l CartLineif err := rows.Scan(&l.Id, &l.ProductId, &l.Name, &l.PriceCents, &l.ImageUrl, &l.Qty); err != nil {rows.Close()- c.AbortWithError(http.StatusInternalServerError, traceway.NewStackTraceErrorf("scan checkout line: %w", err))+ c.AbortWithError(http.StatusInternalServerError, fmt.Errorf("scan checkout line: %w", err))return}l.LineTotal = l.PriceCents * l.Qty@@ -43,14 +38,11 @@ func checkout(c *gin.Context) {}rows.Close()- pay := traceway.StartSpan(ctx, "payment.charge")if !fastPath() {slowJitter(300, 1200)}- pay.End()if rand.IntN(6) == 0 {- traceway.CaptureExceptionWithContext(ctx, traceway.NewStackTraceErrorf("payment declined for card ****%s", req.CardLast4))c.JSON(http.StatusPaymentRequired, gin.H{"error": "payment declined, please try another card"})return}@@ -62,12 +54,9 @@ func checkout(c *gin.Context) {firstItem := lines[0]- persist := traceway.StartSpan(ctx, "order.persist")orderId := fmt.Sprintf("ORD-%d", rand.IntN(900000)+100000)- _, err = twdb.ExecContext(ctx, `DELETE FROM cart_items`)- persist.End()- if err != nil {- c.AbortWithError(http.StatusInternalServerError, traceway.NewStackTraceErrorf("clear cart: %w", err))+ if _, err = db.ExecContext(ctx, `DELETE FROM cart_items`); err != nil {+ c.AbortWithError(http.StatusInternalServerError, fmt.Errorf("clear cart: %w", err))return}diff --git a/testing/shop/backend/coupon.go b/testing/shop/backend/coupon.goindex 35a724c3..dbac9e7e 100644--- a/testing/shop/backend/coupon.go+++ b/testing/shop/backend/coupon.go@@ -4,11 +4,9 @@ import ("context""database/sql""errors"+ "fmt""net/http"- traceway "go.tracewayapp.com"- tracewaydb "go.tracewayapp.com/tracewaydb"-"github.com/gin-gonic/gin")@@ -22,17 +20,15 @@ func applyCoupon(c *gin.Context) {return}- twdb := tracewaydb.NewTwDB(ctx, db)-var percentOff, active int- row := twdb.QueryRowContext(ctx, `SELECT percent_off, active FROM coupons WHERE code = ?`, req.Code)+ row := db.QueryRowContext(ctx, `SELECT percent_off, active FROM coupons WHERE code = ?`, req.Code)if err := row.Scan(&percentOff, &active); err != nil {if errors.Is(err, sql.ErrNoRows) {- c.Error(traceway.NewStackTraceErrorf("unknown coupon code: %s", req.Code))+ c.Error(fmt.Errorf("unknown coupon code: %s", req.Code))c.JSON(http.StatusBadRequest, gin.H{"error": "invalid coupon code"})return}- c.AbortWithError(http.StatusInternalServerError, traceway.NewStackTraceErrorf("lookup coupon: %w", err))+ c.AbortWithError(http.StatusInternalServerError, fmt.Errorf("lookup coupon: %w", err))return}if active == 0 {@@ -48,7 +44,7 @@ func applyCoupon(c *gin.Context) {couponHits[req.Code]++}- total := cartTotal(ctx, twdb)+ total := cartTotal(ctx, db)discount := total * percentOff / 100c.JSON(http.StatusOK, gin.H{"code": req.Code,@@ -58,8 +54,8 @@ func applyCoupon(c *gin.Context) {})}-func cartTotal(ctx context.Context, twdb *tracewaydb.TwDB) int {- row := twdb.QueryRowContext(ctx, `+func cartTotal(ctx context.Context, database *sql.DB) int {+ row := database.QueryRowContext(ctx, `SELECT COALESCE(SUM(p.price_cents * ci.qty), 0)FROM cart_items ciJOIN products p ON p.id = ci.product_id`)diff --git a/testing/shop/backend/dist/.gitkeep b/testing/shop/backend/dist/.gitkeepnew file mode 100644index 00000000..e69de29bdiff --git a/testing/shop/backend/go.mod b/testing/shop/backend/go.modindex 2b9b6442..ccb62d79 100644--- a/testing/shop/backend/go.mod+++ b/testing/shop/backend/go.mod@@ -5,52 +5,30 @@ go 1.25.1require (github.com/gin-gonic/gin v1.11.0github.com/mattn/go-sqlite3 v1.14.33- go.tracewayapp.com v1.0.4- go.tracewayapp.com/tracewaydb v0.0.0-00010101000000-000000000000- go.tracewayapp.com/tracewaygin v0.0.0-00010101000000-000000000000)require (github.com/bytedance/sonic v1.14.0 // indirectgithub.com/bytedance/sonic/loader v0.3.0 // indirect- github.com/cespare/xxhash/v2 v2.3.0 // indirectgithub.com/cloudwego/base64x v0.1.6 // indirect- github.com/ebitengine/purego v0.10.1 // indirectgithub.com/gabriel-vasile/mimetype v1.4.8 // indirectgithub.com/gin-contrib/sse v1.1.0 // indirect- github.com/go-logr/logr v1.4.3 // indirect- github.com/go-logr/stdr v1.2.2 // indirect- github.com/go-ole/go-ole v1.3.0 // indirectgithub.com/go-playground/locales v0.14.1 // indirectgithub.com/go-playground/universal-translator v0.18.1 // indirectgithub.com/go-playground/validator/v10 v10.27.0 // indirectgithub.com/goccy/go-json v0.10.2 // indirectgithub.com/goccy/go-yaml v1.18.0 // indirect- github.com/google/uuid v1.6.0 // indirectgithub.com/json-iterator/go v1.1.12 // indirectgithub.com/klauspost/cpuid/v2 v2.3.0 // indirectgithub.com/leodido/go-urn v1.4.0 // indirect- github.com/lufia/plan9stats v0.0.0-20260330125221-c963978e514e // indirectgithub.com/mattn/go-isatty v0.0.20 // indirectgithub.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirectgithub.com/modern-go/reflect2 v1.0.2 // indirectgithub.com/pelletier/go-toml/v2 v2.2.4 // indirect- github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirectgithub.com/quic-go/qpack v0.5.1 // indirectgithub.com/quic-go/quic-go v0.54.0 // indirect- github.com/shirou/gopsutil/v4 v4.26.4 // indirect- github.com/tklauser/go-sysconf v0.4.0 // indirect- github.com/tklauser/numcpus v0.12.0 // indirectgithub.com/twitchyliquid64/golang-asm v0.15.1 // indirectgithub.com/ugorji/go/codec v1.3.0 // indirect- github.com/yusufpapurcu/wmi v1.2.4 // indirect- go.opentelemetry.io/auto/sdk v1.2.1 // indirect- go.opentelemetry.io/contrib/instrumentation/host v0.69.0 // indirect- go.opentelemetry.io/otel v1.44.0 // indirect- go.opentelemetry.io/otel/metric v1.44.0 // indirect- go.opentelemetry.io/otel/sdk v1.44.0 // indirect- go.opentelemetry.io/otel/sdk/metric v1.44.0 // indirect- go.opentelemetry.io/otel/trace v1.44.0 // indirectgo.uber.org/mock v0.5.0 // indirectgolang.org/x/arch v0.20.0 // indirectgolang.org/x/crypto v0.40.0 // indirect@@ -62,9 +40,3 @@ require (golang.org/x/tools v0.34.0 // indirectgoogle.golang.org/protobuf v1.36.9 // indirect)--replace go.tracewayapp.com => ../../../../go-client--replace go.tracewayapp.com/tracewaydb => ../../../../go-client/tracewaydb--replace go.tracewayapp.com/tracewaygin => ../../../../go-client/tracewaygindiff --git a/testing/shop/backend/go.sum b/testing/shop/backend/go.sumindex 63b92f79..9cc86c40 100644--- a/testing/shop/backend/go.sum+++ b/testing/shop/backend/go.sum@@ -1,32 +1,18 @@-github.com/DATA-DOG/go-sqlmock v1.5.2 h1:OcvFkGmslmlZibjAjaHm3L//6LiuBgolP7OputlJIzU=-github.com/DATA-DOG/go-sqlmock v1.5.2/go.mod h1:88MAG/4G7SMwSE3CeA0ZKzrT5CiOU3OJ+JlNzwDqpNU=github.com/bytedance/sonic v1.14.0 h1:/OfKt8HFw0kh2rj8N0F6C/qPGRESq0BbaNZgcNXXzQQ=github.com/bytedance/sonic v1.14.0/go.mod h1:WoEbx8WTcFJfzCe0hbmyTGrfjt8PzNEBdxlNUO24NhA=github.com/bytedance/sonic/loader v0.3.0 h1:dskwH8edlzNMctoruo8FPTJDF3vLtDT0sXZwvZJyqeA=github.com/bytedance/sonic/loader v0.3.0/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI=-github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=-github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=github.com/cloudwego/base64x v0.1.6 h1:t11wG9AECkCDk5fMSoxmufanudBtJ+/HemLstXDLI2M=github.com/cloudwego/base64x v0.1.6/go.mod h1:OFcloc187FXDaYHvrNIjxSe8ncn0OOM8gEHfghB2IPU=github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=-github.com/ebitengine/purego v0.10.1 h1:dewVBCBT2GaMu1SrNTYxQhgQBethzfhiwvZiLGP/qyY=-github.com/ebitengine/purego v0.10.1/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ=github.com/gabriel-vasile/mimetype v1.4.8 h1:FfZ3gj38NjllZIeJAmMhr+qKL8Wu+nOoI3GqacKw1NM=github.com/gabriel-vasile/mimetype v1.4.8/go.mod h1:ByKUIKGjh1ODkGM1asKUbQZOLGrPjydw3hYPU2YU9t8=github.com/gin-contrib/sse v1.1.0 h1:n0w2GMuUpWDVp7qSpvze6fAu9iRxJY4Hmj6AmBOU05w=github.com/gin-contrib/sse v1.1.0/go.mod h1:hxRZ5gVpWMT7Z0B0gSNYqqsSCNIJMjzvm6fqCz9vjwM=github.com/gin-gonic/gin v1.11.0 h1:OW/6PLjyusp2PPXtyxKHU0RbX6I/l28FTdDlae5ueWk=github.com/gin-gonic/gin v1.11.0/go.mod h1:+iq/FyxlGzII0KHiBGjuNn4UNENUlKbGlNmc+W50Dls=-github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=-github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=-github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=-github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=-github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=-github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=-github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE=-github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78=github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=@@ -42,16 +28,12 @@ github.com/goccy/go-yaml v1.18.0/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7Lkgithub.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=-github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=-github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y=github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=-github.com/lufia/plan9stats v0.0.0-20260330125221-c963978e514e h1:Q6MvJtQK/iRcRtzAscm/zF23XxJlbECiGPyRicsX+Ak=-github.com/lufia/plan9stats v0.0.0-20260330125221-c963978e514e/go.mod h1:autxFIvghDt3jPTLoqZ9OZ7s9qTGNAWmYCjVFWPX/zg=github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=github.com/mattn/go-sqlite3 v1.14.33 h1:A5blZ5ulQo2AtayQ9/limgHEkFreKj1Dv226a1K73s0=@@ -64,14 +46,10 @@ github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=-github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 h1:o4JXh1EVt9k/+g42oCprj/FisM4qX9L3sZB3upGN2ZU=-github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=github.com/quic-go/qpack v0.5.1 h1:giqksBPnT/HDtZ6VhtFKgoLOWmlyo9Ei6u9PqzIMbhI=github.com/quic-go/qpack v0.5.1/go.mod h1:+PC4XFrEskIVkcLzpEkbLqq1uCoxPhQuvK5rH1ZgaEg=github.com/quic-go/quic-go v0.54.0 h1:6s1YB9QotYI6Ospeiguknbp2Znb/jZYjZLRXn9kMQBg=github.com/quic-go/quic-go v0.54.0/go.mod h1:e68ZEaCdyviluZmy44P6Iey98v/Wfz6HCjQEm+l8zTY=-github.com/shirou/gopsutil/v4 v4.26.4 h1:B4SXVbcwTyrocPHEmWBC4uCYr4Xcu3MK1TXqbprAOWY=-github.com/shirou/gopsutil/v4 v4.26.4/go.mod h1:LZ6ewCSkBqUpvSOf+LsTGnRinC6iaNUNMGBtDkJBaLQ=github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=@@ -81,32 +59,10 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoOgithub.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=-github.com/tklauser/go-sysconf v0.4.0 h1:7H0uAN+7RkwWRaxhYXDLqa5V3LPrJeV8wmD9dRUgPQU=-github.com/tklauser/go-sysconf v0.4.0/go.mod h1:8mTNWyog7H+MpKijp4VmKJAd2bbYQ2zuUwkYRbUArPI=-github.com/tklauser/numcpus v0.12.0 h1:NR85qdvHA9pFse3x3weVZ0r0ST8R6l5RHbZrlRaqob4=-github.com/tklauser/numcpus v0.12.0/go.mod h1:ABHeXzJnr/qqwguhClkZKT1/8VABcYrsyUiUGobwWJg=github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=github.com/ugorji/go/codec v1.3.0 h1:Qd2W2sQawAfG8XSvzwhBeoGq71zXOC/Q1E9y/wUcsUA=github.com/ugorji/go/codec v1.3.0/go.mod h1:pRBVtBSKl77K30Bv8R2P+cLSGaTtex6fsA2Wjqmfxj4=-github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0=-github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=-go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64=-go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y=-go.opentelemetry.io/contrib/instrumentation/host v0.69.0 h1:N/wKAdIOKd9U4bwiwY3j95e2ZR48onTMR/NI/SZQ/a4=-go.opentelemetry.io/contrib/instrumentation/host v0.69.0/go.mod h1:rE1Bxmu3mwcmyTJV4EQdJ/C6zCUnuT9jCiinhRXLAXc=-go.opentelemetry.io/otel v1.44.0 h1:JjwHmHpA4iZ3wBxluu2fbbE7j4kqlE8jXyAyPXH7HqU=-go.opentelemetry.io/otel v1.44.0/go.mod h1:BMgjTHL9WPRlRjL2oZCBTL4whCGtXch2H4BhOPIAyYc=-go.opentelemetry.io/otel/metric v1.44.0 h1:1w0gILTcHdr3YI+ixLyjemwrVnsMURbTZFrSYCdDdmc=-go.opentelemetry.io/otel/metric v1.44.0/go.mod h1:8O7hanEPBNgEMmybD3s2VBKcgWOCsA6tzHBPODAiquo=-go.opentelemetry.io/otel/metric/x v0.66.0 h1:YkCrx1zLOChi9ZcZ6euupOcsgzbVlec7D/xoEU1+cTA=-go.opentelemetry.io/otel/metric/x v0.66.0/go.mod h1:d1+BDj9t96do0/1LoU1ayfCv79ZgNE41qbhBvnMOBZk=-go.opentelemetry.io/otel/sdk v1.44.0 h1:nHYwb9lK+fJPU/dnT6s7W7Z8itMWyqrnVfbheVYrZ58=-go.opentelemetry.io/otel/sdk v1.44.0/go.mod h1:Osuydd3Se74nqjAKxid74N5eC+jfEqfTegHRnq58oK0=-go.opentelemetry.io/otel/sdk/metric v1.44.0 h1:3LlKgI+VjbVsjNRFZJZAJ30WjXC5VkNRks6si09iEfI=-go.opentelemetry.io/otel/sdk/metric v1.44.0/go.mod h1:5B5pMARnXxKhltooO4xUuCBorl65a4EpnTalObqOigA=-go.opentelemetry.io/otel/trace v1.44.0 h1:jxF5CsGYCe74MCRx2X4g7WsY/VBKRqqpNvXlX/6gtIk=-go.opentelemetry.io/otel/trace v1.44.0/go.mod h1:oLl1jrMQAVo6v3GAggN+1VH9VIz9iUSvW53sW1Q8PIE=go.uber.org/mock v0.5.0 h1:KAMbZvZPyBPWgD14IrIQ38QCyjwpvVVV6K/bHl1IwQU=go.uber.org/mock v0.5.0/go.mod h1:ge71pBPLYDk7QIi1LupWxdAykm7KIEFchiOqd6z7qMM=golang.org/x/arch v0.20.0 h1:dx1zTU0MAE98U+TQ8BLl7XsJbgze2WnNKF/8tGp/Q6c=@@ -119,9 +75,6 @@ golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs=golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8=golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw=golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=-golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=-golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=-golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=golang.org/x/sys v0.45.0 h1:dO4czNzziLiiXplLQgBCEpCvXQ3dnkn0SdaZSYdQ+FY=golang.org/x/sys v0.45.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=diff --git a/testing/shop/backend/main.go b/testing/shop/backend/main.goindex 8c422299..e1d12970 100644--- a/testing/shop/backend/main.go+++ b/testing/shop/backend/main.go@@ -3,9 +3,6 @@ package mainimport ("database/sql""net/http"- "os"-- tracewaygin "go.tracewayapp.com/tracewaygin""github.com/gin-gonic/gin"_ "github.com/mattn/go-sqlite3"@@ -16,21 +13,8 @@ var db *sql.DBfunc main() {initDB()- endpoint := os.Getenv("TRACEWAY_ENDPOINT")- if endpoint == "" {- endpoint = "default_token_change_me@http://localhost:8082/api/report"- }-router := gin.Default()-router.Use(corsMiddleware())- router.Use(tracewaygin.New(- endpoint,- tracewaygin.WithDebug(true),- tracewaygin.WithServerName("shop-demo"),- tracewaygin.WithVersion("0.1.0"),- tracewaygin.WithOnErrorRecording(tracewaygin.RecordingUrl|tracewaygin.RecordingQuery|tracewaygin.RecordingHeader|tracewaygin.RecordingBody),- ))router.GET("/api/health", func(c *gin.Context) {c.JSON(http.StatusOK, gin.H{"status": "ok"})@@ -46,6 +30,8 @@ func main() {router.POST("/api/coupon", applyCoupon)router.POST("/api/checkout", checkout)+ registerFrontend(router)+router.Run(":8090")}diff --git a/testing/shop/backend/products.go b/testing/shop/backend/products.goindex 8ccdd3da..49afa916 100644--- a/testing/shop/backend/products.go+++ b/testing/shop/backend/products.go@@ -3,20 +3,17 @@ package mainimport ("database/sql""errors"+ "fmt""net/http"- traceway "go.tracewayapp.com"- tracewaydb "go.tracewayapp.com/tracewaydb"-"github.com/gin-gonic/gin")func listProducts(c *gin.Context) {ctx := c.Request.Context()- twdb := tracewaydb.NewTwDB(ctx, db)if fastPath() {- rows, err := twdb.QueryContext(ctx, `+ rows, err := db.QueryContext(ctx, `SELECT p.id, p.name, p.description, p.price_cents, p.image_url, p.stock, p.category_id,c.name AS category, COUNT(r.id) AS review_countFROM products p@@ -25,7 +22,7 @@ func listProducts(c *gin.Context) {GROUP BY p.idORDER BY p.id`)if err != nil {- c.AbortWithError(http.StatusInternalServerError, traceway.NewStackTraceErrorf("list products (fast): %w", err))+ c.AbortWithError(http.StatusInternalServerError, fmt.Errorf("list products (fast): %w", err))return}products := []Product{}@@ -33,7 +30,7 @@ func listProducts(c *gin.Context) {var p Productif err := rows.Scan(&p.Id, &p.Name, &p.Description, &p.PriceCents, &p.ImageUrl, &p.Stock, &p.CategoryId, &p.Category, &p.ReviewCount); err != nil {rows.Close()- c.AbortWithError(http.StatusInternalServerError, traceway.NewStackTraceErrorf("scan product (fast): %w", err))+ c.AbortWithError(http.StatusInternalServerError, fmt.Errorf("scan product (fast): %w", err))return}products = append(products, p)@@ -43,9 +40,9 @@ func listProducts(c *gin.Context) {return}- rows, err := twdb.QueryContext(ctx, `SELECT id, name, description, price_cents, image_url, stock, category_id FROM products ORDER BY id`)+ rows, err := db.QueryContext(ctx, `SELECT id, name, description, price_cents, image_url, stock, category_id FROM products ORDER BY id`)if err != nil {- c.AbortWithError(http.StatusInternalServerError, traceway.NewStackTraceErrorf("list products: %w", err))+ c.AbortWithError(http.StatusInternalServerError, fmt.Errorf("list products: %w", err))return}products := []Product{}@@ -53,7 +50,7 @@ func listProducts(c *gin.Context) {var p Productif err := rows.Scan(&p.Id, &p.Name, &p.Description, &p.PriceCents, &p.ImageUrl, &p.Stock, &p.CategoryId); err != nil {rows.Close()- c.AbortWithError(http.StatusInternalServerError, traceway.NewStackTraceErrorf("scan product: %w", err))+ c.AbortWithError(http.StatusInternalServerError, fmt.Errorf("scan product: %w", err))return}products = append(products, p)@@ -62,10 +59,10 @@ func listProducts(c *gin.Context) {for i := range products {slowJitter(15, 50)- catRow := twdb.QueryRowContext(ctx, `SELECT name FROM categories WHERE id = ?`, products[i].CategoryId)+ catRow := db.QueryRowContext(ctx, `SELECT name FROM categories WHERE id = ?`, products[i].CategoryId)_ = catRow.Scan(&products[i].Category)- countRow := twdb.QueryRowContext(ctx, `SELECT COUNT(*) FROM reviews WHERE product_id = ?`, products[i].Id)+ countRow := db.QueryRowContext(ctx, `SELECT COUNT(*) FROM reviews WHERE product_id = ?`, products[i].Id)_ = countRow.Scan(&products[i].ReviewCount)}@@ -75,26 +72,25 @@ func listProducts(c *gin.Context) {func getProduct(c *gin.Context) {ctx := c.Request.Context()id := c.Param("id")- twdb := tracewaydb.NewTwDB(ctx, db)var detail ProductDetail- row := twdb.QueryRowContext(ctx, `SELECT id, name, description, price_cents, image_url, stock, category_id FROM products WHERE id = ?`, id)+ row := db.QueryRowContext(ctx, `SELECT id, name, description, price_cents, image_url, stock, category_id FROM products WHERE id = ?`, id)if err := row.Scan(&detail.Id, &detail.Name, &detail.Description, &detail.PriceCents, &detail.ImageUrl, &detail.Stock, &detail.CategoryId); err != nil {if errors.Is(err, sql.ErrNoRows) {c.JSON(http.StatusNotFound, gin.H{"error": "product not found"})return}- c.AbortWithError(http.StatusInternalServerError, traceway.NewStackTraceErrorf("get product: %w", err))+ c.AbortWithError(http.StatusInternalServerError, fmt.Errorf("get product: %w", err))return}- catRow := twdb.QueryRowContext(ctx, `SELECT name FROM categories WHERE id = ?`, detail.CategoryId)+ catRow := db.QueryRowContext(ctx, `SELECT name FROM categories WHERE id = ?`, detail.CategoryId)_ = catRow.Scan(&detail.Category)if fastPath() {- rows, err := twdb.QueryContext(ctx, `SELECT id, product_id, rating, body FROM reviews WHERE product_id = ? ORDER BY id`, detail.Id)+ rows, err := db.QueryContext(ctx, `SELECT id, product_id, rating, body FROM reviews WHERE product_id = ? ORDER BY id`, detail.Id)if err != nil {- c.AbortWithError(http.StatusInternalServerError, traceway.NewStackTraceErrorf("get reviews (fast): %w", err))+ c.AbortWithError(http.StatusInternalServerError, fmt.Errorf("get reviews (fast): %w", err))return}for rows.Next() {@@ -109,11 +105,9 @@ func getProduct(c *gin.Context) {return}- span := traceway.StartSpan(ctx, "load_reviews")- idRows, err := twdb.QueryContext(ctx, `SELECT id FROM reviews WHERE product_id = ?`, detail.Id)+ idRows, err := db.QueryContext(ctx, `SELECT id FROM reviews WHERE product_id = ?`, detail.Id)if err != nil {- span.End()- c.AbortWithError(http.StatusInternalServerError, traceway.NewStackTraceErrorf("list review ids: %w", err))+ c.AbortWithError(http.StatusInternalServerError, fmt.Errorf("list review ids: %w", err))return}reviewIds := []int{}@@ -128,16 +122,13 @@ func getProduct(c *gin.Context) {for _, rid := range reviewIds {slowJitter(10, 30)var rv Review- rrow := twdb.QueryRowContext(ctx, `SELECT id, product_id, rating, body FROM reviews WHERE id = ?`, rid)+ rrow := db.QueryRowContext(ctx, `SELECT id, product_id, rating, body FROM reviews WHERE id = ?`, rid)if err := rrow.Scan(&rv.Id, &rv.ProductId, &rv.Rating, &rv.Body); err == nil {detail.Reviews = append(detail.Reviews, rv)}}- span.End()- rec := traceway.StartSpan(ctx, "recommendations.fetch")slowJitter(80, 200)- rec.End()detail.ReviewCount = len(detail.Reviews)c.JSON(http.StatusOK, detail)diff --git a/testing/shop/backend/web.go b/testing/shop/backend/web.gonew file mode 100644index 00000000..a86c815d--- /dev/null+++ b/testing/shop/backend/web.go@@ -0,0 +1,31 @@+package main++import (+ "embed"+ "io/fs"+ "net/http"+ "strings"++ "github.com/gin-gonic/gin"+)++//go:embed all:dist+var distFS embed.FS++func registerFrontend(router *gin.Engine) {+ dist, err := fs.Sub(distFS, "dist")+ if err != nil {+ panic(err)+ }+ fileServer := http.FileServer(http.FS(dist))++ router.NoRoute(func(c *gin.Context) {+ path := strings.TrimPrefix(c.Request.URL.Path, "/")+ if path != "" {+ if _, err := fs.Stat(dist, path); err != nil {+ c.Request.URL.Path = "/"+ }+ }+ fileServer.ServeHTTP(c.Writer, c.Request)+ })+}diff --git a/testing/shop/build-and-run.sh b/testing/shop/build-and-run.shnew file mode 100755index 00000000..aaff5cb1--- /dev/null+++ b/testing/shop/build-and-run.sh@@ -0,0 +1,23 @@+#!/usr/bin/env bash+set -euo pipefail++cd "$(dirname "$0")"++echo "==> Building frontend (with source maps)"+cd frontend+npm install+npm run build+cd ..++echo "==> Embedding frontend into backend"+rm -rf backend/dist+mkdir -p backend/dist+cp -R frontend/dist/. backend/dist/+touch backend/dist/.gitkeep++echo "==> Building backend"+cd backend+CGO_ENABLED=1 go build -o shop .++echo "==> Starting shop on http://localhost:8090"+exec ./shopdiff --git a/testing/shop/frontend/.env.example b/testing/shop/frontend/.env.exampleindex 0bd4c357..0a0c3037 100644--- a/testing/shop/frontend/.env.example+++ b/testing/shop/frontend/.env.example@@ -1,2 +1 @@-VITE_TW_CONNECTION=default_token_change_me@http://localhost:8082/api/reportVITE_API_BASE=/apidiff --git a/testing/shop/frontend/package-lock.json b/testing/shop/frontend/package-lock.jsonindex 96a6912c..1cdd618b 100644--- a/testing/shop/frontend/package-lock.json+++ b/testing/shop/frontend/package-lock.json@@ -6,7 +6,6 @@"": {"name": "shop-frontend","dependencies": {- "@tracewayapp/react": "file:../../../../js-client/packages/react","react": "^18.3.1","react-dom": "^18.3.1"},@@ -15,17 +14,6 @@"vite": "^7.0.0"}},- "../../../../js-client/packages/react": {- "name": "@tracewayapp/react",- "version": "1.2.0",- "dependencies": {- "@tracewayapp/frontend": "1.2.0"- },- "peerDependencies": {- "react": ">=18.0.0",- "react-dom": ">=18.0.0"- }- },"node_modules/@babel/code-frame": {"version": "7.29.7","resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.29.7.tgz",@@ -1157,10 +1145,6 @@"win32"]},- "node_modules/@tracewayapp/react": {- "resolved": "../../../../js-client/packages/react",- "link": true- },"node_modules/@types/babel__core": {"version": "7.20.5","resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.5.tgz",diff --git a/testing/shop/frontend/package.json b/testing/shop/frontend/package.jsonindex 8623e42b..3dc02877 100644--- a/testing/shop/frontend/package.json+++ b/testing/shop/frontend/package.json@@ -8,7 +8,6 @@"preview": "vite preview"},"dependencies": {- "@tracewayapp/react": "file:../../../../js-client/packages/react","react": "^18.3.1","react-dom": "^18.3.1"},diff --git a/testing/shop/frontend/src/CheckoutPage.jsx b/testing/shop/frontend/src/CheckoutPage.jsxindex 50e38b4d..018d9298 100644--- a/testing/shop/frontend/src/CheckoutPage.jsx+++ b/testing/shop/frontend/src/CheckoutPage.jsx@@ -1,7 +1,19 @@import React, { useState } from 'react'-import { useTraceway, TracewayErrorBoundary } from '@tracewayapp/react'import { applyCoupon, checkout, formatPrice } from './api.js'+class ErrorBoundary extends React.Component {+ constructor(props) {+ super(props)+ this.state = { failed: false }+ }+ static getDerivedStateFromError() {+ return { failed: true }+ }+ render() {+ return this.state.failed ? this.props.fallback : this.props.children+ }+}+function CouponBadge({ discount }) {return (<div className="coupon-badge">@@ -11,7 +23,6 @@ function CouponBadge({ discount }) {}export default function CheckoutPage({ onDone }) {- const { captureException } = useTraceway()const [code, setCode] = useState('')const [discount, setDiscount] = useState(undefined)const [couponError, setCouponError] = useState('')@@ -26,7 +37,6 @@ export default function CheckoutPage({ onDone }) {const res = await applyCoupon(code)setDiscount({ percent: res.percent_off, cents: res.discount_cents })} catch (e) {- captureException(e)setCouponError(e.message)setDiscount(null)}@@ -83,9 +93,9 @@ export default function CheckoutPage({ onDone }) {</div>{couponError && <div className="error-inline">{couponError}</div>}{discount !== undefined && (- <TracewayErrorBoundary fallback={<div className="error-inline">Could not display coupon.</div>}>+ <ErrorBoundary fallback={<div className="error-inline">Could not display coupon.</div>}><CouponBadge discount={discount} />- </TracewayErrorBoundary>+ </ErrorBoundary>)}</section>diff --git a/testing/shop/frontend/src/ProductsPage.jsx b/testing/shop/frontend/src/ProductsPage.jsxindex a71638e0..eb425612 100644--- a/testing/shop/frontend/src/ProductsPage.jsx+++ b/testing/shop/frontend/src/ProductsPage.jsx@@ -1,9 +1,7 @@import React, { useEffect, useState } from 'react'-import { useTraceway } from '@tracewayapp/react'import { getProducts, addToCart, formatPrice } from './api.js'export default function ProductsPage({ onCartChanged }) {- const { captureException } = useTraceway()const [products, setProducts] = useState([])const [loading, setLoading] = useState(true)const [error, setError] = useState('')@@ -41,8 +39,7 @@ export default function ProductsPage({ onCartChanged }) {try {const variant = p.variants.find((v) => v.default)setQuickView({ name: p.name, label: variant.label })- } catch (e) {- captureException(e)+ } catch {setQuickView({ name: p.name, label: 'No variants available' })}}diff --git a/testing/shop/frontend/src/main.jsx b/testing/shop/frontend/src/main.jsxindex 3ab5cf0a..fe5a9e3c 100644--- a/testing/shop/frontend/src/main.jsx+++ b/testing/shop/frontend/src/main.jsx@@ -1,15 +1,6 @@import React from 'react'import { createRoot } from 'react-dom/client'-import { TracewayProvider } from '@tracewayapp/react'import App from './App.jsx'import './styles.css'-const connectionString =- import.meta.env.VITE_TW_CONNECTION ||- 'default_token_change_me@http://localhost:8082/api/report'--createRoot(document.getElementById('root')).render(- <TracewayProvider connectionString={connectionString} options={{ debug: true, version: '0.1.0' }}>- <App />- </TracewayProvider>-)+createRoot(document.getElementById('root')).render(<App />)diff --git a/testing/shop/frontend/vite.config.mjs b/testing/shop/frontend/vite.config.mjsindex 42385e32..5ff58a1d 100644--- a/testing/shop/frontend/vite.config.mjs+++ b/testing/shop/frontend/vite.config.mjs@@ -2,6 +2,9 @@ import { defineConfig } from 'vite'import react from '@vitejs/plugin-react'export default defineConfig({+ build: {+ sourcemap: true+ },server: {port: 5175,proxy: {