From 0ecff875eff8e02539df05d7ddace8f0a5b5ec09 Mon Sep 17 00:00:00 2001 From: Marcus Bitzl Date: Tue, 26 Sep 2023 15:41:30 +0200 Subject: [PATCH 1/2] Fix missing log fields --- .../framework/config/FlusswerkConfiguration.java | 2 +- .../framework/reporting/DefaultProcessReport.java | 10 ++++++---- .../framework/reporting/DefaultProcessReportTest.java | 3 ++- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/framework/src/main/java/com/github/dbmdz/flusswerk/framework/config/FlusswerkConfiguration.java b/framework/src/main/java/com/github/dbmdz/flusswerk/framework/config/FlusswerkConfiguration.java index 233aa775..c186ee25 100644 --- a/framework/src/main/java/com/github/dbmdz/flusswerk/framework/config/FlusswerkConfiguration.java +++ b/framework/src/main/java/com/github/dbmdz/flusswerk/framework/config/FlusswerkConfiguration.java @@ -129,7 +129,7 @@ public List workers( metrics, messageBroker, processReport.orElseGet( - () -> new DefaultProcessReport(appProperties.name())), + () -> new DefaultProcessReport(appProperties.name(), tracing)), taskQueue, tracing)) .collect( diff --git a/framework/src/main/java/com/github/dbmdz/flusswerk/framework/reporting/DefaultProcessReport.java b/framework/src/main/java/com/github/dbmdz/flusswerk/framework/reporting/DefaultProcessReport.java index abdc2e07..d976d01b 100644 --- a/framework/src/main/java/com/github/dbmdz/flusswerk/framework/reporting/DefaultProcessReport.java +++ b/framework/src/main/java/com/github/dbmdz/flusswerk/framework/reporting/DefaultProcessReport.java @@ -14,14 +14,16 @@ public class DefaultProcessReport implements ProcessReport { private static final Logger LOGGER = LoggerFactory.getLogger(DefaultProcessReport.class); private final String name; + private final Tracing tracing; - public DefaultProcessReport(String name) { + public DefaultProcessReport(String name, Tracing tracing) { this.name = requireNonNull(name); + this.tracing = requireNonNull(tracing); } @Override public void reportSuccess(Message message) { - LOGGER.info("{} successful", name); + LOGGER.info("{} successful", name, keyValue("tracing", tracing.tracingPath())); } @Override @@ -64,7 +66,7 @@ public void reportRetry(Message message, RuntimeException e) { name, e.getMessage(), keyValue("amqp_message", message.toString()), - keyValue("exception", e.toString())); + e); } @Override @@ -79,7 +81,7 @@ public void reportComplexRetry(Message message, RetryProcessingException e) { messagesSent, e.getMessage(), keyValue("amqp_message", message.toString()), - keyValue("exception", e.toString())); + e); } @Override diff --git a/framework/src/test/java/com/github/dbmdz/flusswerk/framework/reporting/DefaultProcessReportTest.java b/framework/src/test/java/com/github/dbmdz/flusswerk/framework/reporting/DefaultProcessReportTest.java index 6d200571..ad125f67 100644 --- a/framework/src/test/java/com/github/dbmdz/flusswerk/framework/reporting/DefaultProcessReportTest.java +++ b/framework/src/test/java/com/github/dbmdz/flusswerk/framework/reporting/DefaultProcessReportTest.java @@ -1,6 +1,7 @@ package com.github.dbmdz.flusswerk.framework.reporting; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; import ch.qos.logback.classic.Level; import ch.qos.logback.classic.Logger; @@ -29,7 +30,7 @@ void setUp() { listAppender.setContext((LoggerContext) LoggerFactory.getILoggerFactory()); listAppender.start(); logger.addAppender(listAppender); - defaultProcessReport = new DefaultProcessReport("testapp"); + defaultProcessReport = new DefaultProcessReport("testapp", mock(Tracing.class)); } @DisplayName("should report success") From 761c47c578a3b3fe452438616b71fa83db64ef43 Mon Sep 17 00:00:00 2001 From: Marcus Bitzl Date: Tue, 26 Sep 2023 16:06:59 +0200 Subject: [PATCH 2/2] Remove extra field --- .../flusswerk/framework/reporting/DefaultProcessReport.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/framework/src/main/java/com/github/dbmdz/flusswerk/framework/reporting/DefaultProcessReport.java b/framework/src/main/java/com/github/dbmdz/flusswerk/framework/reporting/DefaultProcessReport.java index d976d01b..8d348edb 100644 --- a/framework/src/main/java/com/github/dbmdz/flusswerk/framework/reporting/DefaultProcessReport.java +++ b/framework/src/main/java/com/github/dbmdz/flusswerk/framework/reporting/DefaultProcessReport.java @@ -34,7 +34,6 @@ public void reportFail(Message message, StopProcessingException e) { name, e.getMessage(), keyValue("amqp_message", message.toString()), - keyValue("exception", e.toString()), e); } @@ -46,7 +45,6 @@ public void reportFailAfterMaxRetries(Message message, Exception e) { name, e.getMessage(), keyValue("amqp_message", message.toString()), - keyValue("exception", e.toString()), e); }