From the course: Mastering Observability with OpenTelemetry

Unlock the full course today

Join today to access over 24,400 courses taught by industry experts.

Instrumenting Node.js for tracing

Instrumenting Node.js for tracing

- So let's now add the instrumentation to the node frontend. For that I'm opening the node-frontend folder, and then I'm opening the app.js file because that's the main file of the application. And right at the very top, and this is important to know that in most cases the instrumentation should really go at the very first of the application file. So I'm doing this here and I write "require," and I'm including the _opentelemetry js library. We can omit the index js because that's implied. And if you remember, this exports a function that I now have to call with the service name and the service version. So where can I get this from? Well, if you look into package.json, you see that there is a name and the version property, and we can use just that. To do this, I will now add one more line on top of this require, and I will write "const pkg = require," and it's on the same level package.json. Now, this link is complaining, you see this, add this red wavy line because the input order is…

Contents