Merge "Add trace timer around Elasticsearch's performRequest" into stable-3.5
diff --git a/src/main/java/com/google/gerrit/elasticsearch/AbstractElasticIndex.java b/src/main/java/com/google/gerrit/elasticsearch/AbstractElasticIndex.java
index fce86b9..1aac6e7 100644
--- a/src/main/java/com/google/gerrit/elasticsearch/AbstractElasticIndex.java
+++ b/src/main/java/com/google/gerrit/elasticsearch/AbstractElasticIndex.java
@@ -52,6 +52,8 @@
import com.google.gerrit.server.config.SitePaths;
import com.google.gerrit.server.index.IndexUtils;
import com.google.gerrit.server.index.options.AutoFlush;
+import com.google.gerrit.server.logging.Metadata;
+import com.google.gerrit.server.logging.TraceContext;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
@@ -354,7 +356,15 @@
for (Map.Entry<String, String> entry : params.entrySet()) {
request.addParameter(entry.getKey(), entry.getValue());
}
- try {
+ try (TraceContext.TraceTimer traceTimer =
+ TraceContext.newTimer(
+ "Elasticsearch perform request",
+ Metadata.builder()
+ .indexName(indexName)
+ .operationName(
+ String.format(
+ "method:%s uri:%s payload:%s params:%s", method, uri, payload, params))
+ .build())) {
return client.get().performRequest(request);
} catch (IOException e) {
throw new StorageException(e);