Skip to content
Snippets Groups Projects
Commit 7673a2dd authored by Vibhuti Sharma [Microsoft]'s avatar Vibhuti Sharma [Microsoft]
Browse files

Add logs to capture latency

parent 2db1762d
No related branches found
No related tags found
2 merge requests!346Merge branch 'aws-integration' into 'master',!299Add logs to capture latency
...@@ -435,7 +435,9 @@ public class IndexerServiceImpl implements IndexerService { ...@@ -435,7 +435,9 @@ public class IndexerServiceImpl implements IndexerService {
Exception failedRequestCause = null; Exception failedRequestCause = null;
try { try {
long startTime = System.currentTimeMillis();
BulkResponse bulkResponse = restClient.bulk(bulkRequest, RequestOptions.DEFAULT); BulkResponse bulkResponse = restClient.bulk(bulkRequest, RequestOptions.DEFAULT);
long stopTime = System.currentTimeMillis();
// log failed bulk requests // log failed bulk requests
ArrayList<String> bulkFailures = new ArrayList<>(); ArrayList<String> bulkFailures = new ArrayList<>();
...@@ -464,7 +466,7 @@ public class IndexerServiceImpl implements IndexerService { ...@@ -464,7 +466,7 @@ public class IndexerServiceImpl implements IndexerService {
} }
if (!bulkFailures.isEmpty()) this.jaxRsDpsLog.warning(bulkFailures); if (!bulkFailures.isEmpty()) this.jaxRsDpsLog.warning(bulkFailures);
jaxRsDpsLog.info(String.format("records in elasticsearch service bulk request: %s | successful: %s | failed: %s", bulkRequest.numberOfActions(), succeededResponses, failedResponses)); jaxRsDpsLog.info(String.format("records in elasticsearch service bulk request: %s | successful: %s | failed: %s | time taken for bulk request: %d milliseconds", bulkRequest.numberOfActions(), succeededResponses, failedResponses, stopTime-startTime));
// retry entire message if all records are failing // retry entire message if all records are failing
if (bulkRequest.numberOfActions() == failureRecordIds.size()) throw new AppException(failedRequestStatus, "Elastic error", failedRequestCause.getMessage(), failedRequestCause); if (bulkRequest.numberOfActions() == failureRecordIds.size()) throw new AppException(failedRequestStatus, "Elastic error", failedRequestCause.getMessage(), failedRequestCause);
......
...@@ -97,10 +97,15 @@ public class IndicesServiceImpl implements IndicesService { ...@@ -97,10 +97,15 @@ public class IndicesServiceImpl implements IndicesService {
request.mapping(mappingJsonString, XContentType.JSON); request.mapping(mappingJsonString, XContentType.JSON);
} }
request.setTimeout(REQUEST_TIMEOUT); request.setTimeout(REQUEST_TIMEOUT);
long startTime = System.currentTimeMillis();
CreateIndexResponse response = client.indices().create(request, RequestOptions.DEFAULT); CreateIndexResponse response = client.indices().create(request, RequestOptions.DEFAULT);
long stopTime = System.currentTimeMillis();
// cache the index status // cache the index status
boolean indexStatus = response.isAcknowledged() && response.isShardsAcknowledged(); boolean indexStatus = response.isAcknowledged() && response.isShardsAcknowledged();
if (indexStatus) this.indexCache.put(index, true); if (indexStatus) {
this.indexCache.put(index, true);
this.log.info(String.format("Time taken to successfully create new index %s : %d milliseconds", request.index(), stopTime-startTime));
}
return indexStatus; return indexStatus;
} catch (ElasticsearchStatusException e) { } catch (ElasticsearchStatusException e) {
......
...@@ -167,8 +167,10 @@ public class IndexerQueueTaskBuilderAzure extends IndexerQueueTaskBuilder { ...@@ -167,8 +167,10 @@ public class IndexerQueueTaskBuilderAzure extends IndexerQueueTaskBuilder {
message.setContentType("application/json"); message.setContentType("application/json");
try { try {
logger.info("Indexer publishes message to Service Bus " + headers.getCorrelationId()); long startTime = System.currentTimeMillis();
topicClientFactory.getClient(headers.getPartitionId(), serviceBusReindexTopicName).send(message); topicClientFactory.getClient(headers.getPartitionId(), serviceBusReindexTopicName).send(message);
long stopTime = System.currentTimeMillis();
logger.info(String.format("Indexer publishes message to Service Bus, messageId: %s | time taken to send message: %d milliseconds ", message.getMessageId(), stopTime - startTime));
} catch (Exception e) { } catch (Exception e) {
logger.error(e.getMessage(), e); logger.error(e.getMessage(), e);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment