fix: move otel logic into otel (#29073)

cleanup
229228ae0d
This commit is contained in:
snek 2025-04-28 15:09:15 +02:00 committed by GitHub
parent a33dae6a2a
commit f360d61d64
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 11 deletions

View file

@ -51,7 +51,6 @@ use deno_runtime::tokio_util::create_and_run_current_thread_with_maybe_metrics;
use deno_runtime::WorkerExecutionMode;
pub use deno_runtime::UNSTABLE_FEATURES;
use deno_telemetry::OtelConfig;
use deno_telemetry::OtelConsoleConfig;
use deno_terminal::colors;
use factory::CliFactory;
@ -490,15 +489,10 @@ fn resolve_flags_and_init(
let otel_config = flags.otel_config();
init_logging(flags.log_level, Some(otel_config.clone()));
if otel_config.metrics_enabled
|| otel_config.tracing_enabled
|| !matches!(otel_config.console, OtelConsoleConfig::Ignore)
{
deno_telemetry::init(
deno_lib::version::otel_runtime_config(),
otel_config.clone(),
)?;
}
deno_telemetry::init(
deno_lib::version::otel_runtime_config(),
otel_config.clone(),
)?;
// TODO(bartlomieju): remove in Deno v2.5 and hard error then.
if flags.unstable_config.legacy_flag_enabled {

View file

@ -162,7 +162,7 @@ pub enum OtelPropagators {
None = 2,
}
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[repr(u8)]
pub enum OtelConsoleConfig {
Ignore = 0,
@ -636,6 +636,13 @@ pub fn init(
rt_config: OtelRuntimeConfig,
config: OtelConfig,
) -> deno_core::anyhow::Result<()> {
if !config.metrics_enabled
&& !config.tracing_enabled
&& config.console == OtelConsoleConfig::Ignore
{
return Ok(());
}
// Parse the `OTEL_EXPORTER_OTLP_PROTOCOL` variable. The opentelemetry_*
// crates don't do this automatically.
// TODO(piscisaureus): enable GRPC support.