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

Improve reporting

Update dependency.
parent cb4d5746
Pipeline #21600 passed with stages
in 4 minutes and 2 seconds
...@@ -33,7 +33,7 @@ ext { ...@@ -33,7 +33,7 @@ ext {
dependencies { dependencies {
implementation 'ch.memobase:memobase-kafka-utils:0.2.3' implementation 'ch.memobase:memobase-kafka-utils:0.2.3'
implementation 'org.memobase:memobase-service-utilities:2.0.5' implementation 'org.memobase:memobase-service-utilities:2.0.5'
implementation 'ch.memobase:mapper-service-configuration:1.0.2' implementation 'ch.memobase:mapper-service-configuration:1.0.3'
// Logging Framework // Logging Framework
implementation "org.apache.logging.log4j:log4j-api:${log4jV}" implementation "org.apache.logging.log4j:log4j-api:${log4jV}"
implementation "org.apache.logging.log4j:log4j-core:${log4jV}" implementation "org.apache.logging.log4j:log4j-core:${log4jV}"
......
...@@ -45,7 +45,7 @@ class KafkaTopology( ...@@ -45,7 +45,7 @@ class KafkaTopology(
private val settings: SettingsLoader private val settings: SettingsLoader
) { ) {
private val log = LogManager.getLogger("KafkaTopology") private val log = LogManager.getLogger("MappingProcessor")
private val reportTopic = settings.processReportTopic private val reportTopic = settings.processReportTopic
private val klaxon = Klaxon() private val klaxon = Klaxon()
...@@ -75,7 +75,7 @@ class KafkaTopology( ...@@ -75,7 +75,7 @@ class KafkaTopology(
configJoiner.join(stream, configStream) configJoiner.join(stream, configStream)
val handledStream = joinedStream val handledStream = joinedStream
.mapValues { readOnlyKey, value -> handleExceptions(value) } .mapValues { value -> handleExceptions(value) }
.branch( .branch(
Predicate { _, value -> value.third != "" }, Predicate { _, value -> value.third != "" },
Predicate { _, _ -> true } Predicate { _, _ -> true }
...@@ -173,7 +173,7 @@ class KafkaTopology( ...@@ -173,7 +173,7 @@ class KafkaTopology(
val noRecordId = hasRecordId[1] val noRecordId = hasRecordId[1]
noRecordId noRecordId
.mapValues { key, _ -> Report(key, ReportStatus.fatal, "No record id found for record $key.", Service.step).toJson() } .mapValues { key, value -> Report(key, ReportStatus.fatal, value.errorMessage, Service.step).toJson() }
.to(reportTopic) .to(reportTopic)
return hasRecordId[0] return hasRecordId[0]
...@@ -190,11 +190,11 @@ class KafkaTopology( ...@@ -190,11 +190,11 @@ class KafkaTopology(
val noRecordTypeValue = hasRecordTypeValue[1] val noRecordTypeValue = hasRecordTypeValue[1]
noRecordTypeValue noRecordTypeValue
.mapValues { key, _ -> .mapValues { key, value ->
Report( Report(
key, key,
ReportStatus.fatal, ReportStatus.fatal,
"No correct record type found for record $key.", value.errorMessage,
Service.step Service.step
).toJson() ).toJson()
} }
...@@ -209,7 +209,7 @@ class KafkaTopology( ...@@ -209,7 +209,7 @@ class KafkaTopology(
result.first, result.first,
Pair( Pair(
result.second, result.second,
Report(result.first, ReportStatus.success, "Successfully mapped record with id ${result.first}.", Service.step) Report(result.first, ReportStatus.success, "", Service.step)
) )
) )
} }
...@@ -230,7 +230,7 @@ class KafkaTopology( ...@@ -230,7 +230,7 @@ class KafkaTopology(
Triple(parsedSource, mapperConfiguration.get(), null) Triple(parsedSource, mapperConfiguration.get(), null)
} else { } else {
log.error("Parsed source is empty: ${value.first}.") log.error("Parsed source is empty: ${value.first}.")
Triple(null, null, Report(key, ReportStatus.fatal, "Found empty source document.", Service.step)) Triple(null, null, Report(key, ReportStatus.fatal, "Could not parse source document.", Service.step))
} }
} catch (ex: InvalidMappingException) { } catch (ex: InvalidMappingException) {
log.error(ex.localizedMessage) log.error(ex.localizedMessage)
......
...@@ -195,7 +195,7 @@ class IntegrationTests { ...@@ -195,7 +195,7 @@ class IntegrationTests {
Report( Report(
"https://memobase.ch/record/test-record-set-id-ID_1", "https://memobase.ch/record/test-record-set-id-ID_1",
"SUCCESS", "SUCCESS",
"Successfully mapped record with id https://memobase.ch/record/test-record-set-id-ID_1.", "",
Service.step Service.step
) )
)/*, )/*,
......
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