Skip to content

Commit

Permalink
Merge branch 'main' into fix/webgpu-adapter-info
Browse files Browse the repository at this point in the history
  • Loading branch information
petamoriken authored Nov 13, 2024
2 parents 970102e + 9331e2c commit 420ea5e
Show file tree
Hide file tree
Showing 27 changed files with 1,750 additions and 195 deletions.
395 changes: 283 additions & 112 deletions Cargo.lock

Large diffs are not rendered by default.

18 changes: 12 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ repository = "https://github.com/denoland/deno"

[workspace.dependencies]
deno_ast = { version = "=0.43.3", features = ["transpiling"] }
deno_core = { version = "0.318.0" }
deno_core = { version = "0.319.0" }

deno_bench_util = { version = "0.171.0", path = "./bench_util" }
deno_lockfile = "=0.23.1"
Expand All @@ -60,10 +60,10 @@ deno_terminal = "0.2.0"
napi_sym = { version = "0.107.0", path = "./ext/napi/sym" }
test_util = { package = "test_server", path = "./tests/util/server" }

denokv_proto = "0.8.1"
denokv_remote = "0.8.1"
denokv_proto = "0.8.4"
denokv_remote = "0.8.4"
# denokv_sqlite brings in bundled sqlite if we don't disable the default features
denokv_sqlite = { default-features = false, version = "0.8.2" }
denokv_sqlite = { default-features = false, version = "0.8.4" }

# exts
deno_broadcast_channel = { version = "0.171.0", path = "./ext/broadcast_channel" }
Expand Down Expand Up @@ -157,8 +157,8 @@ percent-encoding = "2.3.0"
phf = { version = "0.11", features = ["macros"] }
pin-project = "1.0.11" # don't pin because they yank crates from cargo
pretty_assertions = "=1.4.0"
prost = "0.11"
prost-build = "0.11"
prost = "0.13"
prost-build = "0.13"
rand = "=0.8.5"
regex = "^1.7.0"
reqwest = { version = "=0.12.5", default-features = false, features = ["rustls-tls", "stream", "gzip", "brotli", "socks", "json", "http2"] } # pinned because of https://github.com/seanmonstar/reqwest/pull/1955
Expand Down Expand Up @@ -207,6 +207,12 @@ yoke = { version = "0.7.4", features = ["derive"] }
zeromq = { version = "=0.4.1", default-features = false, features = ["tcp-transport", "tokio-runtime"] }
zstd = "=0.12.4"

opentelemetry = "0.27.0"
opentelemetry-http = "0.27.0"
opentelemetry-otlp = { version = "0.27.0", features = ["logs", "http-proto", "http-json"] }
opentelemetry-semantic-conventions = { version = "0.27.0", features = ["semconv_experimental"] }
opentelemetry_sdk = "0.27.0"

# crypto
hkdf = "0.12.3"
rsa = { version = "0.9.3", default-features = false, features = ["std", "pem", "hazmat"] } # hazmat needed for PrehashSigner in ext/node
Expand Down
18 changes: 18 additions & 0 deletions cli/args/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use deno_npm::npm_rc::ResolvedNpmRc;
use deno_npm::resolution::ValidSerializedNpmResolutionSnapshot;
use deno_npm::NpmSystemInfo;
use deno_path_util::normalize_path;
use deno_runtime::ops::otel::OtelConfig;
use deno_semver::npm::NpmPackageReqReference;
use import_map::resolve_import_map_value_from_specifier;

Expand Down Expand Up @@ -1129,6 +1130,23 @@ impl CliOptions {
}
}

pub fn otel_config(&self) -> Option<OtelConfig> {
if self
.flags
.unstable_config
.features
.contains(&String::from("otel"))
{
Some(OtelConfig {
runtime_name: Cow::Borrowed("deno"),
runtime_version: Cow::Borrowed(crate::version::DENO_VERSION_INFO.deno),
..Default::default()
})
} else {
None
}
}

pub fn env_file_name(&self) -> Option<&String> {
self.flags.env_file.as_ref()
}
Expand Down
1 change: 1 addition & 0 deletions cli/factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -939,6 +939,7 @@ impl CliFactory {
StorageKeyResolver::from_options(cli_options),
cli_options.sub_command().clone(),
self.create_cli_main_worker_options()?,
self.cli_options()?.otel_config(),
))
}

Expand Down
3 changes: 3 additions & 0 deletions cli/standalone/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ use deno_runtime::deno_fs::FileSystem;
use deno_runtime::deno_fs::RealFs;
use deno_runtime::deno_io::fs::FsError;
use deno_runtime::deno_node::PackageJson;
use deno_runtime::ops::otel::OtelConfig;
use deno_semver::npm::NpmVersionReqParseError;
use deno_semver::package::PackageReq;
use deno_semver::Version;
Expand Down Expand Up @@ -185,6 +186,7 @@ pub struct Metadata {
pub entrypoint_key: String,
pub node_modules: Option<NodeModules>,
pub unstable_config: UnstableConfig,
pub otel_config: Option<OtelConfig>, // None means disabled.
}

