Investigate application errors

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.

Light-mode Console Home page for Northstar Analytics, showing the workspace connection bar with the example API address ap-southeast-1.aws.scopedb.cloud and Create API key.
Copy the ScopeDB API address from your own workspace, then choose Create API key. The account and address shown are demonstration values.
Light-mode Console Home page for Northstar Analytics, showing the workspace connection bar with the example API address ap-southeast-1.aws.scopedb.cloud and Create API key.
Copy the ScopeDB API address from your own workspace, then choose Create API key. The account and address shown are demonstration values.

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.

Light-mode Create API Key dialog with the name event-tutorial and a 90-day expiration.
Give the key a recognizable name, choose an expiration, and select Create Key. Save the secret when it appears.
Light-mode Create API Key dialog with the name event-tutorial and a 90-day expiration.
Give the key a recognizable name, choose an expiration, and select Create Key. Save the secret when it appears.

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 ci

All three language implementations write identical rows to guide_logs.requests, so every query in this guide works unchanged across runtimes:

SDKVersionRuntimeDirectoryStart commandSingle-cycle check
JavaScript0.3.0Node.js 20 or laterapplication-logs/jsnpm startSCOPEDB_DEMO_RUN=checkout-check-js npm start -- --cycles 1
Go0.7.0Go 1.26 or laterapplication-logs/gogo run .SCOPEDB_DEMO_RUN=checkout-check-go go run . -cycles 1
Rust0.4.2Rust 1.91 or laterapplication-logs/rustcargo runSCOPEDB_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 start

Each 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
Stagerequestserrors
After 1 cycle122
After 95 cycles (continuous)1140190

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, gateway

After a single 12-request cycle, each (release, gateway) group has 3 requests, and only 1.9 + credit_card exhibits failures:

releasegatewayrequestserrorserror_percent
1.8bank_transfer300.0
1.8credit_card300.0
1.9bank_transfer300.0
1.9credit_card3266.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%:

Light-mode Console Query view in the Northstar workspace showing 4 release and gateway groups across 285 requests each, with 190 errors and a 66.7% error rate isolated to release 1.9 credit_card.
Grouping by var['release'] and var['gateway'] isolates the 66.7% timeout rate to release 1.9 credit_card while release 1.8 and bank_transfer remain at 0.0%.
Light-mode Console Query view in the Northstar workspace showing 4 release and gateway groups across 285 requests each, with 190 errors and a 66.7% error rate isolated to release 1.9 credit_card.
Grouping by var['release'] and var['gateway'] isolates the 66.7% timeout rate to release 1.9 credit_card while release 1.8 and bank_transfer remain 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 10

Click 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.

Light-mode Console Query view showing failed checkout requests and the Row details drawer open on req-08, displaying the formatted var JSON object with gateway credit_card, release 1.9, request_id req-08, and run_id checkout-first.
Click any var cell to open Row details and inspect the full semi-structured context for that request.
Light-mode Console Query view showing failed checkout requests and the Row details drawer open on req-08, displaying the formatted var JSON object with gateway credit_card, release 1.9, request_id req-08, and run_id checkout-first.
Click any var cell to open Row details and inspect the full semi-structured context for that request.

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:

Light-mode Console Data Explore view for scopedb.guide_logs.requests with the level = error filter chip applied and matching timeout records listed.
In Data > Explore, filter requests by level = error and click Run to browse matching timeout records visually.
Light-mode Console Data Explore view for scopedb.guide_logs.requests with the level = error filter chip applied and matching timeout records listed.
In Data > Explore, filter requests by level = error and click Run to browse matching timeout records visually.

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 an object column first. ScopeDB automatically maintains a path index on object columns, 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

SymptomNext step
401 or 403Verify SCOPEDB_ENDPOINT, SCOPEDB_API_KEY, key expiration, and the target workspace.
Run ID already has logsQuery 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 QueryConfirm the simulator is running in the same workspace, check the run_id filter, and wait ~1 second for the stream flush.
No records in ExploreCheck the active table and level = error filter, then widen or clear any active time-range filter.
Timeout or failed appendCheck the existing row count for run_id before retrying; start a new SCOPEDB_DEMO_RUN if you want a clean cycle baseline.