Endpoints & transactions

Understand request labels, transaction timing and bounded metric summaries.

Choose the right working directory. Examples using npm run shortcuts, node bin/loadstride.js, or top-level starter-kit/ paths run from the LoadStride source checkout. Those shortcuts do not exist in your application’s package.json. Installed-package users run npx --no-install loadstride from their application directory. See Getting started for both options.

Endpoint and transaction metrics

Every measured HTTP helper request and browser network observation contributes to an endpoint breakdown automatically. Add transactions to measure user-facing flow steps, such as login, product search, and checkout. Both appear in console, JSON, and offline HTML reports, including each scenario and the merged run.

Endpoint names

The default identity is the request source (http or browser), HTTP method, and initial URL origin plus pathname. URL credentials, query strings, and fragments are excluded. /search?q=one and /search?q=two share an endpoint; GET and POST remain separate. Paths and origins are visible in reports, so use explicit names when paths contain sensitive values or dynamic IDs:

const response = await http.get(`${base}/products/${productId}?session=${sessionId}`, {
  name: '/products/:id',
});

HTTP request name replaces the automatic name, keeping the method and source. It is a literal label, not a route matcher: specify it on each request to group them. Explicit names can combine origins intentionally. Names must be nonblank, at most 200 characters, and contain no control characters; surrounding whitespace is trimmed. Automatic URL labels are truncated to 200 characters, so very long paths with the same prefix combine. Keep secrets out of explicit names.

For HTTP helpers, redirects retain the original endpoint identity and count as one logical request through the final body/status, matching overall HTTP metrics. Browser endpoints use each observed HTTP(S) request, including redirects and resources. Browser endpoint names are automatic; request name is an HTTP helper option. A transaction around browser actions does not rename its resource URLs.

Each endpoint reports count, count/second, failed count and fraction, body bytes, status counts, and duration min/mean/median/p95/p99/max. A request fails when there is a transport error or its final status is outside 200–399. Status 0 means no HTTP response status. Duration includes failed requests. HTTP helper bytes are decoded body bytes; browser bytes are encoded response body bytes reported by Playwright. Keep the two sources separate when interpreting results.

Transactions

export const options = {
  vus: 2, iterations: 10,
  thresholds: { checks: ['rate==1'], http_req_failed: ['rate==0'] },
};

export default async function ({ http, check, transaction }) {
  const base = process.env.TARGET_URL ?? 'http://127.0.0.1:3000';
  await transaction('checkout', async () => {
    const response = await http.post(`${base}/cart`, JSON.stringify({ productId: 123 }), {
      name: '/cart', headers: { 'content-type': 'application/json' },
    });
    check(response, { 'cart updated': r => r.status === 201 });
  });
}

await transaction(name, callback) returns the callback’s result and rethrows its error without replacing it. Callbacks may be synchronous or async. Always await transactions and the requests/actions inside them; detached work is not awaited by the engine. The helper is available in measured HTTP and browser iterations, not setup/teardown hooks. Names follow the same validation rules as request names.

Transaction duration is wall-clock time through callback completion, including network, assertions, retries written in your script, and sleeps inside the callback. It excludes browser context startup/cleanup outside the callback. A transaction fails if its callback throws or a check fails in its scope. Nested failures also mark enclosing transactions failed, even if an inner error is caught. Parallel transactions and VUs have independent scopes; sibling failures do not contaminate each other. Closed scopes do not receive later checks from detached work.

HTTP/browser status failures alone do not fail transactions: assert the expected response with check or Playwright expect. check records failure without throwing; expect throws on failure. Caught errors can leave the iteration passed while its transaction is failed. This preserves existing run-pass behavior: let errors propagate, use check/request thresholds, or configure a scoped threshold to enforce a run-level policy. See scoped thresholds for latency, failure, sample-count, and transaction-check requirements on an individual name.

Transactions report invocation count/rate, passed/failed counts, failure fraction, check counts, and duration distributions. Nested timing and check counts are inclusive: do not add parent and child totals. An interrupted callback that throws is included as a failed transaction in a returned partial report. A transaction that catches cancellation and returns without failed checks is considered passed; the run remains interrupted.

Ready-to-run demos

Start the shopping/login target:

npm run demo:auth-server

In another terminal:

npm run test:transactions

The API demo uses distinct public dummy users per VU and reports login, view profile, add to cart, and the enclosing shopping journey. Output goes under reports/transactions/run-.../. It skips .env; shell values and CLI flags still apply. To select another local demo port, pass -- --url <printed-origin>.

For a larger API run:

npm run test:transactions -- --vus 1000 --duration 30s

Restart npm run demo:auth-server after updating its code. The demo reuses a valid session per username and refreshes its five-minute expiry at each login. Parallel flows sharing credentials keep the same token. Repeated iterations with 1,000 distinct users therefore retain at most 1,000 active sessions, rather than one session for every iteration. All three requests still run every iteration. Expired sessions are reclaimed in expiry order without a full scan on each login. The store retains a cap of 10,000 active distinct users; additional users receive HTTP 503 until space becomes available. This behavior is for the local demo only. Other failures under load still need investigation; 1,000 VUs does not guarantee that the target or generator has sufficient resources.

The browser equivalent is npm run browser:demo -- --vus 2 --iterations 4 after optional browser installation. It reports the three steps and automatically observed network endpoints. Raw codegen recordings need manual transaction wrappers around the actions you want timed; meaningful assertions still require review.

JSON and memory limits

The additive endpointResults and transactionResults arrays are siblings of metrics in report format version 1. Each row has count, rate, failed, failureRate (0–1), and duration (milliseconds, including count and histogram percentiles). Endpoints also include source, method, name, dataReceivedBytes, statuses, and overflow. Transactions include name, passed, checks: { passed, failed }, and overflow.

Each accumulator retains at most 100 distinct endpoint identities across both sources and 100 transaction names. Further identities go into (other endpoints) rows separated by source or one (other transactions) row. overflow: true distinguishes these from a user-provided name. Counts, bytes, failures and raw histograms are retained in overflow; individual additional names are not. With concurrent work, first-observed names can vary between runs. Use stable explicit names for repeatable endpoint reporting.

Names selected by scoped thresholds reserve slots within these limits before load starts. Reservations allocate histograms only when observed and do not add fake samples. Rules for the merged run reserve their targets in every scenario so the measurements cannot disappear into scenario overflow. Other labels may overflow sooner. Without configured rules, label selection keeps its original behavior.

The same limits apply to each scenario and the merged report. Merging adds raw histograms rather than averaging percentiles. Rows already in scenario overflow remain overflow during merging. Rates use the elapsed load window including drain for that report; child and whole-run rates can therefore differ. Setup and teardown requests remain outside measured reports. Older JSON without breakdown arrays still renders in the console and HTML renderers.

These summaries do not add general metric tags, automatic dynamic-route matching, request-to-transaction network attribution, individual request traces, or time series. Use stable names and assertions to make the aggregates useful.

Based on the released v0.2.0 guide. View source on GitHub.