summaryrefslogtreecommitdiff
path: root/tests/specs/cli/otel_basic/basic.ts
blob: 5a178794a3ea589c1d9c770108bba5e89f109b18 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.

async function inner() {
  using _span = new Deno.tracing.Span("inner span");
  console.log("log 1");
  await 1;
  console.log("log 2");
}

const server = Deno.serve({
  port: 0,
  async onListen({ port }) {
    try {
      await fetch(`http://localhost:${port}`);
    } finally {
      server.shutdown();
    }
  },
  handler: async (_req) => {
    using _span = new Deno.tracing.Span("outer span");
    await inner();
    return new Response(null, { status: 200 });
  },
});