Spotlight Run
The run command wraps your application with Spotlight, automatically setting up the necessary environment variables and capturing telemetry data.
Basic Usage
spotlight run [options] [command]Key points:
- If you don’t provide a command, Spotlight automatically detects and runs your development script from
package.json - Works with any language or framework
- Automatically configures environment variables for Spotlight integration
Auto-Detection from package.json
When you run spotlight run without a command, it looks for these scripts in your package.json (in order):
devdevelopservestart
# In a directory with package.jsonspotlight run# ✓ Automatically runs: npm run dev (or first available script)This makes it incredibly easy to get started - just add Spotlight to your existing workflow:
{ "scripts": { "dev": "node server.js", "dev:spotlight": "spotlight run" }}Running Specific Commands
You can run any command with Spotlight:
spotlight run [your-command]Examples:
# Node.jsspotlight run node server.js
# Pythonspotlight run python manage.py runserver
# Gospotlight run go run main.go
# Any other commandspotlight run npm startspotlight run flask runspotlight run rails serverWhat Happens Under the Hood
When you run spotlight run, it:
- Starts the Spotlight Sidecar on the specified port (default: dynamically assigned)
- Sets Environment Variables:
SENTRY_SPOTLIGHT=http://localhost:<port>/streamSENTRY_TRACES_SAMPLE_RATE=1(enables 100% trace sampling)
- Runs Your Command with these environment variables
- Captures stdout/stderr as log events automatically
- Streams Everything to Spotlight in real-time
Automatic Log Capture
Your application’s console output is automatically captured and sent to Spotlight as log events:
- stdout → Info-level logs
- stderr → Error-level logs
This means you don’t need to add any special logging configuration - your existing console.log(), print(), or standard output statements will appear in Spotlight!
Options
Port Configuration
Default port: 0 - automatically assigns a random available port.
# Use default port (0)spotlight run node server.js
# Use custom portspotlight run -p 3000 node server.js
# Use random available portspotlight run -p 0 node server.jsDebug Mode
Enable debug logging to see what Spotlight is doing:
spotlight run -d node server.js# orspotlight run --debug python app.pyComplete Examples
Full Development Workflow
# Terminal 1: Run your app with Spotlightspotlight run npm run dev
# Terminal 2: Open the Spotlight UIopen http://localhost:8969
# Now interact with your app and see errors, traces, and logs in real-time!With Custom Port
# If port 8969 is already in usespotlight run -p 9000 node server.js
# Update your Sentry SDK configuration if needed:# spotlight: "http://localhost:9000/stream"CI/CD Integration
# Run tests with Spotlight for debugging failuresspotlight run npm test
# Capture traces during integration testsspotlight run -p 0 pytest tests/SDK Configuration
For the run command to work, your application needs:
- Sentry SDK installed and initialized
- SDK configured to respect the
SENTRY_SPOTLIGHTenvironment variable (most modern SDKs do this automatically)
Automatic Configuration (Recommended)
Most modern Sentry SDKs automatically detect the SENTRY_SPOTLIGHT environment variable:
// Sentry will automatically use the SENTRY_SPOTLIGHT env varSentry.init({ dsn: "your-dsn", // Optional - can be omitted for local dev // spotlight: true, // Not needed - handled by env var});import sentry_sdk
# Sentry will automatically use the SENTRY_SPOTLIGHT env varsentry_sdk.init( dsn="your-dsn", # Optional - can be omitted for local dev # spotlight="...", # Not needed - handled by env var)// Sentry will automatically use the SENTRY_SPOTLIGHT env varsentry.Init(sentry.ClientOptions{ Dsn: "your-dsn", // Optional})Manual Configuration
If you prefer explicit configuration:
Sentry.init({ dsn: "your-dsn", spotlight: process.env.NODE_ENV === "development", // or explicitly: // spotlight: "http://localhost:8969/stream",});Unsupported SDKs (DSN Workaround)
If your SDK doesn’t support the spotlight option or the SENTRY_SPOTLIGHT environment variable, you can use the DSN workaround:
Sentry.init({ dsn: "http://spotlight@localhost:8969/0",});Troubleshooting
Command Not Found
If spotlight is not found, make sure you’ve installed it:
npm install -g @spotlightjs/sidecar# or use npxnpx @spotlightjs/sidecar run node server.jsNo Events Showing Up
- Check SDK Configuration: Ensure your Sentry SDK is properly initialized
- Verify Environment Variable: The SDK should respect
SENTRY_SPOTLIGHT - Check Port: Make sure the port isn’t already in use
- Enable Debug Mode: Run with
-dflag to see what’s happening
spotlight run -d node server.jsPort Already in Use
If port 8969 is already taken:
# Use a different portspotlight run -p 9000 node server.js
# Or let the OS choose an available portspotlight run -p 0 node server.js