Check alarm status node: added tenant and ruleChainName to the log to make a log useful in multi-tenant deployments
This commit is contained in:
parent
2efd411a36
commit
add2bea56a
@ -80,9 +80,9 @@ public class TbCheckAlarmStatusNode implements TbNode {
|
||||
}, ctx.getDbCallbackExecutor());
|
||||
} catch (Exception e) {
|
||||
if (e instanceof IllegalArgumentException || e instanceof NullPointerException) {
|
||||
log.debug("Failed to parse alarm: [{}] error [{}]", msg.getData(), e.getMessage());
|
||||
log.debug("[{}][{}] Failed to parse alarm: [{}] error [{}]", ctx.getTenantId(), ctx.getRuleChainName(), msg.getData(), e.getMessage());
|
||||
} else {
|
||||
log.error("Failed to parse alarm: [{}]", msg.getData(), e);
|
||||
log.error("[{}][{}] Failed to parse alarm: [{}]", ctx.getTenantId(), ctx.getRuleChainName(), msg.getData(), e);
|
||||
}
|
||||
throw new TbNodeException(e);
|
||||
}
|
||||
|
||||
@ -41,6 +41,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.BDDMockito.willReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.times;
|
||||
@ -163,6 +164,7 @@ class TbCheckAlarmStatusNodeTest {
|
||||
void givenUnparseableAlarm_whenOnMsg_then_Failure() {
|
||||
String msgData = "{\"Number\":1113718,\"id\":8.1}";
|
||||
TbMsg msg = getTbMsg(msgData);
|
||||
willReturn("Default Rule Chain").given(ctx).getRuleChainName();
|
||||
|
||||
assertThatThrownBy(() -> node.onMsg(ctx, msg))
|
||||
.as("onMsg")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user