Tin

Examples · learn/31-telemetry · 309 of 339

spans

examples/learn/31-telemetry/spans.tintin run examples/learn/31-telemetry/spans.tin
/// Add two integers.
tool fn add(a: int, b: int): int => a + b

agent Calc {
  model: "mock"
  tools: [add]
  telemetry: { attributes: { team: "billing" } }
}

fn total(orders: int[]): int {
  span("total") {
    spanAttr("#orders", "{orders.len}")
    var sum = 0
    for o in orders { sum += o }
    sum
  }
}

fn main() {
  let t = span("load", () => total([3, 4, 5]))
  print("total {t}")
  span("ask") {
    print(Calc("add 2 and 3"))
  }
}