Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix: log ERROR ActivityLog when reporting Health.down
  • Loading branch information
johnBgood committed May 4, 2026
commit ce6d6add3a01920032f2f3ea751da3873ba252ef
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ public void reportHealth(Health health) {
String.format(
"Health status changed to %s, details: %s",
health.getStatus(), health.getDetails()))
.withSeverity(health.getStatus() == Health.Status.UP ? Severity.INFO : Severity.ERROR)
.andReportHealth(health)
.build();
// append the activity log to store the health status change history
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@

import com.fasterxml.jackson.databind.ObjectMapper;
import io.camunda.connector.api.annotation.FEEL;
import io.camunda.connector.api.inbound.ActivityLogTag;
import io.camunda.connector.api.inbound.Health;
import io.camunda.connector.api.inbound.Severity;
import io.camunda.connector.api.secret.SecretProvider;
import io.camunda.connector.runtime.core.FooBarSecretProvider;
import io.camunda.connector.runtime.core.TestObjectMapperSupplier;
Expand Down Expand Up @@ -155,6 +158,56 @@ void getProperties_shouldNotParseFeel() {
assertThat(properties.get("stringMap")).isEqualTo("={\"keyString\":null}");
}

@Test
void reportHealth_shouldLogInfoSeverityWhenStatusIsUp() {
// given
var definition = getInboundConnectorDefinition(Map.of());
var health = Health.up();
InboundConnectorContextImpl inboundConnectorContext =
new InboundConnectorContextImpl(
secretProvider, (e) -> {}, definition, null, (e) -> {}, mapper, activityLogRegistry);

// when
inboundConnectorContext.reportHealth(health);

// then
var logs =
activityLogRegistry.getLogs(ExecutableId.fromDeduplicationId(definition.deduplicationId()));
assertThat(logs)
.singleElement()
.satisfies(
log -> {
assertThat(log.tag()).isEqualTo(ActivityLogTag.HEALTH);
assertThat(log.healthChange()).isEqualTo(health);
assertThat(log.severity()).isEqualTo(Severity.INFO);
});
}

@Test
void reportHealth_shouldLogErrorSeverityWhenStatusIsDown() {
// given
var definition = getInboundConnectorDefinition(Map.of());
var health = Health.down();
InboundConnectorContextImpl inboundConnectorContext =
new InboundConnectorContextImpl(
secretProvider, (e) -> {}, definition, null, (e) -> {}, mapper, activityLogRegistry);

// when
inboundConnectorContext.reportHealth(health);

// then
var logs =
activityLogRegistry.getLogs(ExecutableId.fromDeduplicationId(definition.deduplicationId()));
assertThat(logs)
.singleElement()
.satisfies(
log -> {
assertThat(log.tag()).isEqualTo(ActivityLogTag.HEALTH);
assertThat(log.healthChange()).isEqualTo(health);
assertThat(log.severity()).isEqualTo(Severity.ERROR);
});
}

private TestPropertiesClass createTestClass() {
TestPropertiesClass testClass = new TestPropertiesClass();
testClass.setStringMap(Map.of("keyString", "valueString"));
Expand Down
Loading