Steps before an error
With each error, the last 20 steps that led to it, as codes: its route, calls out and their answers, and steps you name.
A stack trace shows where an error happened, not how the app got there. So the SDKs keep the last 20 steps and send them with each error, oldest first, each with how long before the error it was:
1.4 s route:POST /api/carts/:id
1.3 s cart.loaded
40 ms http:POST stripe.com 402 1204ms
10 ms event:checkout
0 ms TypeErrorHere the payment was refused and the code went on as if it wasn't. The frames alone wouldn't say so.
What's noted by itself#
| Step | Node | Python |
|---|---|---|
The route, as its pattern: route:POST /carts/:id | Express, Fastify, NestJS | Flask, FastAPI, Django |
A call out: http:POST stripe.com 402 1204ms (method, site, answer, time) | fetch | requests, urllib, httpx (and anything on Python's http.client) |
event(name): event:checkout | yes | yes |
A failing health check: health:payments failing stripe-402 | yes | yes |
An earlier error, a broken expectation: error:TypeError, expect:total-not-negative | yes | yes |
Your own: step("cart.loaded"). A call that never got an answer says why: http:GET stripe.com ECONNREFUSED 3ms. The site is the address's last two parts (api.stripe.com is stripe.com); the path, query and body are never kept.
Each request its own#
Steps are kept per request, so two requests at the same time don't mix. In Node, the SDK does this by itself for every server Node's http starts: Express, Fastify, NestJS, Koa and plain http alike, with nothing to add. The Python hooks do it too.
Node SDK 0.14.0 and older needed app.use(controxity.trail()) before an Express app's routes. It still works, and does no harm, so there's no need to take it out. It's only needed now for a server that isn't started by Node's http.
Outside a request (a job, a script) the app's steps are kept together. In Python, new_trail() starts fresh ones for a job.
Where it's used#
- The fixer reads them with the frames, so it sees the call that failed or the step that was skipped.
- The problem page shows the latest time's steps under Steps before it.
- Your AI tools get them as
steps_beforefromget_problem.
What's never in it#
A step is a code: letters, digits, spaces and : . / - _. A route is its pattern (/carts/:id), never the path asked for (/carts/c-42). A call out is its site (stripe.com), never its address, query or body: a subdomain is cut, so a tenant's or account's name isn't kept. A run of 6 digits or more becomes #, and Controxity drops any step with an @, a URL query or anything that looks like a secret.
Turn it off with breadcrumbs: false (Node) or breadcrumbs=False (Python); then fetch is left as it was.