Investigate application errors
On this page
Related contents
A checkout release starts producing payment errors. Is every payment method affected, or is the regression isolated to a single gateway?
In this guide, you run a checkout simulator that streams structured application logs into ScopeDB through an official SDK (JavaScript, Go, or Rust). While the simulator continuously appends request outcomes in the background, you use Console Query and Explore to verify the total request population, break down failure rates across (release, gateway) pairs, and inspect the nested request context behind individual timeouts. Across every cycle, the repeating signature is a 66.7% timeout rate on release 1.9 credit-card payments, with bank transfers and release 1.8 unaffected.
Allow about 15 minutes after workspace setup. Each cycle simulates 12 payment attempts and repeats until you press Ctrl+C.
1. Connect the sample application
You need a ready ScopeDB Cloud workspace, one of the supported runtimes below, Git, and a terminal (macOS, Linux, or WSL). Use a test workspace: the simulator creates guide_logs.requests and continuously appends logs in the default scopedb database.
In Console, open Home in your workspace and copy ScopeDB API.

Choose Create API key, give it a name such as event-tutorial, and choose an expiration. Select Create Key and copy the one-time secret. You can follow the connection walkthrough for additional setup details.

Export the endpoint and API key in the terminal where you will run the simulator:
export SCOPEDB_ENDPOINT="https://<endpoint>"
export SCOPEDB_API_KEY="<api-key>"Keep credentials in your local environment, outside source control. Your Console browser sign-in does not authenticate local SDK processes.
Clone the Demo Scene repository and enter the application-logs/js directory (or the Go or Rust directory from the table below):
git clone https://github.com/scopedb/demo-scene.git scopedb-demos
cd scopedb-demos/application-logs/js
npm ciAll three language implementations write identical rows to guide_logs.requests, so every query in this guide works unchanged across runtimes:
| SDK | Version | Runtime | Directory | Start command | Single-cycle check |
|---|---|---|---|---|---|
| JavaScript | 0.3.0 | Node.js 20 or later | application-logs/js | npm start | SCOPEDB_DEMO_RUN=checkout-check-js npm start -- --cycles 1 |
| Go | 0.7.0 | Go 1.26 or later | application-logs/go | go run . | SCOPEDB_DEMO_RUN=checkout-check-go go run . -cycles 1 |
| Rust | 0.4.2 | Rust 1.91 or later | application-logs/rust | cargo run | SCOPEDB_DEMO_RUN=checkout-check-rust cargo run -- --cycles 1 |
2. Stream structured request logs
The simulator writes to scopedb.guide_logs.requests, which uses four typed envelope columns (time, service, level, message) and a semi-structured var object column for request-specific context (run_id, request_id, release, gateway). Its Catalog table definition is:
{
"name": "requests",
"columns": [
{ "name": "time", "data_type": "timestamp" },
{ "name": "service", "data_type": "string" },
{ "name": "level", "data_type": "string" },
{ "name": "message", "data_type": "string" },
{ "name": "var", "data_type": "object" }
]
}On startup, the simulator ensures guide_logs.requests exists before streaming logs, or you can apply the definition ahead of time with scope catalog or in Console Data.
In each cycle, the simulator executes three payment attempts for every combination of release (1.8, 1.9) and gateway (bank_transfer, credit_card). Two of the three credit_card attempts on release 1.9 time out, and the request handler records both successful and failed attempts with the same log structure:
const log = {
time: new Date().toISOString(), service: "checkout", level, message,
var: { run_id: runId, request_id: requestId, release, gateway },
};
console.log(JSON.stringify(log));
await stream.send(log);Start the producer with SCOPEDB_DEMO_RUN=checkout-first and leave this terminal running while you work in Console:
SCOPEDB_DEMO_RUN=checkout-first npm startEach cycle appends 10 successful requests and 2 credit_card timeouts, flushing buffered rows roughly once per second. Press Ctrl+C when you finish the walkthrough; the program flushes in-flight logs before exiting and prints the total committed count.
3. Compare releases and gateways
Open Query in Console and verify that requests are arriving for checkout-first:
FROM guide_logs.requests
WHERE var['run_id']::string = 'checkout-first'
AGGREGATE count() AS requests,
sum(if(level = 'error', 1, 0)) AS errors| Stage | requests | errors |
|---|---|---|
| After 1 cycle | 12 | 2 |
| After 95 cycles (continuous) | 1140 | 190 |
Recording both successful (level = 'info') and failed (level = 'error') attempts in the same table lets you compute true failure rates instead of raw error counts. Click Run again after a few seconds to watch requests and errors advance together.
Next, extract var['release']::string and var['gateway']::string directly from the semi-structured var column and compare the error rate across all four (release, gateway) combinations:
FROM guide_logs.requests
WHERE var['run_id']::string = 'checkout-first'
SELECT level, var['release']::string AS release, var['gateway']::string AS gateway
GROUP BY release, gateway
AGGREGATE count() AS requests,
sum(if(level = 'error', 1, 0)) AS errors
SELECT *, round(100.0 * errors / requests, 1) AS error_percent
ORDER BY release, gatewayAfter a single 12-request cycle, each (release, gateway) group has 3 requests, and only 1.9 + credit_card exhibits failures:
| release | gateway | requests | errors | error_percent |
|---|---|---|---|---|
| 1.8 | bank_transfer | 3 | 0 | 0.0 |
| 1.8 | credit_card | 3 | 0 | 0.0 |
| 1.9 | bank_transfer | 3 | 0 | 0.0 |
| 1.9 | credit_card | 3 | 2 | 66.7 |
As the simulator continues running across cycles (such as 95 cycles / 285 requests per group in the screenshot below), the 66.7% failure rate remains isolated to 1.9 + credit_card while bank_transfer and release 1.8 stay at 0.0%:

