Monitor Express.js with OpenTelemetry
Express is a Node.js web application framework that provides various features for building web and mobile applications using JavaScript programming language.
In this article you will learn how to monitor and optimize Express.js performance using OpenTelemetry observability framework.
What is OpenTelemetry?
OpenTelemetry is an open-source observability framework for distributed tracing (including logs and errors) and OpenTelemetry metrics.
Otel allows developers to collect and export telemetry data in a vendor agnostic way. With OpenTelemetry, you can instrument your application once and then add or change vendors without changing the instrumentation, for example, here is a list popular DataDog alternatives that support OpenTelemetry.
OpenTelemetry is available for most programming languages and provides interoperability across different languages and environments.
Express.js instrumentation
To instrument an Express.js app, you need to install OpenTelementry JS distro for Uptrace which will automatically install all available instrumentations:
# Using npm
npm install @uptrace/node
# Using yarn
yarn add @uptrace/node
Usage
After installing OpenTelemetry, you need to configure it like this:
const uptrace = require('@uptrace/node')
uptrace
.configureOpentelemetry({
// Set dsn or UPTRACE_DSN env var.
dsn: '',
serviceName: 'myservice',
serviceVersion: '1.0.0',
})
.start()
.then(main)
function main() {
// start the app here
}
See OpenTelemetry Express.js example for details.
What is Uptrace?
Uptrace is an open source APM for OpenTelemetry that helps developers pinpoint failures and find performance bottlenecks. Uptrace can process billions of spans on a single server and allows to monitor your software at 10x lower cost.
You can get started with Uptrace by downloading a DEB/RPM package or a pre-compiled Go binary.
What's next?
Next, instrument more operations, for example, database queries and network calls. You can also learn about OpenTelemetry JS API to create your own instrumentations.