withSpan
Mesure la durée d’une tâche dans un span et le marque comme ayant échoué si elle déclenche une exception. Cette fonction équivaut à startSpan, mais termine le span automatiquement. Les appels effectués à l’intérieur s’y imbriquent.
Paramètres
namestringobligatoireLa nature du travail.
fnfunctionobligatoireLe travail à effectuer. Son résultat est renvoyé ; toute erreur qu’il déclenche est signalée sur le span, puis relancée.
opstringUne catégorie, par exemple db.
Exemple
Node
import { withSpan } from "@octri/node";
const rows = await withSpan("orders.list", () => db.query(sql), { op: "db" });Dans chaque langage
| Langage | Appel |
|---|---|
| Node | withSpan() |
| Python | with octri.span(): |
| Go | octri.WithSpan() |
| Ruby | Non disponible |
| Java | Non disponible |
| Kotlin | Non disponible |
| PHP | Non disponible |
| Rust | Non disponible |
| Swift | Non disponible |
| Dart | Non disponible |
Articles associés
- Autres fonctions :
init,captureError,captureEvent,captureSpan,traceFromHeader,addScrubFields,setBeforeSend,startSpan,instrument,autoInstrument. - SDK backend : installation d’un environnement d’exécution et de ses intégrations de framework.