diff options
Diffstat (limited to 'tests/specs')
-rw-r--r-- | tests/specs/cli/otel_basic/basic.out | 18 | ||||
-rw-r--r-- | tests/specs/cli/otel_basic/basic.ts | 24 | ||||
-rw-r--r-- | tests/specs/cli/otel_basic/main.ts | 2 |
3 files changed, 27 insertions, 17 deletions
diff --git a/tests/specs/cli/otel_basic/basic.out b/tests/specs/cli/otel_basic/basic.out index 3f0554f96..3745cb7f3 100644 --- a/tests/specs/cli/otel_basic/basic.out +++ b/tests/specs/cli/otel_basic/basic.out @@ -1,10 +1,10 @@ { "spans": [ { - "traceId": "00000000000000000000000000000002", - "spanId": "0000000000000003", + "traceId": "10000000000000000000000000000002", + "spanId": "1000000000000003", "traceState": "", - "parentSpanId": "0000000000000001", + "parentSpanId": "1000000000000001", "flags": 1, "name": "inner span", "kind": 1, @@ -22,8 +22,8 @@ } }, { - "traceId": "00000000000000000000000000000002", - "spanId": "0000000000000001", + "traceId": "10000000000000000000000000000002", + "spanId": "1000000000000001", "traceState": "", "parentSpanId": "", "flags": 1, @@ -55,8 +55,8 @@ "attributes": [], "droppedAttributesCount": 0, "flags": 1, - "traceId": "00000000000000000000000000000002", - "spanId": "0000000000000003" + "traceId": "10000000000000000000000000000002", + "spanId": "1000000000000003" }, { "timeUnixNano": "0", @@ -69,8 +69,8 @@ "attributes": [], "droppedAttributesCount": 0, "flags": 1, - "traceId": "00000000000000000000000000000002", - "spanId": "0000000000000003" + "traceId": "10000000000000000000000000000002", + "spanId": "1000000000000003" } ] } 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; + }); }, }); diff --git a/tests/specs/cli/otel_basic/main.ts b/tests/specs/cli/otel_basic/main.ts index 6c49462a0..5415a7437 100644 --- a/tests/specs/cli/otel_basic/main.ts +++ b/tests/specs/cli/otel_basic/main.ts @@ -10,7 +10,7 @@ const server = Deno.serve( port: 0, onListen({ port }) { const command = new Deno.Command(Deno.execPath(), { - args: ["run", "-A", "--unstable-otel", Deno.args[0]], + args: ["run", "-A", "-q", "--unstable-otel", Deno.args[0]], env: { OTEL_EXPORTER_OTLP_PROTOCOL: "http/json", OTEL_EXPORTER_OTLP_ENDPOINT: `http://localhost:${port}`, |