captureError
Reports an error, such as one your handler caught. The framework integrations call it for you on an unhandled error. Call it yourself for an error you catch and handle. The event is tagged octri.origin=server, and carries the environment and release from init.
Parameters
errorerrorrequiredThe error. Its type, message and stack are sent. Anything that isn't an error is reported as one, with its text as the message.
traceTraceContextThe request's trace, from traceFromHeader. It links this event to the client SDK's error for the same request. A fresh trace is started without it.
methodstringThe HTTP method of the request that failed.
pathstringIts path.
operationIdstringIts operation, as your spec names it, so the issue sits under that endpoint.
statusCodenumberThe status your server answered with.
levelchoiceerror, fatal or warning.
Example
Node
import { captureError, traceFromHeader } from "@octri/node";
try {
await chargeCard(order);
} catch (error) {
captureError(error, {
trace: traceFromHeader(req.headers.traceparent),
method: "POST",
path: "/orders",
operationId: "createOrder",
statusCode: 502,
});
throw error;
}In each language
| Language | Call |
|---|---|
| Node | captureError() |
| Python | octri.capture_error() |
| Go | octri.CaptureError() |
| Ruby | Octri.capture_error |
| Java | Octri.captureError() |
| Kotlin | Octri.captureError() |
| PHP | Octri::captureError() |
| Rust | octri_monitoring::capture_error() |
| Swift | Octri.captureError() |
| Dart | Octri.captureError() |
Related
- Other functions:
init,captureEvent,captureSpan,traceFromHeader,addScrubFields,setBeforeSend,startSpan,withSpan,instrument,autoInstrument. - Backend SDKs: installing a runtime and its framework integrations.