mirror of
https://github.com/denoland/deno.git
synced 2024-12-18 05:14:21 -05:00
fix(unstable): don't unwrap optional state in otel (#27292)
otel global state may not be initialized if otel is not enabled, so bail out instead of panicking. Fixes: https://github.com/denoland/deno/issues/27272
This commit is contained in:
parent
da3a676d1c
commit
1c0f236923
2 changed files with 8 additions and 7 deletions
|
@ -732,9 +732,9 @@ fn op_otel_instrumentation_scope_enter(
|
||||||
|
|
||||||
#[op2(fast)]
|
#[op2(fast)]
|
||||||
fn op_otel_instrumentation_scope_enter_builtin(state: &mut OpState) {
|
fn op_otel_instrumentation_scope_enter_builtin(state: &mut OpState) {
|
||||||
state.put(InstrumentationScope(
|
if let Some(scope) = BUILT_IN_INSTRUMENTATION_SCOPE.get() {
|
||||||
BUILT_IN_INSTRUMENTATION_SCOPE.get().unwrap().clone(),
|
state.put(InstrumentationScope(scope.clone()));
|
||||||
));
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op2(fast)]
|
#[op2(fast)]
|
||||||
|
@ -749,6 +749,9 @@ fn op_otel_log(
|
||||||
let Some(Processors { logs, .. }) = OTEL_PROCESSORS.get() else {
|
let Some(Processors { logs, .. }) = OTEL_PROCESSORS.get() else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
let Some(instrumentation_scope) = BUILT_IN_INSTRUMENTATION_SCOPE.get() else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
// Convert the integer log level that ext/console uses to the corresponding
|
// Convert the integer log level that ext/console uses to the corresponding
|
||||||
// OpenTelemetry log severity.
|
// OpenTelemetry log severity.
|
||||||
|
@ -776,10 +779,7 @@ fn op_otel_log(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
logs.emit(
|
logs.emit(&mut log_record, instrumentation_scope);
|
||||||
&mut log_record,
|
|
||||||
BUILT_IN_INSTRUMENTATION_SCOPE.get().unwrap(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn owned_string<'s>(
|
fn owned_string<'s>(
|
||||||
|
|
|
@ -220,6 +220,7 @@ function submitSpan(
|
||||||
startTime: number,
|
startTime: number,
|
||||||
endTime: number,
|
endTime: number,
|
||||||
) {
|
) {
|
||||||
|
if (!TRACING_ENABLED) return;
|
||||||
if (!(traceFlags & TRACE_FLAG_SAMPLED)) return;
|
if (!(traceFlags & TRACE_FLAG_SAMPLED)) return;
|
||||||
|
|
||||||
// TODO(@lucacasonato): `resource` is ignored for now, should we implement it?
|
// TODO(@lucacasonato): `resource` is ignored for now, should we implement it?
|
||||||
|
|
Loading…
Reference in a new issue