From a5291ca192fcc39f2eec3db40a2f1c5dc7cef845 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?TATSUNO=20=E2=80=9CTaz=E2=80=9D=20Yasuhiro?= Date: Thu, 5 Nov 2026 12:08:12 +0900 Subject: [PATCH] perf(sns): log each captured push and SMS at debug level (#7569) * perf(sns): log each captured push and SMS at debug level * chore(test): check that pushes and SMS log below INFO --- .../floci/services/sns/SnsService.java | 4 ++-- .../floci/services/sns/SnsMobilePushTest.java | 24 +++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/github/hectorvent/floci/services/sns/SnsService.java b/src/main/java/io/github/hectorvent/floci/services/sns/SnsService.java index 140e0d17f5..6a7871d50a 100644 --- a/src/main/java/io/github/hectorvent/floci/services/sns/SnsService.java +++ b/src/main/java/io/github/hectorvent/floci/services/sns/SnsService.java @@ -1356,7 +1356,7 @@ public class SnsService implements Resettable, ResourceProvider { recordPushNotification(new PushNotification( endpoint.getArn(), app.getArn(), app.getPlatform(), endpoint.getToken(), payload, subject, messageAttributes, messageId, Instant.now())); - LOG.infov("Captured push notification {0} -> {1} ({2})", messageId, endpoint.getArn(), app.getPlatform()); + LOG.debugv("Captured push notification {0} -> {1} ({2})", messageId, endpoint.getArn(), app.getPlatform()); return messageId; } @@ -3031,7 +3031,7 @@ public class SnsService implements Resettable, ResourceProvider { String effectiveRegion = region != null ? region : regionResolver.getDefaultRegion(); SentSms sms = new SentSms(messageId, effectiveRegion, phoneNumber, message, subject, Instant.now()); smsStore.put("sms::" + effectiveRegion + "::" + messageId, sms); - LOG.infov("SNS SMS published: messageId={0} phone={1}", messageId, phoneNumber); + LOG.debugv("SNS SMS published: messageId={0} phone={1}", messageId, phoneNumber); return messageId; } diff --git a/src/test/java/io/github/hectorvent/floci/services/sns/SnsMobilePushTest.java b/src/test/java/io/github/hectorvent/floci/services/sns/SnsMobilePushTest.java index e83e43489a..0c04de0e20 100644 --- a/src/test/java/io/github/hectorvent/floci/services/sns/SnsMobilePushTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/sns/SnsMobilePushTest.java @@ -6,12 +6,15 @@ import io.github.hectorvent.floci.core.storage.InMemoryStorage; import io.github.hectorvent.floci.services.sns.model.PlatformApplication; import io.github.hectorvent.floci.services.sns.model.PlatformEndpoint; import io.github.hectorvent.floci.services.sns.model.PushNotification; +import io.github.hectorvent.floci.testutil.LogCapture; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.util.List; import java.util.Map; import java.util.UUID; +import java.util.logging.Level; +import java.util.logging.LogRecord; import static org.junit.jupiter.api.Assertions.*; @@ -354,6 +357,27 @@ class SnsMobilePushTest { assertTrue(capturedB.get(0).payload().contains("market alert")); } + @Test + void publish_logsEachPushAndSmsBelowInfo() { + PlatformApplication app = snsService.createPlatformApplication("android-app", "GCM", Map.of(), REGION); + PlatformEndpoint endpoint = snsService.createPlatformEndpoint(app.getArn(), "fcm-token", null, Map.of(), REGION); + String topicArn = snsService.createTopic("market-alerts", null, null, REGION).getTopicArn(); + snsService.subscribe(topicArn, "application", endpoint.getArn(), REGION, Map.of()); + + List records = LogCapture.capture(SnsService.class, () -> { + snsService.publish(topicArn, null, null, "to topic", null, null, null, null, null, REGION); + snsService.publish(null, endpoint.getArn(), null, "to endpoint", null, null, null, null, null, REGION); + snsService.publish(null, null, "+15555550100", "to phone", null, null, REGION); + }); + + assertEquals(2, records.stream().filter(r -> r.getMessage().startsWith("Captured push notification")).count()); + assertEquals(1, records.stream().filter(r -> r.getMessage().startsWith("SNS SMS published")).count()); + assertEquals(List.of(), records.stream() + .filter(r -> r.getLevel().intValue() >= Level.INFO.intValue()) + .map(LogRecord::getMessage) + .toList()); + } + @Test void publish_topicBroadcastSkipsDisabledEndpointButDeliversToEnabled() { PlatformApplication app = snsService.createPlatformApplication("android-app", "GCM", Map.of(), REGION);