Files
zooqueenandHanzo Dev d3ba598ff7 otel: move the OpenTelemetry bridge out of the root package
exporter_otelzap.go was the only file in the root package importing
go.opentelemetry.io, and it made the root package link 34 OpenTelemetry SDK
packages. Nothing else in the root package wants them: the registry, the text
encoder and the ZAP exporter are pure luxfi/zap.

That cost was not paid by the root package alone. github.com/zap-proto/zip
imports this module for the registry, EncodeText and NewZAPExporter, and passes
on whatever the root package links to each of the 125 programs built on it. The
ruling is native ZAP only, so nothing a plugin inherits may carry the
OpenTelemetry SDK.

The adapter is now package github.com/luxfi/metric/otel, and the two symbols it
exports lose the prefixes that only existed to disambiguate them inside the root
package:

  metric.NewOTelZAPExporter(cfg)  ->  otel.New(cfg)
  *metric.OTelZAPExporter         ->  *otel.Exporter

The configuration type stays metric.ZAPExporterConfig, since it belongs to the
ZAP exporter this adapter builds on. No alias is left behind in the root package
— one that re-imported the moved package would link the SDK again and undo the
change. Callers of the adapter add the otel import and drop the prefixes.

Proof, rather than a grep for import lines:

  go list -deps . | grep -c go.opentelemetry.io    ->  0
  go list -deps ./otel | grep -c go.opentelemetry.io  ->  34

0 holds under the default tags, -tags metrics and -tags metrics_noop alike. A
program importing zip v1.25.0 against this module resolves 0 as well, measured
with a replace directive.

The conversion had no tests, so the move now pins it: counter and gauge shapes,
the drop of an aggregation these shapes cannot carry, and the arithmetic that
matters — OpenTelemetry reports a count per bucket where Prometheus reports a
running total.

The metrics_noop defaults are untouched; recording stays the default and the
no-op stays opt-in. Build, vet and test -race are green under all three tag
sets.

Co-authored-by: Hanzo Dev <[email protected]>
2026-08-04 22:03:23 -07:00
..