otelkit
One constructor that sets up OpenTelemetry traces, metrics and logs, with presets for common backends.
go get github.com/ubgo/otelkit
- Language
- Go
- Go version
- 1.25.0
- Core deps
- 14 direct
- Latest tag
- none
- License
- Apache-2.0
- Go modules
- 3
How it fits together
Highlights from the README
- Spec-compliant — honors the standard
OTEL_*environment variables and defaults. - Vendor presets as data — switch backends in one line; the preset encodes the endpoint, auth header name/format, path quirk, and metric temporality.
- Loud, not silent — an export-error handler, a connectivity probe, a dry-run mode, and an opt-in boot self-test turn silent misconfiguration into a specific startup error.
- One knob, no footguns —
otelkitowns all port +/v1/path construction. - One handle, one ordered
Shutdown+ a ready-made signal helper; a real no-op onOTEL_SDK_DISABLED. - Future-proof — delegates to the now-stable declarative config (
otelconf) whenOTEL_CONFIG_FILEis set. - Zero application dependencies.
Code from the README
package main
import (
"context"
"log"
"github.com/ubgo/otelkit"
)
func main() {
ctx := context.Background()
tel, err := otelkit.Init(ctx,
otelkit.WithService("checkout", "1.4.2"),
otelkit.WithEnvironment("prod"),
otelkit.WithPreset(otelkit.PresetHyperDX("<ingestion-key>", "")),
)
if err != nil {
log.Fatal(err)
}
tel.SetGlobal()
defer tel.Shutdown(ctx)
// ... run your service; create spans/metrics via the OTEL globals ...
}tel, err := otelkit.Init(ctx,
otelkit.WithPreset(otelkit.PresetHoneycomb(key, "metrics", "")),
otelkit.WithSelfTest(), // send one span synchronously; error if the backend is unreachable
otelkit.WithErrorHandler(myLogger), // route export failures into your logs (default: stderr)
)import (
"github.com/ubgo/otelkit"
_ "github.com/ubgo/otelkit/contrib/otelkit-grpc" // blank import enables gRPC
)
tel, _ := otelkit.Init(ctx,
otelkit.WithPreset(otelkit.PresetCollector("localhost:4317", otelkit.TransportGRPC)),
)From the otelkit README.
At a glance (from the README)
| Module | Import |
|---|---|
| core | github.com/ubgo/otelkit |
| gRPC exporters | github.com/ubgo/otelkit/contrib/otelkit-grpc |