feat(storage)!: remove CacheMeterProvider; use otelcache.RegisterCache#94
Merged
Merged
Conversation
BREAKING CHANGE: storage.CacheMeterProvider is removed. Wire OpenTelemetry
metrics via the new otelcache.RegisterCache helper instead, which mirrors
the file.Cache pattern and keeps the storage package free of OTel imports.
Before:
cache := storage.NewCache(storage.CacheMeterProvider(provider))
After:
cache := storage.NewCache()
reg, _ := otelcache.RegisterCache(provider, cache)
defer reg.Unregister()
RegisterCache reports all three sub-caches (objects, infos, pages) under
a single callback. The callback snapshots cache.Stat() once per
collection so the three kinds always reflect a coherent view.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #93. Once that merges, rebase this onto
main.Summary
storage.CacheMeterProvideroption, themetricsRegistrationfield onCache, and the OTel metric import fromstorage/cache.go. Thestoragepackage no longer depends ongo.opentelemetry.io/otel/metric.storage/cache_metrics.go(148 lines) — replaced by a single helper inotelcache.otelcache.RegisterCache(provider, *storage.Cache, attrs...)that wires all three sub-caches (objects/infos/pages) under one callback. The callback snapshotscache.Stat()once per collection so the three kinds always report a coherent view.otelcache.Registerto share instrument creation withRegisterCachevia internalnewInstruments/instruments.observehelpers.Why
PR #93 introduced
otelcacheto decouplestorage/file.Cachefrom OTel. This finishes the same decoupling for the in-memorystorage.Cache.Breaking change
storage.CacheMeterProvideris removed.Metric names, units, descriptions, and the
storage.cache.kindattribute are unchanged, so existing dashboards keep working. Thestorage.cache.idattribute that the old option auto-derived from the cache pointer must now be supplied by the caller (or omitted).Test plan
go test ./storage/...go vet ./...storageno longer imports otel/metric:go list -f '{{ join .Imports "\n" }}' ./storage | grep otel/metricreturns empty.cache_metrics_test.gotostorage/otelcache/cache_test.go— same 18 (kind, metric) combinations verified.🤖 Generated with Claude Code