captureEvent
Reports an event that isn't an error, such as a payment that was declined. Events appear in logs and can be searched like errors.
Parameters
messagestringrequiredWhat happened.
levelchoicedebug, info, warning, error or fatal.
timestampstring or dateWhen it happened.
operationIdstringThe operation it belongs to.
methodstringThe HTTP method.
pathstringThe request path.
statusCodenumberThe response status.
latencyMsnumberHow long the request took.
attemptnumberWhich attempt this was, when the call was retried.
requestIdstringYour own request id.
userobjectWho it happened to, such as { id }. Redacted like everything else.
tagsobjectYour own labels, which you can search by.
contextobjectAnything else worth keeping with the event.
breadcrumbslistWhat led up to it, each with message, category, type, level, data and timestamp.
fingerprintstringGroups events with the same fingerprint into one issue, instead of grouping by 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.
spanIdstringThe span it happened in.
eventIdstringPass your own to make a retried delivery count once.
Example
import { captureEvent } from "@octri/node";
captureEvent("Card declined", {
level: "warning",
operationId: "createOrder",
tags: { gateway: "stripe" },
context: { declineCode: "insufficient_funds" },
});In each language
| Language | Call |
|---|---|
| Node | captureEvent() |
| Python | octri.capture_event() |
| Go | octri.CaptureEvent() |
| Ruby | Octri.capture_event |
| Java | Octri.captureEvent() |
| Kotlin | Octri.captureEvent() |
| PHP | Octri::captureEvent() |
| Rust | octri_monitoring::capture_event() |
| Swift | Octri.captureEvent() |
| Dart | Octri.captureEvent() |
Python and Ruby take the same options in snake_case, such as operation_id and status_code.
Related
- Other functions:
init,captureError,captureSpan,traceFromHeader,addScrubFields,setBeforeSend,startSpan,withSpan,instrument,autoInstrument. - Backend SDKs: installing a runtime and its framework integrations.