fn write_binary_bytes(
Expand Down Expand Up @@ -722,6 +724,7 @@ impl<'a> DenoCompileBinaryWriter<'a> {
sloppy_imports: cli_options.unstable_sloppy_imports(),
features: cli_options.unstable_features(),
},
otel_config: cli_options.otel_config(),
};

write_binary_bytes(
Expand Down
1 change: 1 addition & 0 deletions cli/standalone/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,7 @@ pub async fn run(data: StandaloneData) -> Result<i32, AnyError> {
serve_port: None,
serve_host: None,
},
metadata.otel_config,
);

// Initialize v8 once from the main thread.
Expand Down
102 changes: 102 additions & 0 deletions cli/tsc/dts/lib.deno.unstable.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1225,6 +1225,108 @@ declare namespace Deno {
export {}; // only export exports
}

/**
* @category Telemetry
* @experimental
*/
export namespace tracing {
/**
* Whether tracing is enabled.
* @category Telemetry
* @experimental
*/
export const enabled: boolean;

/**
* Allowed attribute type.
* @category Telemetry
* @experimental
*/
export type AttributeValue = string | number | boolean | bigint;

/**
* A tracing span.
* @category Telemetry
* @experimental
*/
export class Span implements Disposable {
readonly traceId: string;
readonly spanId: string;
readonly parentSpanId: string;
readonly kind: string;
readonly name: string;
readonly startTime: number;
readonly endTime: number;
readonly status: null | { code: 1 } | { code: 2; message: string };
readonly attributes: Record<string, AttributeValue>;
readonly traceFlags: number;

/**
* Construct a new Span and enter it as the "current" span.
*/
constructor(
name: string,
kind?: "internal" | "server" | "client" | "producer" | "consumer",
);

/**
* Set an attribute on this span.
*/
setAttribute(
name: string,
value: AttributeValue,
): void;

/**
* Enter this span as the "current" span.
*/
enter(): void;

/**
* Exit this span as the "current" span and restore the previous one.
*/
exit(): void;

/**
* End this span, and exit it as the "current" span.
*/
end(): void;

[Symbol.dispose](): void;

/**
* Get the "current" span, if one exists.
*/
static current(): Span | undefined | null;
}

/**
* A SpanExporter compatible with OpenTelemetry.js
* https://open-telemetry.github.io/opentelemetry-js/interfaces/_opentelemetry_sdk_trace_base.SpanExporter.html
* @category Telemetry
* @experimental
*/
export class SpanExporter {}

/**
* A ContextManager compatible with OpenTelemetry.js
* https://open-telemetry.github.io/opentelemetry-js/interfaces/_opentelemetry_api.ContextManager.html
* @category Telemetry
* @experimental
*/
export class ContextManager {}

export {}; // only export exports
}

/**
* @category Telemetry
* @experimental
*/
export namespace metrics {
export {}; // only export exports
}

export {}; // only export exports
}

Expand Down
6 changes: 6 additions & 0 deletions cli/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use deno_runtime::deno_tls::RootCertStoreProvider;
use deno_runtime::deno_web::BlobStore;
use deno_runtime::fmt_errors::format_js_error;
use deno_runtime::inspector_server::InspectorServer;
use deno_runtime::ops::otel::OtelConfig;
use deno_runtime::ops::process::NpmProcessStateProviderRc;
use deno_runtime::ops::worker_host::CreateWebWorkerCb;
use deno_runtime::web_worker::WebWorker;
Expand Down Expand Up @@ -142,6 +143,7 @@ struct SharedWorkerState {
storage_key_resolver: StorageKeyResolver,
options: CliMainWorkerOptions,
subcommand: DenoSubcommand,
otel_config: Option<OtelConfig>, // `None` means OpenTelemetry is disabled.
}

impl SharedWorkerState {
Expand Down Expand Up @@ -405,6 +407,7 @@ impl CliMainWorkerFactory {
storage_key_resolver: StorageKeyResolver,
subcommand: DenoSubcommand,
options: CliMainWorkerOptions,
otel_config: Option<OtelConfig>,
) -> Self {
Self {
shared: Arc::new(SharedWorkerState {
Expand All @@ -427,6 +430,7 @@ impl CliMainWorkerFactory {
storage_key_resolver,
options,
subcommand,
otel_config,
}),
}
}
Expand Down Expand Up @@ -576,6 +580,7 @@ impl CliMainWorkerFactory {
mode,
serve_port: shared.options.serve_port,
serve_host: shared.options.serve_host.clone(),
otel_config: shared.otel_config.clone(),
},
extensions: custom_extensions,
startup_snapshot: crate::js::deno_isolate_init(),
Expand Down Expand Up @@ -775,6 +780,7 @@ fn create_web_worker_callback(
mode: WorkerExecutionMode::Worker,
serve_port: shared.options.serve_port,
serve_host: shared.options.serve_host.clone(),
otel_config: shared.otel_config.clone(),
},
extensions: vec![],
startup_snapshot: crate::js::deno_isolate_init(),
Expand Down
Loading

0 comments on commit 420ea5e

Please sign in to comment.