Skip to main content

Go service traces with OpenTelemetry, no Jaeger to run

Use the OTLP/HTTP exporter in your Go service and set OTEL_EXPORTER_OTLP_ENDPOINT=http://127.0.0.1:8000. Buggregator then shows each trace as a waterfall of spans, with the service name, and logs that link to their trace. One Buggregator container is all you run.

Steps

1. Start Buggregator

OpenTelemetry needs Buggregator 2.12.0 or newer. It takes OTLP over HTTP on the main port 8000, not gRPC.

bash
docker run --pull always \
  -p 127.0.0.1:8000:8000 \
  ghcr.io/buggregator/server:latest

2. Set the OTel variables

The exporter adds /v1/traces to the endpoint by itself. In Docker Compose, use the Buggregator service name instead of 127.0.0.1.

dotenv
OTEL_SERVICE_NAME=checkout
OTEL_EXPORTER_OTLP_ENDPOINT=http://127.0.0.1:8000
OTEL_EXPORTER_OTLP_INSECURE=true

3. Export traces over HTTP

Use otlptracehttp, the HTTP exporter. It reads the variables above.

go
import (
	"context"
	"log"

	"go.opentelemetry.io/otel"
	"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp"
	sdktrace "go.opentelemetry.io/otel/sdk/trace"
)

func main() {
	ctx := context.Background()

	exp, err := otlptracehttp.New(ctx)
	if err != nil {
		log.Fatal(err)
	}
	tp := sdktrace.NewTracerProvider(sdktrace.WithBatcher(exp))
	defer tp.Shutdown(ctx)
	otel.SetTracerProvider(tp)

	ctx, span := otel.Tracer("checkout").Start(ctx, "POST /checkout")
	// your code
	span.End()
}

4. Send logs too, if you want them

The logs exporter otlploghttp reads the same endpoint and adds /v1/logs. Pass its provider to the otelslog bridge and log with slog. The OpenTelemetry project marks the Go logs exporter as experimental.

go
import (
	"go.opentelemetry.io/contrib/bridges/otelslog"
	"go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp"
	sdklog "go.opentelemetry.io/otel/sdk/log"
)

logExp, err := otlploghttp.New(ctx)
if err != nil {
	log.Fatal(err)
}
lp := sdklog.NewLoggerProvider(sdklog.WithProcessor(sdklog.NewBatchProcessor(logExp)))
defer lp.Shutdown(ctx)

logger := otelslog.NewLogger("checkout", otelslog.WithLoggerProvider(lp))
logger.InfoContext(ctx, "order paid")

5. Open the trace

Open the Sentry page at http://127.0.0.1:8000 and pick Traces. The trace is marked OTel, with the services it went through. Open it to see its spans as a waterfall, with a Service column. Logs are on the Logs tab.

Why it works

Buggregator answers the standard OTLP paths /v1/traces and /v1/logs on port 8000, in protobuf or JSON. service.name becomes the service in the UI, and a span with status ERROR is marked as an error. The data sits next to your Sentry errors, dumps and emails.

Checked on with Buggregator v2.13.0

Setup in 60 seconds

No registration. No account. Start it and point your app at it.

1

Start Buggregator

One file, installed with one command. The web UI opens on port 8000. Prefer containers? Use the Docker tab.

$ curl -fsSL https://raw.githubusercontent.com/buggregator/server/master/scripts/install.sh | sh
$ HTTP_ADDR=127.0.0.1:8000 \
  SMTP_ADDR=127.0.0.1:1025 \
  VAR_DUMPER_ADDR=127.0.0.1:9912 \
  MONOLOG_ADDR=127.0.0.1:9913 \
  PROXY_ADDR=127.0.0.1:8080 \
  ~/.local/bin/buggregator

The script picks the file for your CPU: Intel/AMD or ARM.

One file for Linux, macOS and Windows, about 40 MB. Nothing else to install.

This run line keeps it on this computer. Without the *_ADDR settings it listens on all network interfaces

Rather not run a script? Download the file yourself

Runs on Windows, macOS and Linux, on Intel/AMD and ARM.

Prefer not to do it yourself? Your AI agent can set Buggregator up for you