All posts

Distributed Tracing for Go: A Setup Guide

Complete guide to integrating Bugsly distributed tracing in your Go project. Get started in minutes with this tutorial.

That slow API call in your Go app — is it the database? A downstream service? Network latency? Distributed tracing tells you definitively.

Prerequisites

Before you begin, make sure you have a Bugsly account and a Go project ready to instrument. You'll need your project DSN from the Bugsly dashboard — find it under Settings > Projects > Client Keys.

Step-by-Step Integration

  1. Add the Bugsly package to your Go project:
go get github.com/bugsly/bugsly-go
  1. Configure the SDK at your application's entry point:
import "github.com/bugsly/bugsly-go"

func main() {
    err := bugsly.Init(bugsly.ClientOptions{
        Dsn:              "YOUR_BUGSLY_DSN",
        TracesSampleRate: 1.0,
    })
    if err != nil {
        log.Fatalf("bugsly init failed: %s", err)
    }
    defer bugsly.Flush(2 * time.Second)
}
  1. Deploy your changes and verify events appear in the Bugsly dashboard.

Fine-Tuning Your Setup

After the basic integration works, consider these adjustments for Go:

  • Sampling rate: Adjust tracesSampleRate based on your traffic volume. High-traffic apps should sample at 0.1–0.3 to control costs.
  • Environment tags: Tag events with production, staging, or development to filter noise.
  • Release tracking: Pass your version string so Bugsly can track regressions across deployments.
  • Custom context: Attach user IDs, request metadata, or business-specific data to events for richer debugging.

Bugsly's distributed tracing for Go runs with minimal overhead. The SDK is designed to be lightweight, batching events and sending them asynchronously so your application performance stays unaffected.

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