Skip to content
Open icLens

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.

  1. Turn on Traces in your Agent, under Telemetry › Data connections.

  2. 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.

  3. 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 },
    );
  4. Report the client’s health. Add the two public queries from the guide, lifecycleStatus and quarantineStatus. icLens then shows each sender as Recording, Paused or Quarantined under Senders.

  5. Deploy, then check. Your spans appear in Traces, and your canister joins the service map.

  • 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.