Repository navigation
Skip registering Caffeine meters when statistics are not enabled - #5409
Merged
Merged
Conversation
This commit also fixes and improves GuavaCacheMetricsTest and CaffeineCacheMetricsTest. Closes micrometer-metricsgh-5408
izeye
commented
Aug 29, 2024
|
|
||
| private static final String DESCRIPTION_CACHE_GETS = "The number of times cache lookup methods have returned a cached (hit) or uncached (newly loaded or null) value (miss)."; | ||
|
|
||
| static final long UNSUPPORTED = -1L; |
Contributor
Author
There was a problem hiding this comment.
I'm not happy with this magic number to express an unsupported meter for the long primitive type but couldn't find a better way without breaking changes.
shakuzen
approved these changes
Aug 30, 2024
This was referenced Jun 3, 2026
shakuzen
pushed a commit
that referenced
this pull request
Aug 10, 2026
* Skip registering JCache meters when statistics are not enabled When a JCache cache is bound without statistics enabled, the registered meters silently report zero, which is hard to diagnose. Detect this case via CompleteConfiguration#isStatisticsEnabled() and skip registering the stats-dependent meters; log a warning explaining how to enable statistics. This mirrors what was done for Caffeine in gh-5402 and gh-5409. If the JCache provider does not expose CompleteConfiguration (the configuration is null or getConfiguration() throws IllegalArgumentException), assume statistics are enabled to avoid a false-positive warning. See gh-5066. Signed-off-by: jewoodev <jewoos15@naver.com> * Document that JCache statistics toggles are not tracked JCacheMetrics checks whether statistics are enabled at construction time. Runtime toggles via CacheManager#enableStatistics(...) are intentionally not tracked, so metrics need to be rebound if statistics are enabled later. Signed-off-by: jewoodev <jewoos15@naver.com> --------- Signed-off-by: jewoodev <jewoos15@naver.com>
shakuzen
pushed a commit
that referenced
this pull request
Aug 24, 2026
) Follow-up to gh-5402, gh-5409, and gh-7562 for HazelcastCacheMetrics. When a Hazelcast `IMap` is bound without statistics enabled, the registered meters silently report zero, which is hard to diagnose. This change detects the stats-disabled state via `MapConfig#isStatisticsEnabled()`, logs a warning explaining how to enable statistics, and skips registering every stats-dependent meter, including `cache.size` because it reads `LocalMapStats#getOwnedEntryCount()` and is meaningless once statistics are disabled. See gh-5066 * Use Hazelcast `Config` to detect statistics Avoid relying on Hazelcast internal SPI classes to inspect map configuration. Add `Config`-based overloads that use the public API while preserving the behavior of existing overloads. --------- Signed-off-by: jewoodev <jewoos15@naver.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.
This PR changes to skip registering Caffeine meters when statistics are not enabled.
This PR also fixes and improves
GuavaCacheMetricsTestandCaffeineCacheMetricsTest.Closes gh-5408