bageren
bageren9mo ago

OpenTelemetry instrumentation

Did anyone have some luck making OpenTelemetry instrumentation libraries work on Deno? I've seen some examples on the internet of @opentelemetry/instrumentation-fetch working, but I've been unable to make mine work so far. I did manage to find a workaround for that, but now I'm trying to get instrumentation for my SQL queries. I'm currently using drizzle-orm and tried to install @opentelemetry/instrumentation-pg. But just like the fetch instrumentation, it doesn't seem to be doing anything at all. Is there something special required to make this work, or are Open Telemetry instrumentation libraries just completely broken on Deno?
3 Replies
Deno AI Helper
Deno AI Helper9mo ago
I wasn't able to find the answer to your question in the official Deno documentation. However, based on the information you've provided, there are a few things to consider: 1. Deno does not use the Node package manager (npm), and therefore packages like @opentelemetry/instrumentation-fetch or @opentelemetry/instrumentation-pg that are designed for Node.js might not work out of the box in Deno. Deno has its own set of APIs and standard library, and it uses URLs for importing modules. 2. If you are trying to use Node.js packages in Deno, you might encounter compatibility issues since Deno does not support the Node.js module system natively. You would typically need to find a Deno-specific module or a polyfill that provides similar functionality. 3. For SQL query instrumentation in Deno, you would need to look for Deno-specific libraries or adapt existing OpenTelemetry instrumentation to work with Deno's module system and runtime environment. Please note that this advice is not based on the Deno documentation, and I would advise you to double-check the accuracy of the advice given. Since Deno and Node.js have different ecosystems, it's important to look for Deno-compatible libraries or workarounds that fit within Deno's module system and runtime constraints.
realpha
realpha9mo ago
I didn’t take a closer look yet, but IIRC all open telemetry packages depend on async hooks, which unfortunately are currently not supported on deno
dantheman
dantheman7mo ago
I did a partial rebuild of opentelemetry-js to Deno, maybe it is helpful. I've been using it for the past year with personal and workplace scripts, incl. Deno Deploy. I also supply Deno-specific instrumentations (http serving, fetch, KV, etc) and some async function wrappers to instrument business logic. I suspect that instrumentation packages from NPM wouldn't want to transmit to this ported version, maybe an importmap could help. Repo: https://github.com/cloudydeno/deno-observability
GitHub
GitHub - cloudydeno/deno-observability: WIP module for instrumentin...
WIP module for instrumenting Deno programs with OpenTelemetry, transmitting traces and metrics in a standard way. - cloudydeno/deno-observability