You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by "mlbiscoc (via GitHub)" <gi...@apache.org> on 2025/09/19 19:38:03 UTC
[PR] SOLR-17806: Migrate CaffeineCache to OTEL [solr]
mlbiscoc opened a new pull request, #3671:
URL: https://github.com/apache/solr/pull/3671
https://issues.apache.org/jira/browse/SOLR-17806
Migrate CaffeineCache metrics to OTEL. This also cleaned up some things like `core attributes` and some some of the observable instruments for batchCallbacks so we have gauge and counters.
```
# HELP solr_cache_cumulative_ops Number of cumulative cache operations (hits, lookups, inserts and evictions)
# TYPE solr_cache_cumulative_ops gauge
solr_cache_cumulative_ops{cache_name="documentCache",category="CACHE",collection="demo",core="demo_shard1_replica_n1",ops="evictions",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 0.0
solr_cache_cumulative_ops{cache_name="documentCache",category="CACHE",collection="demo",core="demo_shard1_replica_n1",ops="hits",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 0.0
solr_cache_cumulative_ops{cache_name="documentCache",category="CACHE",collection="demo",core="demo_shard1_replica_n1",ops="inserts",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 0.0
solr_cache_cumulative_ops{cache_name="documentCache",category="CACHE",collection="demo",core="demo_shard1_replica_n1",ops="lookups",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 0.0
solr_cache_cumulative_ops{cache_name="fieldValueCache",category="CACHE",collection="demo",core="demo_shard1_replica_n1",ops="evictions",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 0.0
solr_cache_cumulative_ops{cache_name="fieldValueCache",category="CACHE",collection="demo",core="demo_shard1_replica_n1",ops="hits",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 0.0
solr_cache_cumulative_ops{cache_name="fieldValueCache",category="CACHE",collection="demo",core="demo_shard1_replica_n1",ops="inserts",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 0.0
solr_cache_cumulative_ops{cache_name="fieldValueCache",category="CACHE",collection="demo",core="demo_shard1_replica_n1",ops="lookups",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 0.0
solr_cache_cumulative_ops{cache_name="filterCache",category="CACHE",collection="demo",core="demo_shard1_replica_n1",ops="evictions",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 0.0
solr_cache_cumulative_ops{cache_name="filterCache",category="CACHE",collection="demo",core="demo_shard1_replica_n1",ops="hits",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 0.0
solr_cache_cumulative_ops{cache_name="filterCache",category="CACHE",collection="demo",core="demo_shard1_replica_n1",ops="inserts",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 0.0
solr_cache_cumulative_ops{cache_name="filterCache",category="CACHE",collection="demo",core="demo_shard1_replica_n1",ops="lookups",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 0.0
solr_cache_cumulative_ops{cache_name="perSegFilter",category="CACHE",collection="demo",core="demo_shard1_replica_n1",ops="evictions",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 0.0
solr_cache_cumulative_ops{cache_name="perSegFilter",category="CACHE",collection="demo",core="demo_shard1_replica_n1",ops="hits",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 0.0
solr_cache_cumulative_ops{cache_name="perSegFilter",category="CACHE",collection="demo",core="demo_shard1_replica_n1",ops="inserts",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 0.0
solr_cache_cumulative_ops{cache_name="perSegFilter",category="CACHE",collection="demo",core="demo_shard1_replica_n1",ops="lookups",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 0.0
solr_cache_cumulative_ops{cache_name="queryResultCache",category="CACHE",collection="demo",core="demo_shard1_replica_n1",ops="evictions",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 0.0
solr_cache_cumulative_ops{cache_name="queryResultCache",category="CACHE",collection="demo",core="demo_shard1_replica_n1",ops="hits",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 0.0
solr_cache_cumulative_ops{cache_name="queryResultCache",category="CACHE",collection="demo",core="demo_shard1_replica_n1",ops="inserts",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 0.0
solr_cache_cumulative_ops{cache_name="queryResultCache",category="CACHE",collection="demo",core="demo_shard1_replica_n1",ops="lookups",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 0.0
# HELP solr_searcher_cache_hit_ratio Cache hit ratio
# TYPE solr_searcher_cache_hit_ratio gauge
solr_searcher_cache_hit_ratio{cache_name="documentCache",category="CACHE",collection="demo",core="demo_shard1_replica_n1",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 0.0
solr_searcher_cache_hit_ratio{cache_name="fieldValueCache",category="CACHE",collection="demo",core="demo_shard1_replica_n1",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 0.0
solr_searcher_cache_hit_ratio{cache_name="filterCache",category="CACHE",collection="demo",core="demo_shard1_replica_n1",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 0.0
solr_searcher_cache_hit_ratio{cache_name="perSegFilter",category="CACHE",collection="demo",core="demo_shard1_replica_n1",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 0.0
solr_searcher_cache_hit_ratio{cache_name="queryResultCache",category="CACHE",collection="demo",core="demo_shard1_replica_n1",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 0.0
# HELP solr_searcher_cache_ops_total Number of cache operations (hits, lookups, inserts and evictions)
# TYPE solr_searcher_cache_ops_total counter
solr_searcher_cache_ops_total{cache_name="documentCache",category="CACHE",collection="demo",core="demo_shard1_replica_n1",ops="evictions",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 0.0
solr_searcher_cache_ops_total{cache_name="documentCache",category="CACHE",collection="demo",core="demo_shard1_replica_n1",ops="hits",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 0.0
solr_searcher_cache_ops_total{cache_name="documentCache",category="CACHE",collection="demo",core="demo_shard1_replica_n1",ops="inserts",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 0.0
solr_searcher_cache_ops_total{cache_name="documentCache",category="CACHE",collection="demo",core="demo_shard1_replica_n1",ops="lookups",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 0.0
solr_searcher_cache_ops_total{cache_name="fieldValueCache",category="CACHE",collection="demo",core="demo_shard1_replica_n1",ops="evictions",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 0.0
solr_searcher_cache_ops_total{cache_name="fieldValueCache",category="CACHE",collection="demo",core="demo_shard1_replica_n1",ops="hits",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 0.0
solr_searcher_cache_ops_total{cache_name="fieldValueCache",category="CACHE",collection="demo",core="demo_shard1_replica_n1",ops="inserts",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 0.0
solr_searcher_cache_ops_total{cache_name="fieldValueCache",category="CACHE",collection="demo",core="demo_shard1_replica_n1",ops="lookups",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 0.0
solr_searcher_cache_ops_total{cache_name="filterCache",category="CACHE",collection="demo",core="demo_shard1_replica_n1",ops="evictions",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 0.0
solr_searcher_cache_ops_total{cache_name="filterCache",category="CACHE",collection="demo",core="demo_shard1_replica_n1",ops="hits",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 0.0
solr_searcher_cache_ops_total{cache_name="filterCache",category="CACHE",collection="demo",core="demo_shard1_replica_n1",ops="inserts",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 0.0
solr_searcher_cache_ops_total{cache_name="filterCache",category="CACHE",collection="demo",core="demo_shard1_replica_n1",ops="lookups",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 0.0
solr_searcher_cache_ops_total{cache_name="perSegFilter",category="CACHE",collection="demo",core="demo_shard1_replica_n1",ops="evictions",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 0.0
solr_searcher_cache_ops_total{cache_name="perSegFilter",category="CACHE",collection="demo",core="demo_shard1_replica_n1",ops="hits",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 0.0
solr_searcher_cache_ops_total{cache_name="perSegFilter",category="CACHE",collection="demo",core="demo_shard1_replica_n1",ops="inserts",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 0.0
solr_searcher_cache_ops_total{cache_name="perSegFilter",category="CACHE",collection="demo",core="demo_shard1_replica_n1",ops="lookups",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 0.0
solr_searcher_cache_ops_total{cache_name="queryResultCache",category="CACHE",collection="demo",core="demo_shard1_replica_n1",ops="evictions",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 0.0
solr_searcher_cache_ops_total{cache_name="queryResultCache",category="CACHE",collection="demo",core="demo_shard1_replica_n1",ops="hits",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 0.0
solr_searcher_cache_ops_total{cache_name="queryResultCache",category="CACHE",collection="demo",core="demo_shard1_replica_n1",ops="inserts",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 0.0
solr_searcher_cache_ops_total{cache_name="queryResultCache",category="CACHE",collection="demo",core="demo_shard1_replica_n1",ops="lookups",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 0.0
# HELP solr_searcher_cache_ram_used_bytes RAM bytes used by cache
# TYPE solr_searcher_cache_ram_used_bytes gauge
solr_searcher_cache_ram_used_bytes{cache_name="documentCache",category="CACHE",collection="demo",core="demo_shard1_replica_n1",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 440.0
solr_searcher_cache_ram_used_bytes{cache_name="fieldValueCache",category="CACHE",collection="demo",core="demo_shard1_replica_n1",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 448.0
solr_searcher_cache_ram_used_bytes{cache_name="filterCache",category="CACHE",collection="demo",core="demo_shard1_replica_n1",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 440.0
solr_searcher_cache_ram_used_bytes{cache_name="perSegFilter",category="CACHE",collection="demo",core="demo_shard1_replica_n1",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 592.0
solr_searcher_cache_ram_used_bytes{cache_name="queryResultCache",category="CACHE",collection="demo",core="demo_shard1_replica_n1",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 440.0
# HELP solr_searcher_cache_size Current number cache entries
# TYPE solr_searcher_cache_size gauge
solr_searcher_cache_size{cache_name="documentCache",category="CACHE",collection="demo",core="demo_shard1_replica_n1",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 0.0
solr_searcher_cache_size{cache_name="fieldValueCache",category="CACHE",collection="demo",core="demo_shard1_replica_n1",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 0.0
solr_searcher_cache_size{cache_name="filterCache",category="CACHE",collection="demo",core="demo_shard1_replica_n1",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 0.0
solr_searcher_cache_size{cache_name="perSegFilter",category="CACHE",collection="demo",core="demo_shard1_replica_n1",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 0.0
solr_searcher_cache_size{cache_name="queryResultCache",category="CACHE",collection="demo",core="demo_shard1_replica_n1",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 0.0
# HELP solr_searcher_cache_warmup_time_milliseconds Cache warmup time
# TYPE solr_searcher_cache_warmup_time_milliseconds gauge
solr_searcher_cache_warmup_time_milliseconds{cache_name="documentCache",category="CACHE",collection="demo",core="demo_shard1_replica_n1",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 0.0
solr_searcher_cache_warmup_time_milliseconds{cache_name="fieldValueCache",category="CACHE",collection="demo",core="demo_shard1_replica_n1",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 0.0
solr_searcher_cache_warmup_time_milliseconds{cache_name="filterCache",category="CACHE",collection="demo",core="demo_shard1_replica_n1",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 0.0
solr_searcher_cache_warmup_time_milliseconds{cache_name="perSegFilter",category="CACHE",collection="demo",core="demo_shard1_replica_n1",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 0.0
solr_searcher_cache_warmup_time_milliseconds{cache_name="queryResultCache",category="CACHE",collection="demo",core="demo_shard1_replica_n1",otel_scope_name="org.apache.solr",replica="replica_n1",shard="shard1"} 0.0
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-17806: Migrate CaffeineCache to OTEL [solr]
Posted by "mlbiscoc (via GitHub)" <gi...@apache.org>.
mlbiscoc commented on PR #3671:
URL: https://github.com/apache/solr/pull/3671#issuecomment-3325281114
My take is keep them. I think it's useful to have a few of the hit/misses on the current cache and the user should probably know its not one big long lived cache, but resets between searchers even though it is an internal detail. I guess one example I can think of using it is having a single dashboard with both searcher metrics and cache hit/miss rates. Could be useful to see your hit rates and misses between searcher creations and registers. But also from a test perspective that internal detail is important. There were tests checking that queries hit the same caches or reset/reloaded one.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-17806: Migrate CaffeineCache to OTEL [solr]
Posted by "mlbiscoc (via GitHub)" <gi...@apache.org>.
mlbiscoc commented on code in PR #3671:
URL: https://github.com/apache/solr/pull/3671#discussion_r2364339895
##########
solr/core/src/java/org/apache/solr/core/SolrCore.java:
##########
@@ -555,6 +557,25 @@ public void setName(String v) {
assert this.name != null;
assert coreDescriptor.getCloudDescriptor() == null : "Cores are not renamed in SolrCloud";
this.name = Objects.requireNonNull(v);
+ initCoreAttributes();
+ }
+
+ public Attributes getCoreAttributes() {
+ return coreAttributes;
+ }
+
+ public void initCoreAttributes() {
+ this.coreAttributes =
+ (coreContainer.isZooKeeperAware())
+ ? Attributes.builder()
+ .put(COLLECTION_ATTR, coreDescriptor.getCollectionName())
+ .put(CORE_ATTR, getName())
+ .put(SHARD_ATTR, coreDescriptor.getCloudDescriptor().getShardId())
+ .put(
+ REPLICA_ATTR,
+ Utils.parseMetricsReplicaName(coreDescriptor.getCollectionName(), getName()))
+ .build()
+ : Attributes.builder().put(CORE_ATTR, getName()).build();
Review Comment:
I noticed that I set core attributes quite a bit so I made I initialized it as its own member and a getter method. Make it easier to add or remove core attributes in the future as well.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-17806: Migrate CaffeineCache to OTEL [solr]
Posted by "mlbiscoc (via GitHub)" <gi...@apache.org>.
mlbiscoc commented on PR #3671:
URL: https://github.com/apache/solr/pull/3671#issuecomment-3329967007
Thats fair. I moved the cumulative metric to just normal `solr_cache_lookups_total` and removed the metric between caches. Playing conservative is probably better as you said. It would be easier to re-add if someone really wanted it rather than to take away going forward.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-17806: Migrate CaffeineCache to OTEL [solr]
Posted by "mlbiscoc (via GitHub)" <gi...@apache.org>.
mlbiscoc commented on code in PR #3671:
URL: https://github.com/apache/solr/pull/3671#discussion_r2369757819
##########
solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java:
##########
@@ -603,9 +604,10 @@ public void register() {
this.solrMetricsContext = core.getSolrMetricsContext().getChildContext(this);
for (SolrCache<?, ?> cache : cacheList) {
cache.initializeMetrics(
- // TODO SOLR-17458: Add Otel
solrMetricsContext,
- Attributes.empty(),
+ core.getCoreAttributes().toBuilder()
+ .put(AttributeKey.stringKey("cache_name"), cache.name())
Review Comment:
Just made it name then.
##########
solr/core/src/java/org/apache/solr/core/SolrCore.java:
##########
@@ -555,6 +557,25 @@ public void setName(String v) {
assert this.name != null;
assert coreDescriptor.getCloudDescriptor() == null : "Cores are not renamed in SolrCloud";
this.name = Objects.requireNonNull(v);
+ initCoreAttributes();
+ }
+
+ public Attributes getCoreAttributes() {
+ return coreAttributes;
+ }
+
+ public void initCoreAttributes() {
+ this.coreAttributes =
+ (coreContainer.isZooKeeperAware())
+ ? Attributes.builder()
+ .put(COLLECTION_ATTR, coreDescriptor.getCollectionName())
+ .put(CORE_ATTR, getName())
Review Comment:
I rebuilt it in the `setName` method right above this. I found a test that failed so I caught the rename and test passes now
##########
solr/core/src/java/org/apache/solr/search/CaffeineCache.java:
##########
@@ -471,47 +477,90 @@ public SolrMetricsContext getSolrMetricsContext() {
@Override
public String toString() {
- return name() + (cacheMap != null ? cacheMap.getValue().toString() : "");
+ return name();
}
- // TODO SOLR-17458: Migrate to Otel
@Override
public void initializeMetrics(
SolrMetricsContext parentContext, Attributes attributes, String scope) {
+ Attributes cacheAttributes =
+ attributes.toBuilder().put(CATEGORY_ATTR, getCategory().toString()).build();
solrMetricsContext = parentContext.getChildContext(this);
- cacheMap =
- new MetricsMap(
- map -> {
+
+ ObservableLongMeasurement cacheOperation =
+ solrMetricsContext.longCounterMeasurement(
+ "solr_searcher_cache_ops",
+ "Number of cache operations (hits, lookups, inserts and evictions)");
+
+ ObservableLongMeasurement hitRatioMetric =
+ solrMetricsContext.longGaugeMeasurement("solr_searcher_cache_hit_ratio", "Cache hit ratio");
+
+ ObservableLongMeasurement sizeMetric =
+ solrMetricsContext.longGaugeMeasurement(
+ "solr_searcher_cache_size", "Current number cache entries");
+
+ ObservableLongMeasurement ramBytesUsedMetric =
+ solrMetricsContext.longGaugeMeasurement(
+ "solr_searcher_cache_ram_used", "RAM bytes used by cache", OtelUnit.BYTES);
+
+ ObservableLongMeasurement warmupTimeMetric =
+ solrMetricsContext.longGaugeMeasurement(
+ "solr_searcher_cache_warmup_time", "Cache warmup time", OtelUnit.MILLISECONDS);
+
+ ObservableLongMeasurement cumulativeCacheOperation =
+ solrMetricsContext.longGaugeMeasurement(
+ "solr_cache_cumulative_ops",
+ "Number of cumulative cache operations (hits, lookups, inserts and evictions)");
+
+ this.toClose =
+ solrMetricsContext.batchCallback(
+ () -> {
if (cache != null) {
CacheStats stats = cache.stats();
long hitCount = stats.hitCount() + hits.sum();
long insertCount = inserts.sum();
long lookupCount = stats.requestCount() + lookups.sum();
- map.put(LOOKUPS_PARAM, lookupCount);
- map.put(HITS_PARAM, hitCount);
- map.put(HIT_RATIO_PARAM, hitRate(hitCount, lookupCount));
- map.put(INSERTS_PARAM, insertCount);
- map.put(EVICTIONS_PARAM, stats.evictionCount());
- map.put(SIZE_PARAM, cache.asMap().size());
- map.put("warmupTime", warmupTime);
- map.put(RAM_BYTES_USED_PARAM, ramBytesUsed());
- map.put(MAX_RAM_MB_PARAM, getMaxRamMB());
+ cacheOperation.record(
+ hitCount, cacheAttributes.toBuilder().put(OPERATION_ATTR, "hits").build());
Review Comment:
Ok so I split into 2 metrics. `solr_cache_lookups` and `solr_cache_ops`. `solr_cache_lookups` will have a `result` attirbute of `hit/miss` and if missing `result` is just total lookups. WDYT?
##########
solr/core/src/test/org/apache/solr/core/TestSolrConfigHandler.java:
##########
@@ -1045,20 +1046,19 @@ public void testSetPropertyEnableAndDisableCache() throws Exception {
String payload = "{'set-property' : { 'query.documentCache.enabled': true} }";
runConfigCommand(restTestHarness, "/config", payload);
restTestHarness.setServerProvider(() -> getBaseUrl());
- MapWriter confMap = getRespMap("/admin/metrics", restTestHarness);
- assertNotNull(
- confMap._get(
- asList("metrics", "solr.core.collection1", "CACHE.searcher.documentCache"), null));
+
+ String prometheusMetrics = restTestHarness.query("/admin/metrics?wt=prometheus");
+ assertTrue(prometheusMetrics.contains("cache_name=\"documentCache\""));
// Disabling Cache
payload = "{ 'set-property' : { 'query.documentCache.enabled': false } }";
restTestHarness.setServerProvider(oldProvider);
+
runConfigCommand(restTestHarness, "/config", payload);
restTestHarness.setServerProvider(() -> getBaseUrl());
- confMap = getRespMap("/admin/metrics", restTestHarness);
- assertNull(
- confMap._get(
- asList("metrics", "solr.core.collection1", "CACHE.searcher.documentCache"), null));
+
+ prometheusMetrics = restTestHarness.query("/admin/metrics?wt=prometheus");
Review Comment:
It will always be prometheus but right now this branch does both dropwizard and prometheus because the number of tests failing while doing incremental migration made it difficult to track changes. Once I remove Dropwizard, going to default it to prometheus and remove all the `wt=prometheus` parameters. I placed NOCOMMITS around other tests to remember.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-17806: Migrate CaffeineCache to OTEL [solr]
Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on code in PR #3671:
URL: https://github.com/apache/solr/pull/3671#discussion_r2376876197
##########
solr/core/src/java/org/apache/solr/core/SolrCore.java:
##########
@@ -556,6 +557,25 @@ public void setName(String v) {
assert this.name != null;
assert coreDescriptor.getCloudDescriptor() == null : "Cores are not renamed in SolrCloud";
this.name = Objects.requireNonNull(v);
+ initCoreAttributes();
+ }
+
+ public Attributes getCoreAttributes() {
+ return coreAttributes;
+ }
+
+ public void initCoreAttributes() {
Review Comment:
protected or private but not public, right?
##########
solr/core/src/java/org/apache/solr/search/CaffeineCache.java:
##########
@@ -458,60 +464,86 @@ public String getDescription() {
return description;
}
- // for unit tests only
- @VisibleForTesting
- MetricsMap getMetricsMap() {
- return cacheMap;
- }
-
@Override
public SolrMetricsContext getSolrMetricsContext() {
return solrMetricsContext;
}
@Override
public String toString() {
- return name() + (cacheMap != null ? cacheMap.getValue().toString() : "");
Review Comment:
I recall there was a useful feature in the admin UI to observe the contents of the cache in a debug/diagnostic setting, and I recall it was powered by this. Maybe I'm a bit off. Any way, fine for it to go for now. If we want it back, it ought to come back in a better way than this.
##########
solr/core/src/java/org/apache/solr/search/CaffeineCache.java:
##########
@@ -325,13 +330,14 @@ public int size() {
@Override
public void close() throws IOException {
- SolrCache.super.close();
+ IOUtils.closeQuietly(toClose);
Review Comment:
I see the metrics closure is here before cache.invalidateAll & cleanUp, which at least superficially sound like operations that might trigger metrics like invalidation. I dunno. Well your tests pass so I suppose not an issue.
##########
solr/core/src/java/org/apache/solr/search/CaffeineCache.java:
##########
@@ -458,60 +464,86 @@ public String getDescription() {
return description;
}
- // for unit tests only
- @VisibleForTesting
- MetricsMap getMetricsMap() {
- return cacheMap;
- }
-
@Override
public SolrMetricsContext getSolrMetricsContext() {
return solrMetricsContext;
}
@Override
public String toString() {
- return name() + (cacheMap != null ? cacheMap.getValue().toString() : "");
+ return name();
}
- // TODO SOLR-17458: Migrate to Otel
@Override
public void initializeMetrics(
SolrMetricsContext parentContext, Attributes attributes, String scope) {
- solrMetricsContext = parentContext.getChildContext(this);
- cacheMap =
- new MetricsMap(
- map -> {
- if (cache != null) {
- CacheStats stats = cache.stats();
- long hitCount = stats.hitCount() + hits.sum();
- long insertCount = inserts.sum();
- long lookupCount = stats.requestCount() + lookups.sum();
-
- map.put(LOOKUPS_PARAM, lookupCount);
- map.put(HITS_PARAM, hitCount);
- map.put(HIT_RATIO_PARAM, hitRate(hitCount, lookupCount));
- map.put(INSERTS_PARAM, insertCount);
- map.put(EVICTIONS_PARAM, stats.evictionCount());
- map.put(SIZE_PARAM, cache.asMap().size());
- map.put("warmupTime", warmupTime);
- map.put(RAM_BYTES_USED_PARAM, ramBytesUsed());
- map.put(MAX_RAM_MB_PARAM, getMaxRamMB());
-
- CacheStats cumulativeStats = priorStats.plus(stats);
- long cumLookups = priorLookups + lookupCount;
- long cumHits = priorHits + hitCount;
- map.put("cumulative_lookups", cumLookups);
- map.put("cumulative_hits", cumHits);
- map.put("cumulative_hitratio", hitRate(cumHits, cumLookups));
- map.put("cumulative_inserts", priorInserts + insertCount);
- map.put("cumulative_evictions", cumulativeStats.evictionCount());
- }
- });
- solrMetricsContext.gauge(cacheMap, true, scope, getCategory().toString());
+ initializeMetrics(parentContext, attributes, false);
}
- private static double hitRate(long hitCount, long lookupCount) {
- return lookupCount == 0 ? 1.0 : (double) hitCount / lookupCount;
+ public void initializeMetrics(
+ SolrMetricsContext parentContext, Attributes attributes, boolean isNodeLevelCache) {
+ Attributes cacheAttributes =
+ attributes.toBuilder().put(CATEGORY_ATTR, getCategory().toString()).build();
+ solrMetricsContext = parentContext.getChildContext(this);
+ String metricPrefix = isNodeLevelCache ? "solr_node_cache" : "solr_cache";
+
+ ObservableLongMeasurement cacheLookupsMetric =
+ solrMetricsContext.longCounterMeasurement(
+ metricPrefix + "_lookups",
+ "Number of cumulative cache lookup results (hits and misses)");
+
+ ObservableLongMeasurement cacheOperationMetric =
+ solrMetricsContext.longCounterMeasurement(
+ metricPrefix + "_ops", "Number of cumulative cache operations (inserts and evictions)");
+
+ ObservableLongMeasurement sizeMetric =
+ solrMetricsContext.longGaugeMeasurement(
+ metricPrefix + "_size", "Current number cache entries");
+
+ ObservableLongMeasurement ramBytesUsedMetric =
+ solrMetricsContext.longGaugeMeasurement(
+ metricPrefix + "_ram_used", "RAM bytes used by cache", OtelUnit.BYTES);
+
+ ObservableLongMeasurement warmupTimeMetric =
+ solrMetricsContext.longGaugeMeasurement(
+ metricPrefix + "_warmup_time", "Cache warmup time", OtelUnit.MILLISECONDS);
Review Comment:
Could clarify "Cache warmup time (most recent)"
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-17806: Migrate CaffeineCache to OTEL [solr]
Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on PR #3671:
URL: https://github.com/apache/solr/pull/3671#issuecomment-3325170352
Note: we can add more metrics later if we play it conservative :-)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-17806: Migrate CaffeineCache to OTEL [solr]
Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on PR #3671:
URL: https://github.com/apache/solr/pull/3671#issuecomment-3335897164
What about the top 2 bullets I summarized?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-17806: Migrate CaffeineCache to OTEL [solr]
Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on code in PR #3671:
URL: https://github.com/apache/solr/pull/3671#discussion_r2364565335
##########
solr/core/src/java/org/apache/solr/core/SolrCore.java:
##########
@@ -555,6 +557,25 @@ public void setName(String v) {
assert this.name != null;
assert coreDescriptor.getCloudDescriptor() == null : "Cores are not renamed in SolrCloud";
this.name = Objects.requireNonNull(v);
+ initCoreAttributes();
+ }
+
+ public Attributes getCoreAttributes() {
+ return coreAttributes;
+ }
+
+ public void initCoreAttributes() {
+ this.coreAttributes =
+ (coreContainer.isZooKeeperAware())
+ ? Attributes.builder()
+ .put(COLLECTION_ATTR, coreDescriptor.getCollectionName())
+ .put(CORE_ATTR, getName())
Review Comment:
cores can be renamed (sadly; I hate it). We'll need to rebuild when that happens.
##########
solr/core/src/java/org/apache/solr/search/CaffeineCache.java:
##########
@@ -471,47 +477,90 @@ public SolrMetricsContext getSolrMetricsContext() {
@Override
public String toString() {
- return name() + (cacheMap != null ? cacheMap.getValue().toString() : "");
+ return name();
}
- // TODO SOLR-17458: Migrate to Otel
@Override
public void initializeMetrics(
SolrMetricsContext parentContext, Attributes attributes, String scope) {
+ Attributes cacheAttributes =
+ attributes.toBuilder().put(CATEGORY_ATTR, getCategory().toString()).build();
solrMetricsContext = parentContext.getChildContext(this);
- cacheMap =
- new MetricsMap(
- map -> {
+
+ ObservableLongMeasurement cacheOperation =
+ solrMetricsContext.longCounterMeasurement(
+ "solr_searcher_cache_ops",
+ "Number of cache operations (hits, lookups, inserts and evictions)");
+
+ ObservableLongMeasurement hitRatioMetric =
+ solrMetricsContext.longGaugeMeasurement("solr_searcher_cache_hit_ratio", "Cache hit ratio");
+
+ ObservableLongMeasurement sizeMetric =
+ solrMetricsContext.longGaugeMeasurement(
+ "solr_searcher_cache_size", "Current number cache entries");
+
+ ObservableLongMeasurement ramBytesUsedMetric =
+ solrMetricsContext.longGaugeMeasurement(
+ "solr_searcher_cache_ram_used", "RAM bytes used by cache", OtelUnit.BYTES);
+
+ ObservableLongMeasurement warmupTimeMetric =
+ solrMetricsContext.longGaugeMeasurement(
+ "solr_searcher_cache_warmup_time", "Cache warmup time", OtelUnit.MILLISECONDS);
+
+ ObservableLongMeasurement cumulativeCacheOperation =
+ solrMetricsContext.longGaugeMeasurement(
+ "solr_cache_cumulative_ops",
+ "Number of cumulative cache operations (hits, lookups, inserts and evictions)");
+
+ this.toClose =
+ solrMetricsContext.batchCallback(
+ () -> {
if (cache != null) {
CacheStats stats = cache.stats();
long hitCount = stats.hitCount() + hits.sum();
long insertCount = inserts.sum();
long lookupCount = stats.requestCount() + lookups.sum();
- map.put(LOOKUPS_PARAM, lookupCount);
- map.put(HITS_PARAM, hitCount);
- map.put(HIT_RATIO_PARAM, hitRate(hitCount, lookupCount));
- map.put(INSERTS_PARAM, insertCount);
- map.put(EVICTIONS_PARAM, stats.evictionCount());
- map.put(SIZE_PARAM, cache.asMap().size());
- map.put("warmupTime", warmupTime);
- map.put(RAM_BYTES_USED_PARAM, ramBytesUsed());
- map.put(MAX_RAM_MB_PARAM, getMaxRamMB());
+ cacheOperation.record(
+ hitCount, cacheAttributes.toBuilder().put(OPERATION_ATTR, "hits").build());
Review Comment:
this is the result/outcome of an operation, not an operation.
It could be interesting to have two pseudo-operations -- lookups_hit and lookups_miss or put the outcomes into a separate attribute like "hit" (1 or 0).
##########
solr/core/src/test/org/apache/solr/core/TestSolrConfigHandler.java:
##########
@@ -1045,20 +1046,19 @@ public void testSetPropertyEnableAndDisableCache() throws Exception {
String payload = "{'set-property' : { 'query.documentCache.enabled': true} }";
runConfigCommand(restTestHarness, "/config", payload);
restTestHarness.setServerProvider(() -> getBaseUrl());
- MapWriter confMap = getRespMap("/admin/metrics", restTestHarness);
- assertNotNull(
- confMap._get(
- asList("metrics", "solr.core.collection1", "CACHE.searcher.documentCache"), null));
+
+ String prometheusMetrics = restTestHarness.query("/admin/metrics?wt=prometheus");
+ assertTrue(prometheusMetrics.contains("cache_name=\"documentCache\""));
// Disabling Cache
payload = "{ 'set-property' : { 'query.documentCache.enabled': false } }";
restTestHarness.setServerProvider(oldProvider);
+
runConfigCommand(restTestHarness, "/config", payload);
restTestHarness.setServerProvider(() -> getBaseUrl());
- confMap = getRespMap("/admin/metrics", restTestHarness);
- assertNull(
- confMap._get(
- asList("metrics", "solr.core.collection1", "CACHE.searcher.documentCache"), null));
+
+ prometheusMetrics = restTestHarness.query("/admin/metrics?wt=prometheus");
Review Comment:
this if fine but isn't prometheus always the format if not specified henceforth?
##########
solr/core/src/java/org/apache/solr/search/CaffeineCache.java:
##########
@@ -471,47 +477,90 @@ public SolrMetricsContext getSolrMetricsContext() {
@Override
public String toString() {
- return name() + (cacheMap != null ? cacheMap.getValue().toString() : "");
+ return name();
}
- // TODO SOLR-17458: Migrate to Otel
@Override
public void initializeMetrics(
SolrMetricsContext parentContext, Attributes attributes, String scope) {
+ Attributes cacheAttributes =
+ attributes.toBuilder().put(CATEGORY_ATTR, getCategory().toString()).build();
solrMetricsContext = parentContext.getChildContext(this);
- cacheMap =
- new MetricsMap(
- map -> {
+
+ ObservableLongMeasurement cacheOperation =
+ solrMetricsContext.longCounterMeasurement(
+ "solr_searcher_cache_ops",
+ "Number of cache operations (hits, lookups, inserts and evictions)");
+
+ ObservableLongMeasurement hitRatioMetric =
+ solrMetricsContext.longGaugeMeasurement("solr_searcher_cache_hit_ratio", "Cache hit ratio");
+
+ ObservableLongMeasurement sizeMetric =
+ solrMetricsContext.longGaugeMeasurement(
+ "solr_searcher_cache_size", "Current number cache entries");
Review Comment:
I see you are putting "searcher" in the name yet CaffeineCache could be used anywhere.
##########
solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java:
##########
@@ -603,9 +604,10 @@ public void register() {
this.solrMetricsContext = core.getSolrMetricsContext().getChildContext(this);
for (SolrCache<?, ?> cache : cacheList) {
cache.initializeMetrics(
- // TODO SOLR-17458: Add Otel
solrMetricsContext,
- Attributes.empty(),
+ core.getCoreAttributes().toBuilder()
+ .put(AttributeKey.stringKey("cache_name"), cache.name())
Review Comment:
would the "cache_" prefix be redundant?
##########
solr/core/src/java/org/apache/solr/search/CaffeineCache.java:
##########
@@ -326,6 +331,7 @@ public int size() {
@Override
public void close() throws IOException {
SolrCache.super.close();
Review Comment:
Generally, closure works like a stack, so we close super _last_, not first. I know you didn't touch that but...
##########
solr/core/src/test/org/apache/solr/CursorPagingTest.java:
##########
@@ -715,30 +715,19 @@ public void testCacheImpacts() throws Exception {
final Collection<String> allFieldNames = getAllSortFieldNames();
- final MetricsMap filterCacheStats =
- (MetricsMap)
- ((SolrMetricManager.GaugeWrapper)
- h.getCore()
- .getCoreMetricManager()
- .getRegistry()
- .getMetrics()
- .get("CACHE.searcher.filterCache"))
- .getGauge();
- assertNotNull(filterCacheStats);
- final MetricsMap queryCacheStats =
- (MetricsMap)
- ((SolrMetricManager.GaugeWrapper)
- h.getCore()
- .getCoreMetricManager()
- .getRegistry()
- .getMetrics()
- .get("CACHE.searcher.queryResultCache"))
- .getGauge();
- assertNotNull(queryCacheStats);
-
- final long preQcIn = (Long) queryCacheStats.getValue().get("inserts");
- final long preFcIn = (Long) filterCacheStats.getValue().get("inserts");
- final long preFcHits = (Long) filterCacheStats.getValue().get("hits");
+ SolrCore solrCore = h.getCore();
+
+ // Get initial metrics for filter and query cache
+ var preFilterInserts =
+ SolrMetricTestUtils.getCacheSearcherOpsInserts(solrCore, SolrMetricTestUtils.FILTER_CACHE)
Review Comment:
nice; these will be useful across a number of tests
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-17806: Migrate CaffeineCache to OTEL [solr]
Posted by "mlbiscoc (via GitHub)" <gi...@apache.org>.
mlbiscoc commented on PR #3671:
URL: https://github.com/apache/solr/pull/3671#issuecomment-3324124441
> Since we should prefer aggregations outside of the service we export, shouldn't we omit the hit ratio?
Good point. Will remove it. The same metrics exist to calculate it yourself.
> This metric looks useless: solr_cache_ops_total
So you want to remove it? It is used in many different tests.
> FWIW w export some metrics as gauges but Gemini AI pointed out that some of these look like counters, and that counters allow use of PromQL functions like rate() and increase(), implying it's impossible otherwise.
I believe you technically can use functions like `rate()` and `increase()` for gauges but shouldn't because those functions were created for counters (Strictly increasing numbers). If gauges goes down at any point, the function outputs misleading data. But at that point if your gauge never goes down, it should have been a counter in the first place. I tried my best to make things counters when we can but possible I missed some places so let me know if you see something. For this PR specifically, I noticed now in the PR the `solr_cache_cumulative_lookups` should be the counter and `solr_cache_lookups` should be a gauge since it can get reset to 0 on cache warm (I flipped it) . Going to fix that.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-17806: Migrate CaffeineCache to OTEL [solr]
Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on PR #3671:
URL: https://github.com/apache/solr/pull/3671#issuecomment-3325168516
We definitely should retain the current size (count), size (bytes), and warmup time (ms). And I'm assuming we already have searcher creation metrics that could be used to definitively correlate the cache reset event with the cumulative cache metrics. But I question if we need any other metric for the cache that isn't cumulative. Please sell me on that if you think so.
OTEL transition has been a time for metrics house-cleaning. Reconsider their names and which ones we actually need in the first place.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-17806: Migrate CaffeineCache to OTEL [solr]
Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on PR #3671:
URL: https://github.com/apache/solr/pull/3671#issuecomment-3325360685
I'm confident a test can get what it wants to know based on the reduced set of metrics I propose. If you doubt it, tell me which test exactly couldn't be supported and I'll look into it right away.
If we agree "cumulative" is what a user ought to want to look at by default, then ideally it's name would be the simpler version without the word cumulative (the description can clarify), and we put non-cumulative ones in another named metric. I asked Gemini AI about the whole situation, and it recommended _snapshotting_ the cumulative metrics instead of separately capturing both as we've been doing because it is more efficient -- more counters instead of gauges and moreover reduces cardinality a lot. Capturing a metric since the reset is then simple subtraction.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-17806: Migrate CaffeineCache to OTEL [solr]
Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on PR #3671:
URL: https://github.com/apache/solr/pull/3671#issuecomment-3334659055
We had a nice discussion today 1:1:
* the CaffeineCache should not create the metric name. The caller knows the name to use; it should pass it in
* the metric name should reflect the subsystem/category of Solr where it lives. Like "solr_searcher_cache" or "solr_node_cache".
I suggested maybe the cache's name should be part of the metric name, i.e. "solr_searcher_filterCache. I suggested this because the cardinality isn't highly variable and it's pretty small. And I don't imagine someone would do aggregations across all caches. But as I think about this, there's also a consistency factor, like say with request handlers. Caches and request handlers are fairly similar in this way. So if a request handler's name is *not* part of the metric name, then a cache name should probably *not* be part of the metric name either. At least it's debatable and I don't have a strong opinion.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-17806: Migrate CaffeineCache to OTEL [solr]
Posted by "mlbiscoc (via GitHub)" <gi...@apache.org>.
mlbiscoc commented on PR #3671:
URL: https://github.com/apache/solr/pull/3671#issuecomment-3335945445
Ah sorry forgot that duh... I would be ok with either of these 2 things unless you have a different idea but don't want to put these cacheName in the metric name. Either add a `namespace` or `component` attribute to differentiate by `node`/`searcher` or we allow a string prefix for the `namespace` that isn't the name of the distinct cacheName. to basically `solr_ + prefix + _cache` and we can sanitize it to lower case to keep things consistent.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-17806: Migrate CaffeineCache to OTEL [solr]
Posted by "mlbiscoc (via GitHub)" <gi...@apache.org>.
mlbiscoc commented on PR #3671:
URL: https://github.com/apache/solr/pull/3671#issuecomment-3334801256
It was definitely worth exploring. I played around with it thought about it more and after looking I think I prefer it as an attribute and probably against prefixing it in the name. I am not really worried about cardinality but labels also help with filtering not just aggregation. So at something like the OTel collector level you can filter more easily or if we improve that on the /admin/metrics endpoint and at promQL it can be more annoying to aggregate like `solr_*Cache_lookups` as a filter parameter for caches. Also to pick up new caches you need to change your dashboards since its embedded in the name (though I know you argued changing or removing caches isn't done often) but with labels nothing needs to change. Also the naming doesn't follow our snake case convention which looks awkward. If we care about a user knowing its cache level or component, then maybe that should be an attribute as well `level` or `component` = `searcher/node/foobar`. Something that could be nice thou
gh from this is that someone could pass in their own description for each cache since it created it own metric.
```
# HELP solr_searcher_fieldValueCache_lookups_total Number of cumulative cache lookup results (hits and misses)
# TYPE solr_searcher_fieldValueCache_lookups_total counter
solr_searcher_fieldValueCache_lookups_total{category="CACHE",collection="demo",core="demo_shard1_replica_n1",otel_scope_name="org.apache.solr",replica="replica_n1",result="hit",shard="shard1"} 0.0
solr_searcher_fieldValueCache_lookups_total{category="CACHE",collection="demo",core="demo_shard1_replica_n1",otel_scope_name="org.apache.solr",replica="replica_n1",result="miss",shard="shard1"} 0.0
solr_searcher_fieldValueCache_lookups_total{category="CACHE",collection="foobar",core="foobar_shard1_replica_n1",otel_scope_name="org.apache.solr",replica="replica_n1",result="hit",shard="shard1"} 0.0
solr_searcher_fieldValueCache_lookups_total{category="CACHE",collection="foobar",core="foobar_shard1_replica_n1",otel_scope_name="org.apache.solr",replica="replica_n1",result="miss",shard="shard1"} 0.0
# HELP solr_searcher_documentCache_lookups_total Number of cumulative cache lookup results (hits and misses)
# TYPE solr_searcher_documentCache_lookups_total counter
solr_searcher_documentCache_lookups_total{category="CACHE",collection="demo",core="demo_shard1_replica_n1",otel_scope_name="org.apache.solr",replica="replica_n1",result="hit",shard="shard1"} 0.0
solr_searcher_documentCache_lookups_total{category="CACHE",collection="demo",core="demo_shard1_replica_n1",otel_scope_name="org.apache.solr",replica="replica_n1",result="miss",shard="shard1"} 0.0
solr_searcher_documentCache_lookups_total{category="CACHE",collection="foobar",core="foobar_shard1_replica_n1",otel_scope_name="org.apache.solr",replica="replica_n1",result="hit",shard="shard1"} 0.0
solr_searcher_documentCache_lookups_total{category="CACHE",collection="foobar",core="foobar_shard1_replica_n1",otel_scope_name="org.apache.solr",replica="replica_n1",result="miss",shard="shard1"} 0.0
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-17806: Migrate CaffeineCache to OTEL [solr]
Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on PR #3671:
URL: https://github.com/apache/solr/pull/3671#issuecomment-3321205040
Since we should prefer aggregations outside of the service we export, shouldn't we omit the hit ratio?
This metric looks useless: solr_cache_ops_total
FWIW w export some metrics as gauges but Gemini AI pointed out that some of these *look* like counters, and that counters allow use of PromQL functions like `rate()` and `increase()`, implying it's impossible otherwise.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-17806: Migrate CaffeineCache to OTEL [solr]
Posted by "mlbiscoc (via GitHub)" <gi...@apache.org>.
mlbiscoc commented on code in PR #3671:
URL: https://github.com/apache/solr/pull/3671#discussion_r2372904521
##########
solr/core/src/java/org/apache/solr/search/CaffeineCache.java:
##########
@@ -471,47 +477,90 @@ public SolrMetricsContext getSolrMetricsContext() {
@Override
public String toString() {
- return name() + (cacheMap != null ? cacheMap.getValue().toString() : "");
+ return name();
}
- // TODO SOLR-17458: Migrate to Otel
@Override
public void initializeMetrics(
SolrMetricsContext parentContext, Attributes attributes, String scope) {
+ Attributes cacheAttributes =
+ attributes.toBuilder().put(CATEGORY_ATTR, getCategory().toString()).build();
solrMetricsContext = parentContext.getChildContext(this);
- cacheMap =
- new MetricsMap(
- map -> {
+
+ ObservableLongMeasurement cacheOperation =
+ solrMetricsContext.longCounterMeasurement(
+ "solr_searcher_cache_ops",
+ "Number of cache operations (hits, lookups, inserts and evictions)");
+
+ ObservableLongMeasurement hitRatioMetric =
+ solrMetricsContext.longGaugeMeasurement("solr_searcher_cache_hit_ratio", "Cache hit ratio");
+
+ ObservableLongMeasurement sizeMetric =
+ solrMetricsContext.longGaugeMeasurement(
+ "solr_searcher_cache_size", "Current number cache entries");
+
+ ObservableLongMeasurement ramBytesUsedMetric =
+ solrMetricsContext.longGaugeMeasurement(
+ "solr_searcher_cache_ram_used", "RAM bytes used by cache", OtelUnit.BYTES);
+
+ ObservableLongMeasurement warmupTimeMetric =
+ solrMetricsContext.longGaugeMeasurement(
+ "solr_searcher_cache_warmup_time", "Cache warmup time", OtelUnit.MILLISECONDS);
+
+ ObservableLongMeasurement cumulativeCacheOperation =
+ solrMetricsContext.longGaugeMeasurement(
+ "solr_cache_cumulative_ops",
+ "Number of cumulative cache operations (hits, lookups, inserts and evictions)");
+
+ this.toClose =
+ solrMetricsContext.batchCallback(
+ () -> {
if (cache != null) {
CacheStats stats = cache.stats();
long hitCount = stats.hitCount() + hits.sum();
long insertCount = inserts.sum();
long lookupCount = stats.requestCount() + lookups.sum();
- map.put(LOOKUPS_PARAM, lookupCount);
- map.put(HITS_PARAM, hitCount);
- map.put(HIT_RATIO_PARAM, hitRate(hitCount, lookupCount));
- map.put(INSERTS_PARAM, insertCount);
- map.put(EVICTIONS_PARAM, stats.evictionCount());
- map.put(SIZE_PARAM, cache.asMap().size());
- map.put("warmupTime", warmupTime);
- map.put(RAM_BYTES_USED_PARAM, ramBytesUsed());
- map.put(MAX_RAM_MB_PARAM, getMaxRamMB());
+ cacheOperation.record(
+ hitCount, cacheAttributes.toBuilder().put(OPERATION_ATTR, "hits").build());
Review Comment:
The more I thought about it, I think you're right here. No point in a total metric as its redundant. Just sum `hit/miss`. Miss is `total - hits` anyways and the aggregation is simple. So I removed it. Only hit/miss now.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-17806: Migrate CaffeineCache to OTEL [solr]
Posted by "mlbiscoc (via GitHub)" <gi...@apache.org>.
mlbiscoc commented on PR #3671:
URL: https://github.com/apache/solr/pull/3671#issuecomment-3335193439
Going to keep the PR as is unless there is something you else you think is worth changing.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-17806: Migrate CaffeineCache to OTEL [solr]
Posted by "mlbiscoc (via GitHub)" <gi...@apache.org>.
mlbiscoc merged PR #3671:
URL: https://github.com/apache/solr/pull/3671
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-17806: Migrate CaffeineCache to OTEL [solr]
Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on PR #3671:
URL: https://github.com/apache/solr/pull/3671#issuecomment-3336027245
I'm definitely okay leaving the cache name out of the metric name -- which is what the paragraph afterwards was about. Those 2 bullets (preceding) don't imply anything about that paragraph. That paragraph is not associated with either bullet. I think we should do both bullets.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-17806: Migrate CaffeineCache to OTEL [solr]
Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on PR #3671:
URL: https://github.com/apache/solr/pull/3671#issuecomment-3324360730
On my mind is the "cumulative" metrics distinction. I imagine someone looking at Solr metrics would expect that to be the norm / implied. The fact that caches get recreated is an internal detail. WDYT? Just exploring this idea with you; I don't have a strong opinion (yet). In proposing this notion, I don't mean to remove important metrics for troubleshooting / deeper insights.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-17806: Migrate CaffeineCache to OTEL [solr]
Posted by "mlbiscoc (via GitHub)" <gi...@apache.org>.
mlbiscoc commented on PR #3671:
URL: https://github.com/apache/solr/pull/3671#issuecomment-3324812494
> On my mind is the "cumulative" metrics distinction. I imagine someone looking at Solr metrics would expect that to be the norm / implied. The fact that caches get recreated is an internal detail. WDYT? Just exploring this idea with you; I don't have a strong opinion (yet). In proposing this notion, I don't mean to remove important metrics for troubleshooting / deeper insights.
Cumulative is probably the one a generic user should be using but I do see some value in cache metrics after warming and it being reset. If you can correlate it with `solr_cache_warmup_time_count` on your dashboard it could probably help you get insight on why you are hitting or missing.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-17806: Migrate CaffeineCache to OTEL [solr]
Posted by "mlbiscoc (via GitHub)" <gi...@apache.org>.
mlbiscoc commented on code in PR #3671:
URL: https://github.com/apache/solr/pull/3671#discussion_r2372898024
##########
solr/core/src/java/org/apache/solr/core/CoreContainer.java:
##########
@@ -874,9 +874,7 @@ private void loadInternal() {
String cacheName = e.getKey();
c.initializeMetrics(
solrMetricsContext,
- Attributes.builder()
- .put(AttributeKey.stringKey("cache_name"), "nodeLevelCache/" + cacheName)
- .build(),
+ Attributes.builder().put(NAME_ATTR, "nodeLevelCache/" + cacheName).build(),
Review Comment:
Embedding it in the metric name is hacking actually... So instead I overloaded the initializeMetrics call in CaffeineCache and set a boolean to create the prefix of the metric name if it is node level or not. The output looks much cleaner and tests pass for `TestThinCache`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-17806: Migrate CaffeineCache to OTEL [solr]
Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on code in PR #3671:
URL: https://github.com/apache/solr/pull/3671#discussion_r2369926163
##########
solr/core/src/test/org/apache/solr/core/TestSolrConfigHandler.java:
##########
@@ -1045,20 +1046,19 @@ public void testSetPropertyEnableAndDisableCache() throws Exception {
String payload = "{'set-property' : { 'query.documentCache.enabled': true} }";
runConfigCommand(restTestHarness, "/config", payload);
restTestHarness.setServerProvider(() -> getBaseUrl());
- MapWriter confMap = getRespMap("/admin/metrics", restTestHarness);
- assertNotNull(
- confMap._get(
- asList("metrics", "solr.core.collection1", "CACHE.searcher.documentCache"), null));
+
+ String prometheusMetrics = restTestHarness.query("/admin/metrics?wt=prometheus");
+ assertTrue(prometheusMetrics.contains("cache_name=\"documentCache\""));
// Disabling Cache
payload = "{ 'set-property' : { 'query.documentCache.enabled': false } }";
restTestHarness.setServerProvider(oldProvider);
+
runConfigCommand(restTestHarness, "/config", payload);
restTestHarness.setServerProvider(() -> getBaseUrl());
- confMap = getRespMap("/admin/metrics", restTestHarness);
- assertNull(
- confMap._get(
- asList("metrics", "solr.core.collection1", "CACHE.searcher.documentCache"), null));
+
+ prometheusMetrics = restTestHarness.query("/admin/metrics?wt=prometheus");
Review Comment:
it's fine; just wanted to confirm. The explicitness has value!
##########
solr/core/src/java/org/apache/solr/core/CoreContainer.java:
##########
@@ -874,9 +874,7 @@ private void loadInternal() {
String cacheName = e.getKey();
c.initializeMetrics(
solrMetricsContext,
- Attributes.builder()
- .put(AttributeKey.stringKey("cache_name"), "nodeLevelCache/" + cacheName)
- .build(),
+ Attributes.builder().put(NAME_ATTR, "nodeLevelCache/" + cacheName).build(),
Review Comment:
IMO "nodeLevelCache" can simply be "node". The metric name itself includes the word "cache"; we know it's a cache.
I like that you were thinking of this cache level differentiation. It feels like a small hack to embed this in the cache name. I suppose ideally it'd be in the metric name but maybe cache name is fine too.
##########
solr/core/src/java/org/apache/solr/search/CaffeineCache.java:
##########
@@ -471,47 +477,90 @@ public SolrMetricsContext getSolrMetricsContext() {
@Override
public String toString() {
- return name() + (cacheMap != null ? cacheMap.getValue().toString() : "");
+ return name();
}
- // TODO SOLR-17458: Migrate to Otel
@Override
public void initializeMetrics(
SolrMetricsContext parentContext, Attributes attributes, String scope) {
+ Attributes cacheAttributes =
+ attributes.toBuilder().put(CATEGORY_ATTR, getCategory().toString()).build();
solrMetricsContext = parentContext.getChildContext(this);
- cacheMap =
- new MetricsMap(
- map -> {
+
+ ObservableLongMeasurement cacheOperation =
+ solrMetricsContext.longCounterMeasurement(
+ "solr_searcher_cache_ops",
+ "Number of cache operations (hits, lookups, inserts and evictions)");
+
+ ObservableLongMeasurement hitRatioMetric =
+ solrMetricsContext.longGaugeMeasurement("solr_searcher_cache_hit_ratio", "Cache hit ratio");
+
+ ObservableLongMeasurement sizeMetric =
+ solrMetricsContext.longGaugeMeasurement(
+ "solr_searcher_cache_size", "Current number cache entries");
+
+ ObservableLongMeasurement ramBytesUsedMetric =
+ solrMetricsContext.longGaugeMeasurement(
+ "solr_searcher_cache_ram_used", "RAM bytes used by cache", OtelUnit.BYTES);
+
+ ObservableLongMeasurement warmupTimeMetric =
+ solrMetricsContext.longGaugeMeasurement(
+ "solr_searcher_cache_warmup_time", "Cache warmup time", OtelUnit.MILLISECONDS);
+
+ ObservableLongMeasurement cumulativeCacheOperation =
+ solrMetricsContext.longGaugeMeasurement(
+ "solr_cache_cumulative_ops",
+ "Number of cumulative cache operations (hits, lookups, inserts and evictions)");
+
+ this.toClose =
+ solrMetricsContext.batchCallback(
+ () -> {
if (cache != null) {
CacheStats stats = cache.stats();
long hitCount = stats.hitCount() + hits.sum();
long insertCount = inserts.sum();
long lookupCount = stats.requestCount() + lookups.sum();
- map.put(LOOKUPS_PARAM, lookupCount);
- map.put(HITS_PARAM, hitCount);
- map.put(HIT_RATIO_PARAM, hitRate(hitCount, lookupCount));
- map.put(INSERTS_PARAM, insertCount);
- map.put(EVICTIONS_PARAM, stats.evictionCount());
- map.put(SIZE_PARAM, cache.asMap().size());
- map.put("warmupTime", warmupTime);
- map.put(RAM_BYTES_USED_PARAM, ramBytesUsed());
- map.put(MAX_RAM_MB_PARAM, getMaxRamMB());
+ cacheOperation.record(
+ hitCount, cacheAttributes.toBuilder().put(OPERATION_ATTR, "hits").build());
Review Comment:
You addressed my feedback, thanks.
I see that the lookup metric with the absence of `result` is the sum of hit/miss. I asked Gemini AI about the possible redundancy of this, and it pointed out the trend of doing aggregations at query time and only having granular data at the spot where we export. This makes sense based on how easy it showed me to sum the lookups of a given cache name across all cores. But it's not quite so simple/easy with this redundancy; since then you have to specifically match where there is a value in result or exclude where result is present (there are different ways). It's not a big deal but... I dunno.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-17806: Migrate CaffeineCache to OTEL [solr]
Posted by "mlbiscoc (via GitHub)" <gi...@apache.org>.
mlbiscoc commented on code in PR #3671:
URL: https://github.com/apache/solr/pull/3671#discussion_r2379053054
##########
solr/core/src/java/org/apache/solr/core/SolrCore.java:
##########
@@ -556,6 +557,25 @@ public void setName(String v) {
assert this.name != null;
assert coreDescriptor.getCloudDescriptor() == null : "Cores are not renamed in SolrCloud";
this.name = Objects.requireNonNull(v);
+ initCoreAttributes();
+ }
+
+ public Attributes getCoreAttributes() {
+ return coreAttributes;
+ }
+
+ public void initCoreAttributes() {
Review Comment:
Good catch, made it private.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org