Migration: pkg/telemetry/{otelcore,logs,metrics,tracing} → go/observability¶
The OpenTelemetry setup group has been extracted out of go-tool-base into the
standalone module gitlab.com/phpboyscout/go/observability (v0.1.0). It carries
the OTel SDK but is otherwise framework-free, so any service can adopt GTB's OTLP
wiring without pulling in the framework.
What changed¶
- The subpackages
gitlab.com/phpboyscout/go-tool-base/pkg/telemetry/{otelcore,logs,metrics,tracing}no longer exist. They now live atgitlab.com/phpboyscout/go/observability/{otelcore,logs,metrics,tracing}. - The core API is unchanged. Package names stay the same;
otelcore.Settings,otelcore.Resource,otelcore.ParseEndpoint,otelcore.ResolveSettings,otelcore.SettingsSource, and thetracing/metrics/logsNewProviderfactories (withWithSampling/WithInterval) are identical. - The GTB config-key adapter moved, not deleted.
otelcore.Resolveandotelcore.ObserveSettingsFromConfigread GTB config (config.Containable), so they cannot live in the framework-free module. They relocated intopkg/telemetry(packagetelemetry): the shared-plus-per-signal resolution is now an internal helper, andtelemetry.ObserveSettingsFromConfigis the public config-observation seam.
How to migrate¶
If you consume the core packages directly (otelcore, tracing, metrics,
logs), repoint the import paths — the symbols are unchanged:
grep -rlE 'go-tool-base/pkg/telemetry/(otelcore|logs|metrics|tracing)' --include='*.go' . \
| xargs sed -i -E 's#go-tool-base/pkg/telemetry/(otelcore|logs|metrics|tracing)#go/observability/\1#g'
go get gitlab.com/phpboyscout/go/[email protected]
go mod tidy
If you called otelcore.Resolve or otelcore.ObserveSettingsFromConfig — the
config-key adapter — use pkg/telemetry instead: telemetry.ObserveSettingsFromConfig
(and, for a one-shot resolve, source your typed otelcore.Settings from your own
config and call otelcore.ResolveSettings directly).
go mod tidy and genproto¶
The OTLP exporters pull a transitive gRPC graph that can surface the
google.golang.org/genproto monolithic-vs-split ambiguous import. If tidy fails,
pin the split modules (as go-tool-base and the module do):
google.golang.org/genproto/googleapis/api // indirect
google.golang.org/genproto/googleapis/rpc // indirect
google.golang.org/grpc
Notes¶
- go-tool-base itself now consumes
go/observability:pkg/telemetry'sSetupFromProps/Setupbuilds the module's providers from GTB config, and the product-analytics half ofpkg/telemetryis unchanged. - Keep the module's OTel versions in lockstep with go-tool-base's (see the module's compatibility note) so a service and the module share one OTel build graph.
- Full documentation and the config model live at observability.go.phpboyscout.uk; the API reference is on pkg.go.dev.