instrument
Turns every call to some methods of an object into a span. Point it at a database client, a cache or a module once, and every call is traced with no code at the call sites. It changes the object in place and returns it.
Parameters
targetobjectrequiredThe object, or its prototype.
methodslist of namesrequiredThe methods to trace. A name that isn't a function is skipped.
opstringA category, such as db or cache.
namefunctionBuilds each span's name from the method name and the call's arguments.
Example
Node
import { instrument } from "@octri/node";
instrument(pool, ["query"], { op: "db" });
instrument(cache, ["get", "set"], { op: "cache" });In each language
| Language | Call |
|---|---|
| Node | instrument() |
| Python | octri.instrument() |
| Go | Not available |
| Ruby | Octri.instrument |
| Java | Not available |
| Kotlin | Not available |
| PHP | Not available |
| Rust | Not available |
| Swift | Not available |
| Dart | Not available |
Node also has instrumentFunction(fn, { name, op }), which wraps a single function.
Related
- Other functions:
init,captureError,captureEvent,captureSpan,traceFromHeader,addScrubFields,setBeforeSend,startSpan,withSpan,autoInstrument. - Backend SDKs: installing a runtime and its framework integrations.