mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 20:29:11 +00:00
feat(otel): stabilize OpenTelemetry support (#29822)
Some checks are pending
ci / build libs (push) Blocked by required conditions
ci / pre-build (push) Waiting to run
ci / test debug linux-aarch64 (push) Blocked by required conditions
ci / test release linux-aarch64 (push) Blocked by required conditions
ci / test debug macos-aarch64 (push) Blocked by required conditions
ci / test release macos-aarch64 (push) Blocked by required conditions
ci / bench release linux-x86_64 (push) Blocked by required conditions
ci / lint debug linux-x86_64 (push) Blocked by required conditions
ci / lint debug macos-x86_64 (push) Blocked by required conditions
ci / lint debug windows-x86_64 (push) Blocked by required conditions
ci / test debug linux-x86_64 (push) Blocked by required conditions
ci / test release linux-x86_64 (push) Blocked by required conditions
ci / test debug macos-x86_64 (push) Blocked by required conditions
ci / test release macos-x86_64 (push) Blocked by required conditions
ci / test debug windows-x86_64 (push) Blocked by required conditions
ci / test release windows-x86_64 (push) Blocked by required conditions
ci / publish canary (push) Blocked by required conditions
Some checks are pending
ci / build libs (push) Blocked by required conditions
ci / pre-build (push) Waiting to run
ci / test debug linux-aarch64 (push) Blocked by required conditions
ci / test release linux-aarch64 (push) Blocked by required conditions
ci / test debug macos-aarch64 (push) Blocked by required conditions
ci / test release macos-aarch64 (push) Blocked by required conditions
ci / bench release linux-x86_64 (push) Blocked by required conditions
ci / lint debug linux-x86_64 (push) Blocked by required conditions
ci / lint debug macos-x86_64 (push) Blocked by required conditions
ci / lint debug windows-x86_64 (push) Blocked by required conditions
ci / test debug linux-x86_64 (push) Blocked by required conditions
ci / test release linux-x86_64 (push) Blocked by required conditions
ci / test debug macos-x86_64 (push) Blocked by required conditions
ci / test release macos-x86_64 (push) Blocked by required conditions
ci / test debug windows-x86_64 (push) Blocked by required conditions
ci / test release windows-x86_64 (push) Blocked by required conditions
ci / publish canary (push) Blocked by required conditions
This commit stabilizes support for OpenTelemetry in Deno, effectively removing the need to use `--unstable-otel` flag or using `{ "unstable": ["otel"] }` option in the config file. Supersedes https://github.com/denoland/deno/pull/29500 Closes https://github.com/denoland/deno/issues/29477
This commit is contained in:
parent
ed0c77edb3
commit
14f9d77f3d
6 changed files with 87 additions and 103 deletions
|
@ -1010,11 +1010,6 @@ impl Flags {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn otel_config(&self) -> OtelConfig {
|
pub fn otel_config(&self) -> OtelConfig {
|
||||||
let has_unstable_flag = self
|
|
||||||
.unstable_config
|
|
||||||
.features
|
|
||||||
.contains(&String::from("otel"));
|
|
||||||
|
|
||||||
let otel_var = |name| match std::env::var(name) {
|
let otel_var = |name| match std::env::var(name) {
|
||||||
Ok(s) if s.eq_ignore_ascii_case("true") => Some(true),
|
Ok(s) if s.eq_ignore_ascii_case("true") => Some(true),
|
||||||
Ok(s) if s.eq_ignore_ascii_case("false") => Some(false),
|
Ok(s) if s.eq_ignore_ascii_case("false") => Some(false),
|
||||||
|
@ -1025,8 +1020,7 @@ impl Flags {
|
||||||
Err(_) => None,
|
Err(_) => None,
|
||||||
};
|
};
|
||||||
|
|
||||||
let disabled =
|
let disabled = otel_var("OTEL_SDK_DISABLED").unwrap_or(false);
|
||||||
!has_unstable_flag || otel_var("OTEL_SDK_DISABLED").unwrap_or(false);
|
|
||||||
let default = !disabled && otel_var("OTEL_DENO").unwrap_or(false);
|
let default = !disabled && otel_var("OTEL_DENO").unwrap_or(false);
|
||||||
|
|
||||||
let propagators = if default {
|
let propagators = if default {
|
||||||
|
|
83
cli/tsc/dts/lib.deno.ns.d.ts
vendored
83
cli/tsc/dts/lib.deno.ns.d.ts
vendored
|
@ -6286,5 +6286,88 @@ declare namespace Deno {
|
||||||
| (CreateHttpClientOptions & TlsCertifiedKeyPem),
|
| (CreateHttpClientOptions & TlsCertifiedKeyPem),
|
||||||
): HttpClient;
|
): HttpClient;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* APIs for working with the OpenTelemetry observability framework. Deno can
|
||||||
|
* export traces, metrics, and logs to OpenTelemetry compatible backends via
|
||||||
|
* the OTLP protocol.
|
||||||
|
*
|
||||||
|
* Deno automatically instruments the runtime with OpenTelemetry traces and
|
||||||
|
* metrics. This data is exported via OTLP to OpenTelemetry compatible
|
||||||
|
* backends. User logs from the `console` API are exported as OpenTelemetry
|
||||||
|
* logs via OTLP.
|
||||||
|
*
|
||||||
|
* User code can also create custom traces, metrics, and logs using the
|
||||||
|
* OpenTelemetry API. This is done using the official OpenTelemetry package
|
||||||
|
* for JavaScript:
|
||||||
|
* [`npm:@opentelemetry/api`](https://opentelemetry.io/docs/languages/js/).
|
||||||
|
* Deno integrates with this package to provide tracing, metrics, and trace
|
||||||
|
* context propagation between native Deno APIs (like `Deno.serve` or `fetch`)
|
||||||
|
* and custom user code. Deno automatically registers the providers with the
|
||||||
|
* OpenTelemetry API, so users can start creating custom traces, metrics, and
|
||||||
|
* logs without any additional setup.
|
||||||
|
*
|
||||||
|
* @example Using OpenTelemetry API to create custom traces
|
||||||
|
* ```ts,ignore
|
||||||
|
* import { trace } from "npm:@opentelemetry/api@1";
|
||||||
|
*
|
||||||
|
* const tracer = trace.getTracer("example-tracer");
|
||||||
|
*
|
||||||
|
* async function doWork() {
|
||||||
|
* return tracer.startActiveSpan("doWork", async (span) => {
|
||||||
|
* span.setAttribute("key", "value");
|
||||||
|
* await new Promise((resolve) => setTimeout(resolve, 1000));
|
||||||
|
* span.end();
|
||||||
|
* });
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* Deno.serve(async (req) => {
|
||||||
|
* await doWork();
|
||||||
|
* const resp = await fetch("https://example.com");
|
||||||
|
* return resp;
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* @category Telemetry
|
||||||
|
*/
|
||||||
|
export namespace telemetry {
|
||||||
|
/**
|
||||||
|
* A TracerProvider compatible with OpenTelemetry.js
|
||||||
|
* https://open-telemetry.github.io/opentelemetry-js/interfaces/_opentelemetry_api.TracerProvider.html
|
||||||
|
*
|
||||||
|
* This is a singleton object that implements the OpenTelemetry
|
||||||
|
* TracerProvider interface.
|
||||||
|
*
|
||||||
|
* @category Telemetry
|
||||||
|
*/
|
||||||
|
// deno-lint-ignore no-explicit-any
|
||||||
|
export const tracerProvider: any;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A ContextManager compatible with OpenTelemetry.js
|
||||||
|
* https://open-telemetry.github.io/opentelemetry-js/interfaces/_opentelemetry_api.ContextManager.html
|
||||||
|
*
|
||||||
|
* This is a singleton object that implements the OpenTelemetry
|
||||||
|
* ContextManager interface.
|
||||||
|
*
|
||||||
|
* @category Telemetry
|
||||||
|
*/
|
||||||
|
// deno-lint-ignore no-explicit-any
|
||||||
|
export const contextManager: any;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A MeterProvider compatible with OpenTelemetry.js
|
||||||
|
* https://open-telemetry.github.io/opentelemetry-js/interfaces/_opentelemetry_api.MeterProvider.html
|
||||||
|
*
|
||||||
|
* This is a singleton object that implements the OpenTelemetry
|
||||||
|
* MeterProvider interface.
|
||||||
|
*
|
||||||
|
* @category Telemetry
|
||||||
|
*/
|
||||||
|
// deno-lint-ignore no-explicit-any
|
||||||
|
export const meterProvider: any;
|
||||||
|
|
||||||
|
export {}; // only export exports
|
||||||
|
}
|
||||||
|
|
||||||
export {}; // only export exports
|
export {}; // only export exports
|
||||||
}
|
}
|
||||||
|
|
89
cli/tsc/dts/lib.deno.unstable.d.ts
vendored
89
cli/tsc/dts/lib.deno.unstable.d.ts
vendored
|
@ -1259,95 +1259,6 @@ declare namespace Deno {
|
||||||
export {}; // only export exports
|
export {}; // only export exports
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* **UNSTABLE**: New API, yet to be vetted.
|
|
||||||
*
|
|
||||||
* APIs for working with the OpenTelemetry observability framework. Deno can
|
|
||||||
* export traces, metrics, and logs to OpenTelemetry compatible backends via
|
|
||||||
* the OTLP protocol.
|
|
||||||
*
|
|
||||||
* Deno automatically instruments the runtime with OpenTelemetry traces and
|
|
||||||
* metrics. This data is exported via OTLP to OpenTelemetry compatible
|
|
||||||
* backends. User logs from the `console` API are exported as OpenTelemetry
|
|
||||||
* logs via OTLP.
|
|
||||||
*
|
|
||||||
* User code can also create custom traces, metrics, and logs using the
|
|
||||||
* OpenTelemetry API. This is done using the official OpenTelemetry package
|
|
||||||
* for JavaScript:
|
|
||||||
* [`npm:@opentelemetry/api`](https://opentelemetry.io/docs/languages/js/).
|
|
||||||
* Deno integrates with this package to provide tracing, metrics, and trace
|
|
||||||
* context propagation between native Deno APIs (like `Deno.serve` or `fetch`)
|
|
||||||
* and custom user code. Deno automatically registers the providers with the
|
|
||||||
* OpenTelemetry API, so users can start creating custom traces, metrics, and
|
|
||||||
* logs without any additional setup.
|
|
||||||
*
|
|
||||||
* @example Using OpenTelemetry API to create custom traces
|
|
||||||
* ```ts,ignore
|
|
||||||
* import { trace } from "npm:@opentelemetry/api@1";
|
|
||||||
*
|
|
||||||
* const tracer = trace.getTracer("example-tracer");
|
|
||||||
*
|
|
||||||
* async function doWork() {
|
|
||||||
* return tracer.startActiveSpan("doWork", async (span) => {
|
|
||||||
* span.setAttribute("key", "value");
|
|
||||||
* await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
||||||
* span.end();
|
|
||||||
* });
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
* Deno.serve(async (req) => {
|
|
||||||
* await doWork();
|
|
||||||
* const resp = await fetch("https://example.com");
|
|
||||||
* return resp;
|
|
||||||
* });
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* @category Telemetry
|
|
||||||
* @experimental
|
|
||||||
*/
|
|
||||||
export namespace telemetry {
|
|
||||||
/**
|
|
||||||
* A TracerProvider compatible with OpenTelemetry.js
|
|
||||||
* https://open-telemetry.github.io/opentelemetry-js/interfaces/_opentelemetry_api.TracerProvider.html
|
|
||||||
*
|
|
||||||
* This is a singleton object that implements the OpenTelemetry
|
|
||||||
* TracerProvider interface.
|
|
||||||
*
|
|
||||||
* @category Telemetry
|
|
||||||
* @experimental
|
|
||||||
*/
|
|
||||||
// deno-lint-ignore no-explicit-any
|
|
||||||
export const tracerProvider: any;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A ContextManager compatible with OpenTelemetry.js
|
|
||||||
* https://open-telemetry.github.io/opentelemetry-js/interfaces/_opentelemetry_api.ContextManager.html
|
|
||||||
*
|
|
||||||
* This is a singleton object that implements the OpenTelemetry
|
|
||||||
* ContextManager interface.
|
|
||||||
*
|
|
||||||
* @category Telemetry
|
|
||||||
* @experimental
|
|
||||||
*/
|
|
||||||
// deno-lint-ignore no-explicit-any
|
|
||||||
export const contextManager: any;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A MeterProvider compatible with OpenTelemetry.js
|
|
||||||
* https://open-telemetry.github.io/opentelemetry-js/interfaces/_opentelemetry_api.MeterProvider.html
|
|
||||||
*
|
|
||||||
* This is a singleton object that implements the OpenTelemetry
|
|
||||||
* MeterProvider interface.
|
|
||||||
*
|
|
||||||
* @category Telemetry
|
|
||||||
* @experimental
|
|
||||||
*/
|
|
||||||
// deno-lint-ignore no-explicit-any
|
|
||||||
export const meterProvider: any;
|
|
||||||
|
|
||||||
export {}; // only export exports
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @category Linter
|
* @category Linter
|
||||||
* @experimental
|
* @experimental
|
||||||
|
|
|
@ -166,6 +166,7 @@ const denoNs = {
|
||||||
umask: fs.umask,
|
umask: fs.umask,
|
||||||
HttpClient: httpClient.HttpClient,
|
HttpClient: httpClient.HttpClient,
|
||||||
createHttpClient: httpClient.createHttpClient,
|
createHttpClient: httpClient.createHttpClient,
|
||||||
|
telemetry: telemetry.telemetry,
|
||||||
};
|
};
|
||||||
|
|
||||||
const denoNsUnstableById = { __proto__: null };
|
const denoNsUnstableById = { __proto__: null };
|
||||||
|
@ -229,8 +230,4 @@ ObjectDefineProperties(denoNsUnstableById[unstableIds.webgpu], {
|
||||||
|
|
||||||
// denoNsUnstableById[unstableIds.workerOptions] = { __proto__: null }
|
// denoNsUnstableById[unstableIds.workerOptions] = { __proto__: null }
|
||||||
|
|
||||||
denoNsUnstableById[unstableIds.otel] = {
|
|
||||||
telemetry: telemetry.telemetry,
|
|
||||||
};
|
|
||||||
|
|
||||||
export { denoNs, denoNsUnstableById, unstableIds };
|
export { denoNs, denoNsUnstableById, unstableIds };
|
||||||
|
|
|
@ -6,7 +6,7 @@ const command1 = new Deno.Command(Deno.execPath(), {
|
||||||
"OTEL_SERVICE_NAME": "server_1",
|
"OTEL_SERVICE_NAME": "server_1",
|
||||||
"DENO_UNSTABLE_OTEL_DETERMINISTIC": "1",
|
"DENO_UNSTABLE_OTEL_DETERMINISTIC": "1",
|
||||||
},
|
},
|
||||||
args: ["run", "-A", "--unstable-otel", "http_propagators_1.ts"],
|
args: ["run", "-A", "http_propagators_1.ts"],
|
||||||
});
|
});
|
||||||
|
|
||||||
const p1 = command1.output();
|
const p1 = command1.output();
|
||||||
|
@ -19,7 +19,7 @@ const command2 = new Deno.Command(Deno.execPath(), {
|
||||||
"OTEL_SERVICE_NAME": "server_2",
|
"OTEL_SERVICE_NAME": "server_2",
|
||||||
"DENO_UNSTABLE_OTEL_DETERMINISTIC": "2",
|
"DENO_UNSTABLE_OTEL_DETERMINISTIC": "2",
|
||||||
},
|
},
|
||||||
args: ["run", "-A", "--unstable-otel", "http_propagators_2.ts"],
|
args: ["run", "-A", "http_propagators_2.ts"],
|
||||||
});
|
});
|
||||||
|
|
||||||
const p2 = command2.output();
|
const p2 = command2.output();
|
||||||
|
|
|
@ -18,7 +18,6 @@ const server = Deno.serve(
|
||||||
"--env-file=env_file",
|
"--env-file=env_file",
|
||||||
"-A",
|
"-A",
|
||||||
"-q",
|
"-q",
|
||||||
"--unstable-otel",
|
|
||||||
Deno.args[0],
|
Deno.args[0],
|
||||||
],
|
],
|
||||||
env: {
|
env: {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue