Skip to content

Commit ec961e5

Browse files
authored
chore(example/main): move OpenTelemetry propagation setup into load event listener (#684)
1 parent d1c474a commit ec961e5

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

examples/main/index.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,16 @@ import { join } from "jsr:@std/path@^1.0";
66
import { context, propagation } from "npm:@opentelemetry/api";
77
import { W3CBaggagePropagator } from "npm:@opentelemetry/core@1";
88

9-
// @ts-ignore See https://github.com/denoland/deno/issues/28082
10-
if (globalThis[Symbol.for("opentelemetry.js.api.1")]) {
11-
globalThis[Symbol.for("opentelemetry.js.api.1")].propagation =
12-
new W3CBaggagePropagator();
13-
}
14-
15-
console.log("main function started");
16-
console.log(Deno.version);
9+
addEventListener("load", () => {
10+
console.log("main function started");
11+
console.log(Deno.version);
12+
13+
// @ts-ignore See https://github.com/denoland/deno/issues/28082
14+
if (globalThis[Symbol.for("opentelemetry.js.api.1")]) {
15+
globalThis[Symbol.for("opentelemetry.js.api.1")].propagation =
16+
new W3CBaggagePropagator();
17+
}
18+
});
1719

1820
addEventListener("beforeunload", () => {
1921
console.log("main worker exiting");

0 commit comments

Comments
 (0)