Skip to content

Commit

Permalink
[improve][io] Add ElasticSearch Sink bulk debug logs (apache#179)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoloboschi authored May 4, 2023
1 parent 4201d00 commit e2e2c4a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ public void appendIndexRequest(BulkIndexRequest request) throws IOException {
if (config.getBulkSizeInMb() > 0) {
sourceLength = request.getDocumentSource().getBytes(StandardCharsets.UTF_8).length;
}
if (log.isDebugEnabled()) {
log.debug("append index request id={}, type={}, source={}, length={}",
request.getDocumentId(), config.getTypeName(), mapped, sourceLength);
}
add(BulkOperationWithPulsarRecord.indexOperation(indexOperation, request.getRecord(), sourceLength));
}

Expand All @@ -109,6 +113,9 @@ public void appendDeleteRequest(BulkDeleteRequest request) {
.index(request.getIndex())
.id(request.getDocumentId())
.build();
if (log.isDebugEnabled()) {
log.debug("append delete request id={}, type={}", request.getDocumentId(), config.getTypeName());
}
add(BulkOperationWithPulsarRecord.deleteOperation(deleteOperation, request.getRecord()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,10 @@ public void appendIndexRequest(BulkProcessor.BulkIndexRequest request) throws IO
}
indexRequest.type(config.getTypeName());
indexRequest.source(request.getDocumentSource(), XContentType.JSON);
if (log.isDebugEnabled()) {
log.debug("append index request id={}, type={}, source={}", request.getDocumentId(), config.getTypeName(),
request.getDocumentSource());
}
internalBulkProcessor.add(indexRequest);
}

Expand All @@ -311,6 +315,9 @@ public void appendDeleteRequest(BulkProcessor.BulkDeleteRequest request) throws
DeleteRequest deleteRequest = new DeleteRequestWithPulsarRecord(request.getIndex(), request.getRecord());
deleteRequest.id(request.getDocumentId());
deleteRequest.type(config.getTypeName());
if (log.isDebugEnabled()) {
log.debug("append delete request id={}, type={}", request.getDocumentId(), config.getTypeName());
}
internalBulkProcessor.add(deleteRequest);
}

Expand Down

0 comments on commit e2e2c4a

Please sign in to comment.