Traces from your code
Traces show how one request moves through your canisters, and where its time goes. Add the traces client to each canister you want on the map.
-
Turn on Traces in your Agent, under Telemetry › Data connections.
-
Add your canister as a sender. On the Traces connection, open Senders and choose Add a sender. The review gives your canister permission to write spans to the Agent’s Traces scope.
-
Add the client to your canister. The sender’s guide shows the exact code, starting with:
import Traces "mo:veyra-client";let base = Traces.defaultConfig({ attributes = [("service.name", #text "payments-api")]; droppedAttributes = 0; schemaUrl = null },{ name = "payments-api"; version = null; attributes = []; droppedAttributes = 0; schemaUrl = null },); -
Report the client’s health. Add the two public queries from the guide,
lifecycleStatusandquarantineStatus. icLens then shows each sender as Recording, Paused or Quarantined under Senders. -
Deploy, then check. Your spans appear in Traces, and your canister joins the service map.
Good to know
Section titled “Good to know”- A callee that sends no spans, such as a ledger, still appears in your traces from your own call to it, marked not reported.
- Baggage is off by default. If you turn it on, allow named keys only, and never put personal data in it.
- Traces keeps every error and slow trace and a share of the rest.
- The traces client is Motoko only for now. It comes from the icLens source, not Mops.