All posts

Setting Up Distributed Tracing in NestJS

Set up distributed tracing for NestJS using Bugsly. Quick installation, configuration, and verification steps included.

The Problem

When a request in your NestJS application touches multiple services, debugging latency issues becomes exponentially harder. Distributed tracing connects the dots.

Quick Start with Bugsly

Getting distributed tracing running in NestJS takes about five minutes. Here's how.

Install the SDK:

npm install @bugsly/node

Add the initialization code:

import * as Bugsly from "@bugsly/node";

Bugsly.init({
  dsn: "YOUR_BUGSLY_DSN",
  tracesSampleRate: 1.0,
});

// In app.module.ts
@Module({
  providers: [{ provide: APP_INTERCEPTOR, useClass: BugslyInterceptor }],
})
export class AppModule {}

That's it. Bugsly starts capturing events immediately. No additional configuration is required for basic distributed tracing, though you'll want to customize the setup as your needs grow.

Going Beyond the Basics

The initial setup captures unhandled errors automatically. To get more value from your NestJS integration:

  • Add breadcrumbs to trace user actions leading up to errors. This context is invaluable when debugging complex flows.
  • Set up release health to track crash-free session rates across deployments. You'll know instantly if a release introduces regressions.
  • Configure integrations with your existing tools. Bugsly connects with Slack, PagerDuty, Jira, GitHub, and more to fit into your workflow.

Why Bugsly for NestJS?

Bugsly's NestJS SDK is purpose-built to hook into the framework's internals. It captures framework-specific context, groups errors intelligently using stack trace analysis, and provides a timeline view of events. Your team spends less time reproducing bugs and more time shipping features.

Next Steps

With distributed tracing active, use Bugsly's trace explorer to find slow spans and identify bottlenecks across services. Set up performance alerts for transactions that exceed your latency budgets. Tag traces with custom attributes to filter by specific users, endpoints, or business operations.

Try Bugsly Free

AI-powered error tracking that explains your bugs. Set up in 2 minutes, free forever for small projects.

Get Started Free