Skip to content

Commit 4dc0b67

Browse files
committed
add xref dump meter
1 parent 55a0a9e commit 4dc0b67

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/web/Util.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
import org.opengrok.indexer.history.Annotation;
6767
import org.opengrok.indexer.history.HistoryGuru;
6868
import org.opengrok.indexer.logger.LoggerFactory;
69+
import org.opengrok.indexer.util.Statistics;
6970

7071
/**
7172
* Class for useful functions.
@@ -1208,7 +1209,7 @@ public static boolean dumpXref(Writer out, File file, boolean compressed, String
12081209
*/
12091210
try (InputStream iss = new BufferedInputStream(new FileInputStream(file));
12101211
Reader in = compressed ? new InputStreamReader(new GZIPInputStream(iss)) : new InputStreamReader(iss)) {
1211-
dumpXref(out, in, contextPath);
1212+
dumpXref(out, in, contextPath, file);
12121213
return true;
12131214
} catch (IOException e) {
12141215
LOGGER.log(Level.WARNING, String.format("An error occurred while piping file '%s'", file), e);
@@ -1222,21 +1223,24 @@ public static boolean dumpXref(Writer out, File file, boolean compressed, String
12221223
* @param out dump destination
12231224
* @param in source to read
12241225
* @param contextPath an optional override of "/source/" as the context path
1226+
* @param file file related to the {@code in}, used for logging only
12251227
* @throws IOException as defined by the given reader/writer
12261228
* @throws NullPointerException if a parameter is {@code null}
12271229
*/
1228-
public static void dumpXref(Writer out, Reader in, String contextPath) throws IOException {
1230+
public static void dumpXref(Writer out, Reader in, String contextPath, File file) throws IOException {
12291231

12301232
if (in == null || out == null) {
12311233
return;
12321234
}
12331235

1236+
Statistics stat = new Statistics();
12341237
XrefSourceTransformer xform = new XrefSourceTransformer(in);
12351238
xform.setWriter(out);
12361239
xform.setContextPath(contextPath);
12371240
while (xform.yylex()) {
12381241
// Nothing else to do.
12391242
}
1243+
stat.report(LOGGER, Level.FINEST, String.format("dumped xref '%s'", file), "xref.dump.latency");
12401244
}
12411245

12421246
/**

opengrok-web/src/main/webapp/list.jsp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ information: Portions Copyright [yyyy] [name of copyright owner]
1616
1717
CDDL HEADER END
1818
19-
Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved.
19+
Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
2020
Portions Copyright 2011 Jens Elkner.
2121
Portions Copyright (c) 2017-2020, Chris Fraire <cfraire@me.com>.
2222
@@ -251,7 +251,7 @@ document.pageReady.push(function() { pageReadyList();});
251251
*/
252252
r = new InputStreamReader(bin);
253253
// dumpXref() is also useful here for translating links.
254-
Util.dumpXref(out, r, request.getContextPath());
254+
Util.dumpXref(out, r, request.getContextPath(), resourceFile);
255255
} else if (g == AbstractAnalyzer.Genre.PLAIN) {
256256
%>
257257
<div id="src" data-navigate-window-enabled="<%= navigateWindowEnabled %>">
@@ -303,7 +303,7 @@ include file="/xref.jspf"
303303
<%
304304
}
305305
} else {
306-
// Requesting cross referenced file with no known revision.
306+
// Requesting cross-referenced file with no known revision.
307307
File xrefFile = cfg.findDataFile();
308308
if (xrefFile != null) {
309309
%>

opengrok-web/src/main/webapp/xref.jspf

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ information: Portions Copyright [yyyy] [name of copyright owner]
1616

1717
CDDL HEADER END
1818

19-
Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
19+
Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
2020
Portions Copyright 2011 Jens Elkner.
2121
Portions Copyright (c) 2017-2020, Chris Fraire <cfraire@me.com>.
2222
--%>
@@ -133,16 +133,14 @@ org.opengrok.indexer.web.QueryParameters"
133133
<pre><%
134134
} else if (g == AbstractAnalyzer.Genre.HTML) {
135135
/*
136-
* For backward compatibility, read the
137-
* OpenGrok-produced document using the system
138-
* default charset.
136+
* For backward compatibility, read the OpenGrok-produced document
137+
* using the system default charset.
139138
*/
140139
r = new InputStreamReader(in);
141140
/*
142-
* dumpXref() is also useful here for
143-
* translating links.
141+
* dumpXref() is also useful here for translating links.
144142
*/
145-
Util.dumpXref(out, r, request.getContextPath());
143+
Util.dumpXref(out, r, request.getContextPath(), resourceFile);
146144
} else {
147145
%>Download binary file, <a href="<%= rawPath %>?<%= QueryParameters.REVISION_PARAM_EQ %>
148146
<%= Util.uriEncode(rev) %>"><%= basename %></a><%

0 commit comments

Comments
 (0)