
OtelX¶
A Go library for unified OpenTelemetry initialization. One function call bootstraps logging, tracing, and metrics for your Go service. View the repository.
Why I Rebuilt It¶
I had a years-old OpenTelemetry helper library that had fallen behind. The upstream opentelemetry-go project had matured significantly. Updating the old code would have been a fight against outdated patterns.
It was simpler to start fresh. Rewrite the whole thing from the ground up against the current SDK.
How It Works¶
A single Initialize() call with functional options configures your entire telemetry stack. Three signals, each independently enabled or disabled.
Logging uses zerolog with otelzerolog for automatic trace correlation. Log entries get trace and span IDs when a trace context is active. No manual context threading required.
Metrics use the OpenTelemetry Prometheus exporter on a configurable port. The library starts an HTTP server and exposes metrics at the configured path (defaults to /metrics on port 9090).
Tracing uses the OTLP gRPC exporter with sampling control. Send traces to an OpenTelemetry Collector or compatible backend. Production defaults include TLS and 10% sampling.
WithService() is mandatory. Every telemetry signal needs service name, version, and environment for proper identification. Call Shutdown() before your application exits to flush pending data.
graph LR
A[Application] --> B[Initialize]
B --> C[Logger]
B --> D[MeterProvider]
B --> E[TracerProvider]
C --> F[zerolog + otelzerolog]
D --> G[Prometheus Exporter]
E --> H[OTLP gRPC Exporter]
F --> I[Stdout/Stderr]
G --> J[Metrics Endpoint]
H --> K[OTLP Collector]
Development and production presets give you sane defaults. Development uses debug logging, pretty formatting, and insecure OTLP connections. Production uses JSON logging, TLS, and 10% trace sampling.
The First Agent-Driven Rewrite¶
This was the first project written from scratch using the claude-code-setup agent ecosystem. The agents had the old implementation as a reference spec. They could see what the library needed to do, but built it fresh against the current opentelemetry-go SDK.
The Go software engineer agent wrote the core package. Iterative code reviews by specialist agents caught real bugs. Architectural issues that human review initially missed. Context propagation errors that would have shipped to production.
The E2E test engineer validated the library's behavior. The DevOps engineer created the Docker setup and CI workflows. The documentation agent wrote the README and migration guide.
Lessons Learned
Having the old implementation as a reference made this implementation sort of like a "supervised solo". The agents didn't need a detailed spec -- they could infer requirements from the existing code while building against the current SDK. Other than being very outdated, the old implementation worked as intended; it wasn't broken. This pattern of "old code as spec" turned out to be a reliable way to drive agent-assisted rewrites.
Production Ready¶
OtelX requires Go 1.24+ and is released under the MIT License. Version 1.0.0 shipped on December 17, 2025. Emerging maturity. Check the repository for usage examples and integration instructions.