Skip to content

Commit

Permalink
logging statements
Browse files Browse the repository at this point in the history
  • Loading branch information
MikelAlejoBR committed Aug 12, 2024
1 parent ae1d7c7 commit 449e94d
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,14 @@ public void processDailyEmail() {
aggregationOrgConfigRepository.createMissingDefaultConfiguration(defaultDailyDigestTime);
List<AggregationCommand> aggregationCommands = processAggregateEmailsWithOrgPref(now, registry);
Log.infof("found %s commands", aggregationCommands.size());
Log.debugf("Aggregation commands: %s", aggregationCommands);

aggregationCommands.stream().collect(Collectors.groupingBy(AggregationCommand::getOrgId))
.values().forEach(this::sendIt);

List<String> orgIdsToUpdate = aggregationCommands.stream().map(agc -> agc.getAggregationKey().getOrgId()).collect(Collectors.toList());
Log.debugf("Found following org IDs to update: %s", orgIdsToUpdate);

aggregationOrgConfigRepository.updateLastCronJobRunAccordingOrgPref(orgIdsToUpdate, now);

Gauge lastSuccess = Gauge
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.redhat.cloud.notifications.processors.webhooks.WebhookTypeProcessor;
import io.micrometer.core.instrument.Counter;
import io.micrometer.core.instrument.MeterRegistry;
import io.quarkus.logging.Log;
import jakarta.annotation.PostConstruct;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
Expand Down Expand Up @@ -89,7 +90,11 @@ public void process(Event event) {

endpoints = List.of(endpoint);
} else if (isAggregatorEvent(event)) {
Log.debugf("[org_id: %s] Processing aggregation event: %s", event.getOrgId(), event);

endpoints = List.of(endpointRepository.getOrCreateDefaultSystemSubscription(event.getAccountId(), event.getOrgId(), EndpointType.EMAIL_SUBSCRIPTION));

Log.debugf("[org_id: %s] Found %s endpoints for the aggregation event: %s", event.getOrgId(), endpoints.size(), event);
} else {
endpoints = endpointRepository.getTargetEndpoints(event.getOrgId(), event.getEventType());
}
Expand Down Expand Up @@ -124,8 +129,10 @@ public void process(Event event) {
break;
case EMAIL_SUBSCRIPTION:
if (isAggregatorEvent(event)) {
Log.debugf("[org_id: %s] Sending event through the aggregator processor: %s", event.getOrgId(), event);
emailAggregationProcessor.processAggregation(event);
} else {
Log.debugf("[org_id: %s] Sending event through the email connector: %s", event.getOrgId(), event);
emailConnectorProcessor.process(event, endpointsByTypeEntry.getValue());
}
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ public CompletionStage<Void> process(Message<String> message) {
* The message ID is already known which means we already processed the current
* message and sent notifications. The message is therefore ignored.
*/
Log.debugf(" [kafka_message_id: %s] Duplicated Kafka message ignored", messageId);
duplicateCounter.increment();
} else {
/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ private void processBundleAggregation(List<AggregationCommand> aggregationComman
Map<User, List<ApplicationAggregatedData>> userData = new HashMap<>();

for (AggregationCommand applicationAggregationCommand : aggregationCommands) {
Log.debugf("Processing aggregation command: %s", applicationAggregationCommand);

try {
Application app = applicationRepository.getApplication(applicationAggregationCommand.getAggregationKey().getBundle(), applicationAggregationCommand.getAggregationKey().getApplication())
.orElseThrow(() -> {
Expand All @@ -289,6 +291,8 @@ private void processBundleAggregation(List<AggregationCommand> aggregationComman
Map<List<ApplicationAggregatedData>, Set<User>> usersWithSameAggregatedData = userData.keySet().stream()
.collect(Collectors.groupingBy(userData::get, Collectors.toSet()));

Log.debugf("Users with same aggregated data: %s", usersWithSameAggregatedData);

String emailTitle = "Daily digest - " + bundle.getDisplayName();

// for each set of users, generate email subject + body and send it to email connector
Expand Down Expand Up @@ -348,6 +352,8 @@ private void processBundleAggregation(List<AggregationCommand> aggregationComman
);

connectorSender.send(aggregatorEvent, endpoint, JsonObject.mapFrom(emailNotification));

Log.debugf("Sent email notification to connector: %s", emailNotification);
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ public void process(final Event event, final List<Endpoint> endpoints) {
externalAuthorizationCriteriaExtractor.extract(event)
);

Log.debugf("[org_id: %s] Sending email notification to connector", emailNotification);

final JsonObject payload = JsonObject.mapFrom(emailNotification);

final Endpoint endpoint = endpointRepository.getOrCreateDefaultSystemSubscription(event.getAccountId(), event.getOrgId(), EMAIL_SUBSCRIPTION);
Expand Down

0 comments on commit 449e94d

Please sign in to comment.