Skip to content

Commit

Permalink
[iceberg] Fix StatisticsFileCache JMX bean
Browse files Browse the repository at this point in the history
Previously, only the cache stats were available through the JMX plugin
because only the CacheStatsMBean was exported. The file size and
column count distributions were not available. This fixes the issue by
problem by exporting the StatisticsFileCache object instead and
embedding the cache stats object
  • Loading branch information
ZacBlanco committed Feb 3, 2025
1 parent 91f3f9a commit f78fc09
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@ public StatisticsFileCache createStatisticsFileCache(IcebergConfig config, MBean
.<StatisticsFileCacheKey, ColumnStatistics>weigher((key, entry) -> (int) entry.getEstimatedSize())
.recordStats()
.build();
CacheStatsMBean bean = new CacheStatsMBean(delegate);
exporter.export(generatedNameOf(StatisticsFileCache.class, connectorId), bean);
return new StatisticsFileCache(delegate);
StatisticsFileCache statisticsFileCache = new StatisticsFileCache(delegate);
exporter.export(generatedNameOf(StatisticsFileCache.class, connectorId), statisticsFileCache);
return statisticsFileCache;
}

@ForCachingHiveMetastore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package com.facebook.presto.iceberg.statistics;

import com.facebook.airlift.stats.DistributionStat;
import com.facebook.presto.hive.CacheStatsMBean;
import com.facebook.presto.spi.statistics.ColumnStatistics;
import com.google.common.cache.Cache;
import com.google.common.cache.ForwardingCache.SimpleForwardingCache;
Expand All @@ -25,10 +26,19 @@ public class StatisticsFileCache
{
private final DistributionStat fileSizes = new DistributionStat();
private final DistributionStat columnCounts = new DistributionStat();
private final CacheStatsMBean cacheStats;

public StatisticsFileCache(Cache<StatisticsFileCacheKey, ColumnStatistics> delegate)
{
super(delegate);
cacheStats = new CacheStatsMBean(delegate);
}

@Managed
@Nested
CacheStatsMBean getCacheStats()
{
return cacheStats;
}

@Managed
Expand Down

0 comments on commit f78fc09

Please sign in to comment.