-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.ts
37 lines (28 loc) · 947 Bytes
/
example.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import "https://deno.land/[email protected]/dotenv/load.ts";
import * as hc from "./mod.ts";
const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));
const root = hc.create({
skip: false, // set to true to turn instrumentation off
name: "root",
service: "spans-example",
extra: {
"service.namespace": "spans",
},
});
await sleep(10);
const c1 = hc.create({ name: "a child span", parent: root });
await sleep(10);
hc.end(c1, { "app.msg": "finished child example" });
const c2 = hc.create({ name: "a second child span", parent: root });
await sleep(10);
hc.link(c2, c1);
hc.end(c2, { "app.msg": "linked" });
await sleep(20);
hc.event({ name: "event!", parent: root, extra: { "app.note": "something happened!" } });
await sleep(30);
hc.end(root, { "app.msg": "all done sending to honeycomb" });
const res = await hc.sendToHoneycomb({
apiKey: Deno.env.get("HC_API_KEY") ?? "",
span: root,
});
if (res) console.log(res.status);