Commit bf30b185 authored by Jonas Waeber's avatar Jonas Waeber
Browse files

Improve logging and reporting

parent bbc99f13
Pipeline #24587 passed with stages
in 4 minutes and 3 seconds
......@@ -109,7 +109,7 @@ class BulkProcessor(
if (message != null) {
if (message.startsWith("Unable to parse response body for")) {
val m = "Could not parse response body for bulk upload ${executionId}: $message"
log.error(message)
log.error(m)
producer.sendReport(
Report(
Service.getRandomReportId(),
......@@ -175,7 +175,7 @@ class BulkProcessor(
val records = consumer.consume()
records.forEach {
val report = if (it.key().contains("#update")) {
log.info("Processing query request.")
log.info("Processing query request for ${it.key()} with message ${it.value()}.")
addUpdateByQueryRequest(it)
} else {
log.info("Adding consumer record ${it.key()} to bulk processor.")
......@@ -188,22 +188,30 @@ class BulkProcessor(
}
private fun add(consumerRecord: ConsumerRecord<String, String>): Report {
if (consumerRecord.key() == null) {
Report(
Service.getRandomReportId(),
ReportStatus.fatal,
"Received message without a key: ${consumerRecord.value()}.",
serviceName
)
}
return try {
val recordIndexRequest = ConsumerRecordIndexRequest(consumerRecord, index)
bulk.add(recordIndexRequest)
recordsInBulk += 1
Report(
"",
consumerRecord.key(),
ReportStatus.success,
"",
serviceName
)
} catch (ex: NullPointerException) {
log.error(ex.message, consumerRecord.key())
} catch (ex: Exception) {
log.error("Unknown exception: ${ex.localizedMessage}")
Report(
"None",
consumerRecord.key(),
ReportStatus.fatal,
"No key defined for message.",
"Unknown exception: ${ex.localizedMessage}",
serviceName
)
}
......@@ -247,7 +255,7 @@ class BulkProcessor(
return Report(
consumerRecord.key(),
ReportStatus.fatal,
"Exception: ${ex.localizedMessage}",
"Unknown Exception: ${ex.localizedMessage}",
serviceName
)
}
......
......@@ -32,7 +32,7 @@ class UpdateByQueryListener(
val report = Report(
it.id,
ReportStatus.fatal,
it.message,
"Failed Update: ${it.message}.",
serviceName
)
producer.sendReport(report, null)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment