mlbiscoc commented on code in PR #2924: URL: https://github.com/apache/solr/pull/2924#discussion_r1896910582
########## solr/core/src/java/org/apache/solr/core/SolrCore.java: ########## @@ -1354,16 +1354,29 @@ public void initializeMetrics(SolrMetricsContext parentContext, String scope) { Category.CORE.toString()); } - // TODO SOLR-8282 move to PATH // initialize disk total / free metrics - Path dataDirPath = Paths.get(dataDir); - File dataDirFile = dataDirPath.toFile(); - parentContext.gauge( - () -> dataDirFile.getTotalSpace(), true, "totalSpace", Category.CORE.toString(), "fs"); + Path dataDirFile = Paths.get(dataDir); + long totalSpace; + long useableSpace; + + try { + totalSpace = Files.getFileStore(dataDirFile).getTotalSpace(); + useableSpace = Files.getFileStore(dataDirFile).getUsableSpace(); + } catch (Exception e) { + // TODO Metrics used to default to 0 with java.io.File even if directory didn't exist + // Should throw an exception and initialize data directory before metrics + totalSpace = 0L; + useableSpace = 0L; + } Review Comment: This here was questionable. Upon a Solr core being initialized, metrics was trying to calculate and initialize a gauge for the `data/` directories before the directory was ever created. This always failed with `File` but it defaults to 0. `Path` on the other hand throws an `Exception`. This didn't seem right but also moving where the `initializeMetrics` is called in a bunch of different places had tests failing and I wasn't sure why so I kept it as TODO. But also if this is initializing metrics for a `SolrCore` registry upon creation, shouldn't it always be 0 as the data directory was most likely just created? -- 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-unsubscr...@solr.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org For additional commands, e-mail: issues-h...@solr.apache.org