# Instrumenting Express.js with OpenTelemetry

# Prerequisites

  • Node.js v10+

# Introduction

In this tutorial we will instrument a basicopen in new window Rails app using OpenTelemetry instrumentation.

# Instrumenting Express.js app

  • Step 1. Let's start by downloading the source code:
git clone https://github.com/uptrace/uptrace-js.git
cd example/express
  • Step 2. Install the required dependencies:
yarn install
  • Step 3. Edit main.js to configure OpenTelemetry to export data to Uptrace:
const uptrace = require('@uptrace/node')

    // Set dsn or UPTRACE_DSN env var.
    dsn: '',

    serviceName: 'myservice',
    serviceVersion: '1.0.0',
  • Step 4. Edit main.js to instrument the Express app:
const { ExpressInstrumentation } = require('@opentelemetry/instrumentation-express')
const { HttpInstrumentation } = require('@opentelemetry/instrumentation-http')


    instrumentations: [new HttpInstrumentation(), new ExpressInstrumentation()],
UPTRACE_DSN="https://<token>@api.uptrace.dev/<project_id>" node main.js

The full code is available at GitHubopen in new window.

# What is next?

By now, you should have a Django app with instrumented views. Next, instrumentopen in new window more operations (for example, database queries) or learn about OpenTelemetry API to create your own instrumentations.