summaryrefslogtreecommitdiffstats
path: root/jdisc_http_service
diff options
context:
space:
mode:
authorMorten Tokle <mortent@verizonmedia.com>2020-08-12 13:43:28 +0200
committerMorten Tokle <mortent@verizonmedia.com>2020-08-12 13:43:28 +0200
commitfd148dede2fdc63bf399f0f601041f0dac483184 (patch)
tree70a41e76a3924fdc4ce05c08c3857d45471f0691 /jdisc_http_service
parent104f7547cb92ab39251308f15ddc45d515a48ae2 (diff)
Report requests to /search as request type read
Diffstat (limited to 'jdisc_http_service')
-rw-r--r--jdisc_http_service/abi-spec.json9
-rw-r--r--jdisc_http_service/src/main/java/com/yahoo/jdisc/http/server/jetty/HttpResponseStatisticsCollector.java7
-rw-r--r--jdisc_http_service/src/main/java/com/yahoo/jdisc/http/server/jetty/JettyHttpServer.java2
-rw-r--r--jdisc_http_service/src/main/resources/configdefinitions/jdisc.http.server.def5
-rw-r--r--jdisc_http_service/src/test/java/com/yahoo/jdisc/http/server/jetty/HttpResponseStatisticsCollectorTest.java5
5 files changed, 22 insertions, 6 deletions
diff --git a/jdisc_http_service/abi-spec.json b/jdisc_http_service/abi-spec.json
index aca8b673cca..f6bfe769997 100644
--- a/jdisc_http_service/abi-spec.json
+++ b/jdisc_http_service/abi-spec.json
@@ -791,10 +791,13 @@
"public void <init>(com.yahoo.jdisc.http.ServerConfig$Metric)",
"public com.yahoo.jdisc.http.ServerConfig$Metric$Builder monitoringHandlerPaths(java.lang.String)",
"public com.yahoo.jdisc.http.ServerConfig$Metric$Builder monitoringHandlerPaths(java.util.Collection)",
+ "public com.yahoo.jdisc.http.ServerConfig$Metric$Builder searchHandlerPaths(java.lang.String)",
+ "public com.yahoo.jdisc.http.ServerConfig$Metric$Builder searchHandlerPaths(java.util.Collection)",
"public com.yahoo.jdisc.http.ServerConfig$Metric build()"
],
"fields": [
- "public java.util.List monitoringHandlerPaths"
+ "public java.util.List monitoringHandlerPaths",
+ "public java.util.List searchHandlerPaths"
]
},
"com.yahoo.jdisc.http.ServerConfig$Metric": {
@@ -807,7 +810,9 @@
"methods": [
"public void <init>(com.yahoo.jdisc.http.ServerConfig$Metric$Builder)",
"public java.util.List monitoringHandlerPaths()",
- "public java.lang.String monitoringHandlerPaths(int)"
+ "public java.lang.String monitoringHandlerPaths(int)",
+ "public java.util.List searchHandlerPaths()",
+ "public java.lang.String searchHandlerPaths(int)"
],
"fields": []
},
diff --git a/jdisc_http_service/src/main/java/com/yahoo/jdisc/http/server/jetty/HttpResponseStatisticsCollector.java b/jdisc_http_service/src/main/java/com/yahoo/jdisc/http/server/jetty/HttpResponseStatisticsCollector.java
index 731e737d683..13abb8ddd4d 100644
--- a/jdisc_http_service/src/main/java/com/yahoo/jdisc/http/server/jetty/HttpResponseStatisticsCollector.java
+++ b/jdisc_http_service/src/main/java/com/yahoo/jdisc/http/server/jetty/HttpResponseStatisticsCollector.java
@@ -35,6 +35,7 @@ import java.util.concurrent.atomic.LongAdder;
public class HttpResponseStatisticsCollector extends HandlerWrapper implements Graceful {
private final AtomicReference<FutureCallback> shutdown = new AtomicReference<>();
private final List<String> monitoringHandlerPaths;
+ private final List<String> searchHandlerPaths;
public static enum HttpMethod {
GET, PATCH, POST, PUT, DELETE, OPTIONS, HEAD, OTHER
@@ -54,9 +55,10 @@ public class HttpResponseStatisticsCollector extends HandlerWrapper implements G
private final AtomicLong inFlight = new AtomicLong();
private final LongAdder statistics[][][][];
- public HttpResponseStatisticsCollector(List<String> monitoringHandlerPaths) {
+ public HttpResponseStatisticsCollector(List<String> monitoringHandlerPaths, List<String> searchHandlerPaths) {
super();
this.monitoringHandlerPaths = monitoringHandlerPaths;
+ this.searchHandlerPaths = searchHandlerPaths;
statistics = new LongAdder[HttpScheme.values().length][HttpMethod.values().length][][];
for (int scheme = 0; scheme < HttpScheme.values().length; ++scheme) {
for (int method = 0; method < HttpMethod.values().length; method++) {
@@ -200,6 +202,9 @@ public class HttpResponseStatisticsCollector extends HandlerWrapper implements G
for (String monitoringHandlerPath : monitoringHandlerPaths) {
if (path.startsWith(monitoringHandlerPath)) return RequestType.MONITORING;
}
+ for (String searchHandlerPath : searchHandlerPaths) {
+ if (path.startsWith(searchHandlerPath)) return RequestType.READ;
+ }
if ("GET".equals(request.getMethod())) {
return RequestType.READ;
} else {
diff --git a/jdisc_http_service/src/main/java/com/yahoo/jdisc/http/server/jetty/JettyHttpServer.java b/jdisc_http_service/src/main/java/com/yahoo/jdisc/http/server/jetty/JettyHttpServer.java
index ef552d87cff..386704a5cc2 100644
--- a/jdisc_http_service/src/main/java/com/yahoo/jdisc/http/server/jetty/JettyHttpServer.java
+++ b/jdisc_http_service/src/main/java/com/yahoo/jdisc/http/server/jetty/JettyHttpServer.java
@@ -257,7 +257,7 @@ public class JettyHttpServer extends AbstractServerProvider {
GzipHandler gzipHandler = newGzipHandler(serverConfig);
gzipHandler.setHandler(authEnforcer);
- HttpResponseStatisticsCollector statisticsCollector = new HttpResponseStatisticsCollector(serverConfig.metric().monitoringHandlerPaths());
+ HttpResponseStatisticsCollector statisticsCollector = new HttpResponseStatisticsCollector(serverConfig.metric().monitoringHandlerPaths(), serverConfig.metric().searchHandlerPaths());
statisticsCollector.setHandler(gzipHandler);
StatisticsHandler statisticsHandler = newStatisticsHandler();
diff --git a/jdisc_http_service/src/main/resources/configdefinitions/jdisc.http.server.def b/jdisc_http_service/src/main/resources/configdefinitions/jdisc.http.server.def
index e968d17df85..0cb5b89b20c 100644
--- a/jdisc_http_service/src/main/resources/configdefinitions/jdisc.http.server.def
+++ b/jdisc_http_service/src/main/resources/configdefinitions/jdisc.http.server.def
@@ -40,4 +40,7 @@ jmx.enabled bool default = false
jmx.listenPort int default = 1099
# Paths that should be reported with monitoring dimensions where applicable
-metric.monitoringHandlerPaths[] string \ No newline at end of file
+metric.monitoringHandlerPaths[] string
+
+# Paths that should be reported with search dimensions where applicable
+metric.searchHandlerPaths[] string \ No newline at end of file
diff --git a/jdisc_http_service/src/test/java/com/yahoo/jdisc/http/server/jetty/HttpResponseStatisticsCollectorTest.java b/jdisc_http_service/src/test/java/com/yahoo/jdisc/http/server/jetty/HttpResponseStatisticsCollectorTest.java
index e06905a0212..1a8aa23668b 100644
--- a/jdisc_http_service/src/test/java/com/yahoo/jdisc/http/server/jetty/HttpResponseStatisticsCollectorTest.java
+++ b/jdisc_http_service/src/test/java/com/yahoo/jdisc/http/server/jetty/HttpResponseStatisticsCollectorTest.java
@@ -36,7 +36,8 @@ import static org.hamcrest.Matchers.equalTo;
public class HttpResponseStatisticsCollectorTest {
private Connector connector;
private List<String> monitoringPaths = List.of("/status.html");
- private HttpResponseStatisticsCollector collector = new HttpResponseStatisticsCollector(monitoringPaths);
+ private List<String> searchPaths = List.of("/search");
+ private HttpResponseStatisticsCollector collector = new HttpResponseStatisticsCollector(monitoringPaths, searchPaths);
private int httpResponseCode = 500;
@Test
@@ -102,12 +103,14 @@ public class HttpResponseStatisticsCollectorTest {
@Test
public void statistics_include_request_type_dimension() throws Exception {
testRequest("http", 200, "GET", "/search");
+ testRequest("http", 200, "POST", "/search");
testRequest("http", 200, "POST", "/feed");
testRequest("http", 200, "GET", "/status.html?foo=bar");
var stats = collector.takeStatistics();
assertStatisticsEntryWithRequestTypePresent(stats, "http", "GET", Metrics.RESPONSES_2XX, "monitoring", 1L);
assertStatisticsEntryWithRequestTypePresent(stats, "http", "GET", Metrics.RESPONSES_2XX, "read", 1L);
+ assertStatisticsEntryWithRequestTypePresent(stats, "http", "POST", Metrics.RESPONSES_2XX, "read", 1L);
assertStatisticsEntryWithRequestTypePresent(stats, "http", "POST", Metrics.RESPONSES_2XX, "write", 1L);
testRequest("http", 200, "GET");