|
18 | 18 | */
|
19 | 19 |
|
20 | 20 | /*
|
21 |
| - * Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved. |
| 21 | + * Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved. |
22 | 22 | * Portions Copyright (c) 2011, Jens Elkner.
|
23 | 23 | * Portions Copyright (c) 2017, 2020, Chris Fraire <[email protected]>.
|
24 | 24 | */
|
|
56 | 56 | import java.util.regex.Pattern;
|
57 | 57 | import java.util.stream.Collectors;
|
58 | 58 |
|
| 59 | +import io.micrometer.core.instrument.Counter; |
| 60 | +import io.micrometer.core.instrument.MeterRegistry; |
59 | 61 | import jakarta.servlet.ServletRequest;
|
60 | 62 | import jakarta.servlet.http.Cookie;
|
61 | 63 | import jakarta.servlet.http.HttpServletRequest;
|
|
64 | 66 | import org.jetbrains.annotations.Nullable;
|
65 | 67 | import org.jetbrains.annotations.VisibleForTesting;
|
66 | 68 | import org.opengrok.indexer.Info;
|
| 69 | +import org.opengrok.indexer.Metrics; |
67 | 70 | import org.opengrok.indexer.analysis.AbstractAnalyzer;
|
68 | 71 | import org.opengrok.indexer.analysis.AnalyzerGuru;
|
69 | 72 | import org.opengrok.indexer.analysis.ExpandTabsReader;
|
@@ -1199,15 +1202,33 @@ private static String trailingSlash(String path) {
|
1199 | 1202 |
|
1200 | 1203 | @Nullable
|
1201 | 1204 | private File checkFileInner(File file, File dir, String name) {
|
1202 |
| - File f = new File(dir, name); |
1203 |
| - if (f.exists() && f.isFile()) { |
1204 |
| - if (f.lastModified() >= file.lastModified()) { |
1205 |
| - return f; |
| 1205 | + |
| 1206 | + MeterRegistry meterRegistry = Metrics.getRegistry(); |
| 1207 | + |
| 1208 | + File xrefFile = new File(dir, name); |
| 1209 | + if (xrefFile.exists() && xrefFile.isFile()) { |
| 1210 | + if (xrefFile.lastModified() >= file.lastModified()) { |
| 1211 | + if (meterRegistry != null) { |
| 1212 | + Counter.builder("xref.file.get"). |
| 1213 | + description("xref file get hits"). |
| 1214 | + tag("what", "hits"). |
| 1215 | + register(meterRegistry). |
| 1216 | + increment(); |
| 1217 | + } |
| 1218 | + return xrefFile; |
1206 | 1219 | } else {
|
1207 |
| - LOGGER.log(Level.WARNING, "file ''{0}'' is newer than ''{1}''", new Object[]{file, f}); |
| 1220 | + LOGGER.log(Level.WARNING, "file ''{0}'' is newer than ''{1}''", new Object[]{file, xrefFile}); |
1208 | 1221 | }
|
1209 | 1222 | }
|
1210 | 1223 |
|
| 1224 | + if (meterRegistry != null) { |
| 1225 | + Counter.builder("xref.file.get"). |
| 1226 | + description("xref file get misses"). |
| 1227 | + tag("what", "miss"). |
| 1228 | + register(meterRegistry). |
| 1229 | + increment(); |
| 1230 | + } |
| 1231 | + |
1211 | 1232 | return null;
|
1212 | 1233 | }
|
1213 | 1234 |
|
|
0 commit comments