@@ -1252,80 +1252,53 @@ declare namespace Deno {
1252
1252
}
1253
1253
1254
1254
/**
1255
+ * **UNSTABLE**: New API, yet to be vetted.
1256
+ *
1257
+ * APIs for working with the OpenTelemetry observability framework. Deno can
1258
+ * export traces, metrics, and logs to OpenTelemetry compatible backends via
1259
+ * the OTLP protocol.
1260
+ *
1261
+ * Deno automatically instruments the runtime with OpenTelemetry traces and
1262
+ * metrics. This data is exported via OTLP to OpenTelemetry compatible
1263
+ * backends. User logs from the `console` API are exported as OpenTelemetry
1264
+ * logs via OTLP.
1265
+ *
1266
+ * User code can also create custom traces, metrics, and logs using the
1267
+ * OpenTelemetry API. This is done using the official OpenTelemetry package
1268
+ * for JavaScript:
1269
+ * [`npm:@opentelemetry/api`](https://opentelemetry.io/docs/languages/js/).
1270
+ * Deno integrates with this package to provide trace context propagation
1271
+ * between native Deno APIs (like `Deno.serve` or `fetch`) and custom user
1272
+ * code. Deno also provides APIs that allow exporting custom telemetry data
1273
+ * via the same OTLP channel used by the Deno runtime. This is done using the
1274
+ * [`jsr:@deno/otel`](https://jsr.io/@deno/otel) package.
1275
+ *
1276
+ * @example Using OpenTelemetry API to create custom traces
1277
+ * ```ts,ignore
1278
+ * import { trace } from "npm:@opentelemetry/api@1";
1279
+ * import "jsr:@deno/[email protected] /register";
1280
+ *
1281
+ * const tracer = trace.getTracer("example-tracer");
1282
+ *
1283
+ * async function doWork() {
1284
+ * return tracer.startActiveSpan("doWork", async (span) => {
1285
+ * span.setAttribute("key", "value");
1286
+ * await new Promise((resolve) => setTimeout(resolve, 1000));
1287
+ * span.end();
1288
+ * });
1289
+ * }
1290
+ *
1291
+ * Deno.serve(async (req) => {
1292
+ * await doWork();
1293
+ * const resp = await fetch("https://example.com");
1294
+ * return resp;
1295
+ * });
1296
+ * ```
1297
+ *
1255
1298
* @category Telemetry
1256
1299
* @experimental
1257
1300
*/
1258
- export namespace tracing {
1259
- /**
1260
- * Whether tracing is enabled.
1261
- * @category Telemetry
1262
- * @experimental
1263
- */
1264
- export const enabled : boolean ;
1265
-
1266
- /**
1267
- * Allowed attribute type.
1268
- * @category Telemetry
1269
- * @experimental
1270
- */
1271
- export type AttributeValue = string | number | boolean | bigint ;
1272
-
1273
- /**
1274
- * A tracing span.
1275
- * @category Telemetry
1276
- * @experimental
1277
- */
1278
- export class Span implements Disposable {
1279
- readonly traceId : string ;
1280
- readonly spanId : string ;
1281
- readonly parentSpanId : string ;
1282
- readonly kind : string ;
1283
- readonly name : string ;
1284
- readonly startTime : number ;
1285
- readonly endTime : number ;
1286
- readonly status : null | { code : 1 } | { code : 2 ; message : string } ;
1287
- readonly attributes : Record < string , AttributeValue > ;
1288
- readonly traceFlags : number ;
1289
-
1290
- /**
1291
- * Construct a new Span and enter it as the "current" span.
1292
- */
1293
- constructor (
1294
- name : string ,
1295
- kind ?: "internal" | "server" | "client" | "producer" | "consumer" ,
1296
- ) ;
1297
-
1298
- /**
1299
- * Set an attribute on this span.
1300
- */
1301
- setAttribute (
1302
- name : string ,
1303
- value : AttributeValue ,
1304
- ) : void ;
1305
-
1306
- /**
1307
- * Enter this span as the "current" span.
1308
- */
1309
- enter ( ) : void ;
1310
-
1311
- /**
1312
- * Exit this span as the "current" span and restore the previous one.
1313
- */
1314
- exit ( ) : void ;
1315
-
1316
- /**
1317
- * End this span, and exit it as the "current" span.
1318
- */
1319
- end ( ) : void ;
1320
-
1321
- [ Symbol . dispose ] ( ) : void ;
1322
-
1323
- /**
1324
- * Get the "current" span, if one exists.
1325
- */
1326
- static current ( ) : Span | undefined | null ;
1327
- }
1328
-
1301
+ export namespace telemetry {
1329
1302
/**
1330
1303
* A SpanExporter compatible with OpenTelemetry.js
1331
1304
* https://open-telemetry.github.io/opentelemetry-js/interfaces/_opentelemetry_sdk_trace_base.SpanExporter.html
@@ -1345,14 +1318,6 @@ declare namespace Deno {
1345
1318
export { } ; // only export exports
1346
1319
}
1347
1320
1348
- /**
1349
- * @category Telemetry
1350
- * @experimental
1351
- */
1352
- export namespace metrics {
1353
- export { } ; // only export exports
1354
- }
1355
-
1356
1321
export { } ; // only export exports
1357
1322
}
1358
1323
0 commit comments