ubgo is in early alpha: libraries and APIs may still change.

Skip to content
ubgo Alpha

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

otelkitcore · 14 direct depsADAPTERS IN CONTRIB/otelkit-grpcotelkit-grpc

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 — otelkit owns all port + /v1/ path construction.
  • One handle, one ordered Shutdown + a ready-made signal helper; a real no-op on OTEL_SDK_DISABLED.
  • Future-proof — delegates to the now-stable declarative config (otelconf) when OTEL_CONFIG_FILE is 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 ...
}

From the otelkit README.

At a glance (from the README)