Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deno panics while serving otel example #27272

Closed
zachauten opened this issue Dec 8, 2024 · 0 comments · Fixed by #27292
Closed

Deno panics while serving otel example #27272

zachauten opened this issue Dec 8, 2024 · 0 comments · Fixed by #27292
Assignees
Labels
bug Something isn't working correctly otel

Comments

@zachauten
Copy link
Contributor

zachauten commented Dec 8, 2024

Running the example from the Deno.telemetry docs.

main.ts:

import { trace } from "npm:@opentelemetry/api@1";
import "jsr:@deno/otel@0.0.2/register";

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;
});

bash script that sets env variables and runs the server:

export OTEL_SERVICE_NAME=my-service-name
export OTEL_EXPORTER_OTLP_ENDPOINT="https://api.honeycomb.io"
export OTEL_EXPORTER_OTLP_HEADERS="x-honeycomb-team=***"
export RUST_BACKTRACE=full
deno run --unstable-otel -A main.ts

Backtrace:

Listening on http://0.0.0.0:8000/

============================================================
Deno has panicked. This is a bug in Deno. Please report this
at https://github.com/denoland/deno/issues/new.
If you can reliably reproduce this panic, include the
reproduction steps and re-run with the RUST_BACKTRACE=1 env
var set and include the backtrace in your report.

Platform: linux x86_64
Version: 2.1.2
Args: ["deno", "run", "--unstable-otel", "-A", "main.ts"]

thread 'main' panicked at ext/telemetry/lib.rs:638:42:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0:     0x55dba96fe921 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h9754a6437f1de22a
   1:     0x55dba81d5a5b - core::fmt::write::hb706a393bb60a06f
   2:     0x55dba9702088 - std::io::Write::write_fmt::h9b447dc5d824d0bd
   3:     0x55dba9735153 - std::panicking::default_hook::{{closure}}::h227952daede9dd84
   4:     0x55dba9734e54 - std::panicking::default_hook::h31626ee1feb8ee2a
   5:     0x55dba810784e - deno::setup_panic_hook::{{closure}}::he901c578798dbf08
   6:     0x55dba9735b99 - std::panicking::rust_panic_with_hook::h76d2aa694a00748e
   7:     0x55dba96fed42 - std::panicking::begin_panic_handler::{{closure}}::h8855a344ffa1638b
   8:     0x55dba96fecd9 - std::sys::backtrace::__rust_end_short_backtrace::h3110d0cbfbf26886
   9:     0x55dba9735584 - rust_begin_unwind
  10:     0x55dba7a1f522 - core::panicking::panic_fmt::h3af706d0346c1c60
  11:     0x55dba7a1f4eb - core::panicking::panic::h8fa9c73fac331fdb
  12:     0x55dba7a1f4a8 - core::option::unwrap_failed::had2d05111e3e145c
  13:     0x55dba8f83f4e - deno_telemetry::op_otel_instrumentation_scope_enter_builtin::op_otel_instrumentation_scope_enter_builtin::v8_fn_ptr::hcd9ad9072700e39b
  14:     0x55db4a2cf1c6 - <unknown>
@bartlomieju bartlomieju added the bug Something isn't working correctly label Dec 9, 2024
devsnek added a commit that referenced this issue Dec 9, 2024
otel global state may not be initialized if otel is not enabled, so bail
out instead of panicking.

Fixes: #27272
bartlomieju pushed a commit that referenced this issue Dec 11, 2024
otel global state may not be initialized if otel is not enabled, so bail
out instead of panicking.

Fixes: #27272
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly otel
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants