UNPKG

kira-node-sdk

Version:

HKAI's metrics platform kira's node-sdk.Still in development.

56 lines (42 loc) 1.26 kB
# Kira-Backend HKAI 自研的统计性 metrics 数据收集服务后端的 node-sdk。 使用示例: ```typescript import { initKiraSDK, Counter } from "@hk-artificial-intelligence-association/kira-node-sdk" /** * 在项目初始化时调用,初始化全局sdk */ initKiraSDK({ baseURL:"http://192.168.1.101:7008", service:"your-service-name", secretKey:"Optional,your secret key for kira-backend" }) /** * 新建一个 counter。 * 如果 counter 已经被初始化,那么不会新增 counter 的记录。 * 请注意,每一条 counter 记录只会保留那个时间点的属性,因此如果属性要作为标识,应该在初始化时就按照命名约定设置好。 */ const counter = Counter("my-test-conter",{attributes1:1}) /** * 计数器值加一 */ counter.increment() /** * 设置计数器属性 */ counter.setAttribute('attributes2',2) /** * 新增的属性会在下一次增加后更新 */ counter.increment() counter.add(4) counter.clearAttributes() counter.add(3) import { Effect } from "effect" console.log('sleep 20s start') await Effect.runPromise(Effect.sleep('20 seconds')) console.log('sleep 20s finished') counter.setAttribute('recoverAttribute',1) counter.increment() counter.add(1) ```