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
- Sign in to your BugByBug dashboard.
- Create a project or open an existing one.
- Copy the project’s API key.
2. Install OpenTelemetry packages
Install the OpenTelemetry Node.js SDK and auto-instrumentation package:3. Configure your environment variables
Add the following variables to your application’s.env file:
YOUR_BUGBYBUG_API_KEY: Your actual BugByBug API key.your-service-name: A descriptive name for your application or service.
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: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 yourpackage.json:
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:- Send a request to an endpoint in your application.
- Check your application logs for OpenTelemetry export or authentication errors.
- Open your BugByBug project dashboard.
- Check whether telemetry from the configured service is appearing.