Skip to main content
Connect your Node.js application to BugByBug using OpenTelemetry. This guide uses OpenTelemetry’s Node.js auto-instrumentation to collect traces from supported libraries and frameworks and export them to BugByBug. The setup uses OTLP/HTTP with JSON encoding and your BugByBug project API key.

What you’ll need

Before you begin, make sure you have:
  • A Node.js application.
  • Node.js and npm installed.
  • A BugByBug account and project.
  • Your BugByBug project API key.
Instrumentation coverage depends on the libraries and versions used by your web app or software.

1. Get your BugByBug API key

  1. Sign in to your BugByBug dashboard.
  2. Create a project or open an existing one.
  3. Copy the project’s API key.
Keep your API key private. Store it in an environment variable rather than hardcoding it into your application.

2. Install OpenTelemetry packages

Install the OpenTelemetry Node.js SDK and auto-instrumentation package:
This package lets OpenTelemetry talk to your project if they are supported Node.js libraries and frameworks.

3. Configure your environment variables

Add the following variables to your application’s .env file:
Replace the placeholders:
  • YOUR_BUGBYBUG_API_KEY: Your actual BugByBug API key.
  • your-service-name: A descriptive name for your application or service.
What these variables do: Keep these values in your .env file. Never expose your project API key in frontend code.

4. Enable auto-instrumentation

OpenTelemetry must initialize before your application loads the libraries you want to instrument. You can do this by starting your Node.js application with the OpenTelemetry registration module. For CommonJS applications:
For ESM applications:
Replace app.js above with your actual application’s entry point.

Add it to your npm scripts

Instead of typing the command every time, add the script below to your package.json:
You can then start your application with:
If your project uses a different module system or build setup, check the OpenTelemetry JavaScript documentation for the correct configuration.

5. Run your application

Start your application using the configured command. OpenTelemetry will initialize before your application code and instrument supported libraries. As your application handles requests and performs supported operations, OpenTelemetry generates trace data and exports it to BugByBug. The data collected depends on the instrumentation available for your application’s dependencies and how they are configured.

6. Verify your connection

After starting your application:
  1. Send a request to an endpoint in your application.
  2. Check your application logs for OpenTelemetry export or authentication errors.
  3. Open your BugByBug project dashboard.
  4. Check whether telemetry from the configured service is appearing.
If telemetry does not appear, review the troubleshooting section below.

Troubleshooting

What’s next?

Your Node.js application is now configured to export OpenTelemetry traces to BugByBug. You may also check out our Python guide to connect your Django, Flask or FastAPI app.