4. Inspect failed requests in Query and Explore
Once you isolate the failing slice (release = '1.9' and gateway = 'credit_card'), retrieve the individual error logs and their correlation IDs (request_id):
FROM guide_logs.requests
WHERE var['run_id']::string = 'checkout-first' AND level = 'error'
SELECT time, message, var['request_id']::string AS request_id, var
ORDER BY time, request_id
LIMIT 10Click the var cell in row 1 (req-08) to open Row details. The side panel displays the timestamp, error message, promoted request_id, and formatted var JSON payload (gateway: "credit_card", release: "1.9", request_id: "req-08", run_id: "checkout-first") so you can copy request_id straight into your downstream trace or gateway logs.

You can also filter and inspect the same table visually without writing ScopeQL. Open Data, expand scopedb → guide_logs, and select requests. In Explore, click Filter, add level = error, and click Run:

Click any record in Explore to open its Row details drawer, or switch from Records to Bar or Top list to group filtered events interactively (see Explore in Console).
5. Apply this pattern to your own services
When adapting this workflow to production services:
- Emit one structured outcome event per request: Record both successful and failed requests with a stable timestamp, service name, severity level, and message so you can calculate true error rates (
errors / requests) rather than raw error counts. - Keep evolving dimensions in
var: Store deployment tags (release,region) and business dimensions (gateway,request_id) in anobjectcolumn first. ScopeDB automatically maintains a path index onobjectcolumns, and you can promote hot paths to computed columns later as your queries stabilize (see Model event data). - Manage schemas declaratively before deployment: Create and update tables in CI/CD or ahead of rollout with
scope catalog, the Catalog HTTP API, or the SDK.catalog().apply(...)methods (JavaScript,Go,Rust) so request handlers only append rows. - Flush on shutdown: Share a single SDK append stream across your server process and flush buffered logs during graceful shutdown (see the JavaScript SDK, Go SDK, and Rust SDK guides).
Continue with Model event data when fields evolve, Query events for more ScopeQL investigation patterns, or Set data retention to manage log lifecycle.
Troubleshooting
| Symptom | Next step |
|---|---|
401 or 403 | Verify SCOPEDB_ENDPOINT, SCOPEDB_API_KEY, key expiration, and the target workspace. |
| Run ID already has logs | Query that run ID first, or start a fresh run with a new SCOPEDB_DEMO_RUN value and update the run_id filter in Query. |
| No rows in Query | Confirm the simulator is running in the same workspace, check the run_id filter, and wait ~1 second for the stream flush. |
| No records in Explore | Check the active table and level = error filter, then widen or clear any active time-range filter. |
| Timeout or failed append | Check the existing row count for run_id before retrying; start a new SCOPEDB_DEMO_RUN if you want a clean cycle baseline. |