Debugging Demo Application
Issue 1: Frontend and Backend Traces Not Connecting
Symptoms
- You see frontend traces in Sentry
- You see backend traces in Sentry
- But they’re separate - not in the same trace
Diagnosis Steps
-
Check for trace headers in browser
Open DevTools > Network tab > Click an API request > Request Headers
You should see:
traceparent: 00-...sentry-trace: ...baggage: ...If headers are missing:
- Check
propagateTraceparent: trueinfrontend/instrument-sentry.js - Verify backend URL is in
tracePropagationTargets
- Check
-
Verify tracePropagationTargets
In
frontend/instrument-sentry.js:tracePropagationTargets: [/^\//, // Same-origin requests/^http:\/\/localhost:3000/, // Your backend URL],The regex must match your backend URL exactly!
-
Check CORS configuration
The backend must allow trace headers. In
api/src/index.js, CORS should be configured:app.use(cors({origin: ['http://localhost:5173', 'http://localhost:5174'],credentials: true,})); -
Verify both services send to same Sentry org
- Frontend and backend can use different projects
- But they must be in the same Sentry organization - otherwise, Sentry can’t link the traces
Issue 2: Traces Missing Database Queries
Symptoms
- Traces appear in Sentry
- But database query spans are missing
- Should see spans with
db.system: postgresql
Solutions
-
Check that Neon database is accessible
This workshop uses Neon - a serverless PostgreSQL database. Neon free tier databases may expire after a period of inactivity.
Check for database connection errors:
Look for errors in the backend logs when starting the server:
Terminal window # In the api directorynpm run demo:directIf you see errors like:
ECONNREFUSEDdatabase does not existauthentication failed
Your Neon database may have expired or the connection string is incorrect.
-
Set up a new Neon database
If your database has expired, the easiest way to create a new one is using the Neon CLI:
Terminal window # In the api directorynpx neondb -yThis will automatically:
- Create a new Neon database
- Configure your
DATABASE_URLin the.envfile - Set up authentication
Alternative: Manual setup
If you prefer to set it up manually:
- Go to console.neon.tech
- Create a new project (or use an existing one)
- Copy the connection string from the dashboard
- Update
api/.env:
Terminal window DATABASE_URL=postgresql://user:password@ep-xyz.us-east-2.aws.neon.tech/dbname?sslmode=require -
Generate database tables
After setting up a new database, you need to create the tables:
Terminal window npm run db:setupThis will run the schema creation and seed the database with sample products and orders.
-
Verify auto-instrumentation is enabled
The database instrumentation should be automatically included via
getNodeAutoInstrumentations()inapi/instrument-otel.js. -
Generate database traffic
Terminal window # This endpoint triggers database queriescurl http://localhost:3000/api/products -
Look for the spans in trace details
Database spans appear as children of the HTTP request span, with tags like:
db.system: postgresqldb.statement: SELECT ...db.name: neondb(or your database name)
Issue 3: Too Many or Too Few Spans
Too Many Spans
If you see hundreds of spans making traces hard to read:
// In api/instrument-otel.js, you can disable noisy instrumentation:getNodeAutoInstrumentations({ '@opentelemetry/instrumentation-fs': { enabled: false, // Disable filesystem tracing (very noisy) },})Too Few Spans
If you’re not seeing enough detail:
- Check that auto-instrumentations are enabled
- Add manual instrumentation for custom business logic
- Verify sampling rate is 100% for development:
tracesSampleRate: 1.0