diff options
Diffstat (limited to 'tests/specs/cli/otel_basic/basic.ts')
-rw-r--r-- | tests/specs/cli/otel_basic/basic.ts | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/tests/specs/cli/otel_basic/basic.ts b/tests/specs/cli/otel_basic/basic.ts index 5a178794a..5c4ae43cd 100644 --- a/tests/specs/cli/otel_basic/basic.ts +++ b/tests/specs/cli/otel_basic/basic.ts @@ -1,10 +1,17 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. +import { trace } from "npm:@opentelemetry/api@1.9.0"; +import "jsr:@deno/otel@0.0.2/register"; + +const tracer = trace.getTracer("example-tracer"); + async function inner() { - using _span = new Deno.tracing.Span("inner span"); - console.log("log 1"); - await 1; - console.log("log 2"); + await tracer.startActiveSpan("inner span", async (span) => { + console.log("log 1"); + await 1; + console.log("log 2"); + span.end(); + }); } const server = Deno.serve({ @@ -17,8 +24,11 @@ const server = Deno.serve({ } }, handler: async (_req) => { - using _span = new Deno.tracing.Span("outer span"); - await inner(); - return new Response(null, { status: 200 }); + return await tracer.startActiveSpan("outer span", async (span) => { + await inner(); + const resp = new Response(null, { status: 200 }); + span.end(); + return resp; + }); }, }); |