CEOInterviews.AI
Start App
Get an email when Ryan Dahl gives a new interview
One email per new interview. Unsubscribe in one click.
Ryan Dahl
Co-founder, Deno (now part of Cloudflare), Cloudflare

Ryan Dahl on Deno and OpenTelemetry

📅 Apr 15, 2025 Deno 20 MIN 20817 VIEWS 10 SEGMENTS · 1 SPEAKERS
Originally published on dotJS YouTube:    • Live coding with Ryan Dahl: Deno and OpenT...   00:00 Intro 00:24 What is Deno? 02:05 Debugging with console.log 02:42 DEMO: figuring out a bug with console.logs 09:55 DEMO: looking at Grafana with logs 11:14 Logs vs. Traces 12:30 It's not magic — it's called async context propagation ✨ 13:39 Metrics 14:34 How to get started right now 16:53 Top secret Deno Deploy demo featuring built-in telemetry 18:39 #FreeJavaScript plug Read more about Deno's built-in OpenTelemetry support: https://deno.com/blog/zero-config-deb... https://deno.com/blog/otel-trac...
Ryan Dahl 0:12 ↗
Hi everyone. Nice to be here. Very bright up here. Hey, I'm going to talk to you about Deno and OpenTelemetry. Raise your hand if you know what Deno is. Great. Raise your hand if you have used Deno. Good. Awesome. Yeah, for those of you who don't know, Deno is a JavaScript and TypeScript runtime and it has TypeScript kind of deeply baked into it and it can do more than just execute TypeScript. It can do type checking and it is really thoughtful about web standards and is of course a server-side runtime but tries to narrow the gap between browsers and server JavaScript. It is an out-of-the-box toolchain. Everything you need comes in a single file and yeah, has all sorts of tooling for manipulating, using, understanding JavaScript and TypeScript. It is secure by default, famously secure by default I should say. Like browser JavaScript, you don't get access to the file system or the network by default and it is backwards compatible with Node since Deno 2.0.
Now, debugging production applications is hard. Who here has struggled with high-traffic servers and understanding what is going on there? Some of you, yes, it can be very painful. There is technological solutions these days to this that can make this much, much better. But we often come back to the humble console log to solve many problems. I have used step debuggers. I've used breakpoints in many situations, but I think I would be lying if I don't say that I debug most problems with console logs. But in production servers, we can do better. And we can do better without too much trouble. So to demonstrate this, let's pretend we have a service with a bug and let's develop this on the fly here. This will be a little bit contrived but bear with me. So let's imagine that we have a function called createUser and it's going to create a new user ID and it's going to write it to the database. But we'll just wait a little bit. Sleep a few milliseconds. And then we're going to insert a little bug into this and we'll try to understand where that bug is.
So, let me open up my editor here and try not to make too many mistakes. So, yeah, let's write this function. So, we'll do async function createUser. And this thing's going to return a string. And I'm going to just grab a UUID from web crypto. So, crypto.randomUUID. And I'm already seeing a problem here. I got to add my promise around my string. And let's log that out. So, we'll say console.log user ID is ID. And let's write to the database here. So what I'm going to use is a little utility called delay that delays a certain number of milliseconds and you can grab this thing from JSR. Delay, and that's in the standard library async. I won't talk about JSR today but do check it out, jsr.io.
So after we've written this to the database, let's just pretend that we have a little bug here. And the bug that I'm going to introduce here is that if the first letter of this UUID is a, then we're going to throw some exception. Throw new error. No, not that. Come on, Copilot. Error bug. So this is the bug that we want to debug and we're going to return that ID here. Let me just check here. We got a little squiggly. This is the Deno LSP in action here. Deno lint happening, but that's fine. createUser is not used yet. Okay, so let's wrap this up in a little API server. For this, I like to use Hono these days. And I'll just import that from npm. And in Deno, you can just import npm:hono to grab that. And let's see, let's instantiate this thing. So const... Do people know Hono? Hono is like Express but better in basically every way. So yeah, when you get slash, we are going to call our createUser function. So let's createUser and let's assign this to an ID and let's return a little JSON object here. And we'll tab our way to success here. And I'm getting a little LSP error here from the Deno LSP saying that I forgot to add an async here. And yes, everything is type checking beautifully.
Now, the last thing I need to do is just deno serve this app.fetch and we should be able to run our program. So, I'm going to run this with allow net because it is creating a server and I need to give it permission to do that. So, I'll just run that. And if I open another terminal here, we should be able to curl localhost 8000. And we indeed get our new user. If I curl this a couple of times, we should hit our bug. I guess on average, this will take about 16 times. And hopefully, if we're unlucky, we're going to be here all day. Oh. Oh, boy. Oh, okay. Hey. Okay, so yeah, we've got this exception here and let's just imagine that you're debugging this and you would see, you know, this console log before it with a little a here at the start, right? Hopefully this is visible enough for you all to see. But of course this is not what it's going to look like in a real high-traffic situation. It's going to look rather like something like this.
Let's wrk it. And you're going to get all sorts of logs happening all the time. And you're going to see random exceptions in your logs. Something like this. And you might naively look at the code and be like, hm, what happened just before that user ID? This one starts with six. That must not be the bug, right? Let's assume that this is like a very complicated bug to understand, right? That you can't just look at the code and understand it. Because this is an asynchronous function and because we're handling many, many requests at once, the logs are kind of interleaved with each other, right? And yeah, you can't necessarily associate log lines with the requests that are generating them or the exceptions that happen during that request. So, how do you solve this problem? Well, OpenTelemetry and Deno to the rescue here. What we can do is add this unstable_otel flag. And if we add also an environment variable service name is createUser. So add an environment variable and you have to add this unstable_otel flag right now because we have not stabilized this support in Deno yet. But if we run our server again and we generate some load on it, we can then go into Grafana where we can start looking at our results. So let me set service name to createUser and let's look at our logs inside of Grafana. Looks much the same as we saw in the terminal. The nice thing here though is that with this exception, we actually have a trace ID. So what Deno is doing is auto-instrumenting our program and assigning trace IDs to each request and those trace IDs are being propagated through and attached to each of the log lines. These user ID log lines also have trace IDs. So let's go start debugging our program here. You see your exception and you see a trace ID. Now we can filter the logs by that trace ID and see that there are actually only two, you know, there's the exception and one other log line associated with this request and that it does indeed start with an A. Right? So we've been able to associate these two things even though they occurred at very different time frames.
So, logs are traces. Traces are kind of dressed up logs, right? They're fancy logs. Logs are just a point in time. They are human readable. They're very easy to employ. Traces have causality to them. They help you debug things. They have timing associated with them. Let's look at this a little bit more carefully. If we click this trace button, we can see kind of the timeline here. Now this is a very simple one but let me see if I can expand this a little bit. But we can see that this createUser took 103 milliseconds and there are various span attributes associated with this. We can see that it got a 500 response and that it was a GET method and this is the URL that it hit. So yeah, traces are fancy logs that help. You might think this is magic. This is not magic. We were able to associate these logs with requests automatically without any code changes. And this is using something called async context propagation. There's been some technology changes in recent months that are allowing for this now. So this in late 2024, late last year, V8 stabilized this continuation preserved embedded data API, a C++ API that allows for fast traces in JavaScript. And this was spawned by the async context proposal and the earlier async hooks work in Node. Async context being a TC39 proposal that is at stage two right now and looks like it will be moving to stage three here at some point and into browsers, yeah, maybe next year or so.
So you have logs, you have traces, there's also metrics. And if we follow this little cartoon metaphor, metrics are, you know, maybe when you sew up your logs and stack them and count them, gives you aggregated information about what's happening in your application. I won't look at that right now. Suffice it to say that in Deno 2.2, telemetry is built in and you can run this. You can run existing applications in Deno and get this telemetry automatically because Deno also can run Node applications. This means in particular that you can take an existing Node application, run it in Deno and suddenly see a bunch of information that you couldn't see before. So out of the box, Deno is auto-instrumenting, is log correlating, attaching these trace IDs with console logs. It does one trace per HTTP request. It has spans for incoming and outgoing HTTP requests. It has request count metrics. It has response latency and it has traceparent header on outbound requests for propagating between services and we're going to keep adding to this. So when you run in Deno you will get all sorts of instrumentation for free. Of course you can add your own spans and metrics using the OpenTelemetry API on npm and these two things play well together. So I would encourage you to try this out. There's a QR code here to the documentation and yeah basically just run your app in Deno, add a couple of flags and export your OTel data to wherever you want to, Grafana or Datadog or whatever system you're using and you should be able to see interesting information about your JavaScript server.
So telemetry is also coming to Deno Deploy. Deno Deploy. Raise your hand if you know Deno Deploy. Great. Fewer people. Deno Deploy is the easiest server... Those of you who raised your hand, is it the easiest serverless system? It is. It is delightful to use. We are about to release a few more features in Deno Deploy. One of them being telemetry support and unfortunately not quite ready for open access right now. But I would encourage you to if you're interested to follow this QR code and opt into early access features and we'll be rolling this out in the coming weeks to Deno Deploy. So once you start running your application there you can start seeing all sorts of stuff and let me give a brief demo of that. So I'm going to create a new application and by the way I've got this code deployed to myjs demo. Here's my main.ts file. I'm going to deploy this application here. Should take just a second hopefully. Okay, so we've deployed our little application and we are indeed getting our user IDs and you know if I reload enough we will hit an exception eventually. You can see the logs in Deno Deploy of course, but now you can also see traces and dig into them. This is a pretty simple one, but you can imagine that you can have a pretty interesting waterfall here and see all sorts of spans and attributes of various things going on. I'll just click around here a little bit. Yeah. So, this is coming to Deno Deploy. I'm pretty excited about that.
One more thing here. Complete digression from all of this. So yes, try OpenTelemetry in Deno. Try this in Deno Deploy. Email me if you hit some problems or find it not delightful. I think you will. Okay, digression. Do you know who owns the trademark for JavaScript? Do you know that JavaScript is trademarked? Oracle owns the trademark for JavaScript. This is very surprising because Oracle has essentially nothing to do with JavaScript. We are frustrated with this situation and we have written this open letter here at javascript.tm where you can lend your support by signing it. I and the Deno company are in the process of officially petitioning the US patent office to cancel the JavaScript trademark. This is being lawyered out as we speak. It's a long and arduous process, but the more public support we have, the better for this. And I think, yeah, it's safe to say, at least within these walls, that yeah, it makes no sense that Oracle owns the trademark. There should be able to be a JavaScript conference. Currently, there cannot be a JavaScript conference. Oracle will cease and desist you, but that's really unfair and not what trademarks are for. So, please lend your support by signing this open letter. And thank you.

Cite this transcript

APA, MLA, BibTeX
APA

Dahl, R. (2025, April 15). Ryan Dahl on Deno and OpenTelemetry [Interview transcript]. Deno. CEOInterviews.AI. https://ceointerviews.ai/interview/3274159/

MLA

Ryan Dahl. "Ryan Dahl on Deno and OpenTelemetry." Deno, 15 Apr. 2025. Transcript, CEOInterviews.AI, https://ceointerviews.ai/interview/3274159/.

BibTeX
@misc{dahl2025_3274159,
  author       = {Ryan Dahl},
  title        = {Ryan Dahl on Deno and OpenTelemetry},
  howpublished = {Interview transcript, Deno. CEOInterviews.AI},
  year         = {2025},
  month        = {apr},
  url          = {https://ceointerviews.ai/interview/3274159/},
  note         = {Speaker-attributed transcript with timestamps}
}