Skip to content
Snippets Groups Projects
Commit f592af29 authored by Larissa Pereira's avatar Larissa Pereira
Browse files

capture inner httpResponse when Partition Exception is thrown

parent e738e723
Branches
Tags
1 merge request!587enhance logging to include correlation-id and record-id
Pipeline #200590 failed
......@@ -69,19 +69,11 @@ public class RecordIndexerApi {
public ResponseEntity<JobStatus> indexWorker(
@NotNull(message = SwaggerDoc.REQUEST_VALIDATION_NOT_NULL_BODY)
@Valid @RequestBody RecordChangedMessages recordChangedMessages) throws Exception {
if (recordChangedMessages == null) {
log.info("record change messages is null");
return new ResponseEntity(HttpStatus.OK);
}
if (recordChangedMessages.hasCorrelationId()) {
this.requestInfo.getHeaders().put(DpsHeaders.CORRELATION_ID, recordChangedMessages.getCorrelationId());
}
populateCorrelationIdIfExist(recordChangedMessages);
verifyDataPartitionId(recordChangedMessages);
if (recordChangedMessages.missingAccountId()) {
throw new AppException(org.apache.http.HttpStatus.SC_BAD_REQUEST, "Invalid tenant",
String.format("Required header: '%s' not found", DpsHeaders.DATA_PARTITION_ID));
}
try {
Type listType = new TypeToken<List<RecordInfo>>() {}.getType();
List<RecordInfo> recordInfos = new Gson().fromJson(recordChangedMessages.getData(), listType);
......@@ -101,6 +93,19 @@ public class RecordIndexerApi {
}
}
private void verifyDataPartitionId(RecordChangedMessages recordChangedMessages) {
if (recordChangedMessages.missingAccountId()) {
throw new AppException(org.apache.http.HttpStatus.SC_BAD_REQUEST, "Invalid tenant",
String.format("Required header: '%s' not found", DpsHeaders.DATA_PARTITION_ID));
}
}
private void populateCorrelationIdIfExist(RecordChangedMessages recordChangedMessages) {
if (recordChangedMessages.hasCorrelationId()) {
this.requestInfo.getHeaders().put(DpsHeaders.CORRELATION_ID, recordChangedMessages.getCorrelationId());
}
}
// THIS IS AN INTERNAL USE API ONLY
// THAT MEANS WE DON'T DOCUMENT IT IN SWAGGER, ACCESS IS LIMITED TO CLOUD TASK QUEUE CALLS ONLY
@PostMapping("/reindex-worker")
......
......@@ -55,7 +55,7 @@ public class BooleanFeatureFlagClient {
PartitionInfo partitionInfo = partitionProvider.get(dataPartitionId);
return partitionInfo;
} catch (PartitionException e) {
logger.error(String.format("Error getting partition info for data-partition: %s", dataPartitionId), e);
logger.error(String.format("Error getting partition info for data-partition: %s. Message: %s. ResponseCode: %s.", dataPartitionId, e.getResponse().getBody(), e.getResponse().getResponseCode()), e);
throw e;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment