diff --git a/swatch-billable-usage/src/main/java/com/redhat/swatch/billable/usage/admin/api/InternalBillableUsageController.java b/swatch-billable-usage/src/main/java/com/redhat/swatch/billable/usage/admin/api/InternalBillableUsageController.java index 2582125b69..2701fb2646 100644 --- a/swatch-billable-usage/src/main/java/com/redhat/swatch/billable/usage/admin/api/InternalBillableUsageController.java +++ b/swatch-billable-usage/src/main/java/com/redhat/swatch/billable/usage/admin/api/InternalBillableUsageController.java @@ -95,6 +95,7 @@ public long processRetries(OffsetDateTime asOf) { List remittances = remittanceRepository.findByRetryAfterLessThan(asOf); for (BillableUsageRemittanceEntity remittance : remittances) { + log.info("Processing retry of remittance {}", remittance); // re-trigger billable usage billingProducer.produce(toBillableUsage(remittance)); // reset the retry after column diff --git a/swatch-billable-usage/src/main/java/com/redhat/swatch/billable/usage/services/BillableUsageStatusConsumer.java b/swatch-billable-usage/src/main/java/com/redhat/swatch/billable/usage/services/BillableUsageStatusConsumer.java index 86668a5167..db1cd29580 100644 --- a/swatch-billable-usage/src/main/java/com/redhat/swatch/billable/usage/services/BillableUsageStatusConsumer.java +++ b/swatch-billable-usage/src/main/java/com/redhat/swatch/billable/usage/services/BillableUsageStatusConsumer.java @@ -59,6 +59,7 @@ public void process(BillableUsageAggregate billableUsageAggregate) { } private void updateStatus(BillableUsageAggregate billableUsageAggregate) { + log.info("Updating status for aggregate: {}", billableUsageAggregate); var status = RemittanceStatus.fromString(billableUsageAggregate.getStatus().value()); var errorCode = ofNullable(billableUsageAggregate.getErrorCode()) diff --git a/swatch-producer-aws/src/main/java/com/redhat/swatch/aws/service/AwsBillableUsageAggregateConsumer.java b/swatch-producer-aws/src/main/java/com/redhat/swatch/aws/service/AwsBillableUsageAggregateConsumer.java index 29dc31b7d8..c310eecad5 100644 --- a/swatch-producer-aws/src/main/java/com/redhat/swatch/aws/service/AwsBillableUsageAggregateConsumer.java +++ b/swatch-producer-aws/src/main/java/com/redhat/swatch/aws/service/AwsBillableUsageAggregateConsumer.java @@ -127,21 +127,14 @@ public void process(BillableUsageAggregate billableUsageAggregate) { } catch (SubscriptionCanNotBeDeterminedException e) { if (!isUsageDateValid(Clock.systemUTC(), billableUsageAggregate)) { log.warn( - "Skipping billable usage with id={} orgId={} remittanceUUIDs={} because the subscription was not found and the snapshot '{}' is past the aws time window of '{}'", - billableUsageAggregate.getAggregateId(), - billableUsageAggregate.getAggregateKey().getOrgId(), - billableUsageAggregate.getRemittanceUuids(), + "Skipping billable usage aggregate {} because the subscription was not found and the snapshot '{}' is past the aws time window of '{}'", + billableUsageAggregate, billableUsageAggregate.getWindowTimestamp(), awsUsageWindow, e); emitErrorStatusOnUsage(billableUsageAggregate, BillableUsage.ErrorCode.INACTIVE); } else { - log.warn( - "Subscription not found for for aggregateId={} orgId={} remittanceUUIDs={}", - billableUsageAggregate.getAggregateId(), - billableUsageAggregate.getAggregateKey().getOrgId(), - billableUsageAggregate.getRemittanceUuids(), - e); + log.warn("Subscription not found for for aggregate={}", billableUsageAggregate, e); emitRetryableStatusOnUsage( billableUsageAggregate, BillableUsage.ErrorCode.SUBSCRIPTION_NOT_FOUND); } @@ -149,21 +142,11 @@ public void process(BillableUsageAggregate billableUsageAggregate) { } catch (SubscriptionRecentlyTerminatedException e) { emitErrorStatusOnUsage( billableUsageAggregate, BillableUsage.ErrorCode.SUBSCRIPTION_TERMINATED); - log.info( - "Subscription recently terminated for billableUsageAggregateId={} orgId={} remittanceUUIDs={}", - billableUsageAggregate.getAggregateId(), - billableUsageAggregate.getAggregateKey().getOrgId(), - billableUsageAggregate.getRemittanceUuids(), - e); + log.info("Subscription recently terminated for aggregate={}", billableUsageAggregate, e); return; } catch (AwsUsageContextLookupException e) { emitErrorStatusOnUsage(billableUsageAggregate, BillableUsage.ErrorCode.USAGE_CONTEXT_LOOKUP); - log.error( - "Error looking up aws usage context for aggregateId={} orgId={} remittanceUUIDs={}", - billableUsageAggregate.getAggregateId(), - billableUsageAggregate.getAggregateKey().getOrgId(), - billableUsageAggregate.getRemittanceUuids(), - e); + log.error("Error looking up aws usage context for aggregate={}", billableUsageAggregate, e); return; } try { @@ -172,41 +155,32 @@ public void process(BillableUsageAggregate billableUsageAggregate) { } catch (UsageTimestampOutOfBoundsException e) { emitErrorStatusOnUsage(billableUsageAggregate, BillableUsage.ErrorCode.REDUNDANT); log.warn( - "{} orgId={} remittanceUUIDs={} aggregateId={} productId={} windowTimestamp={} rhSubscriptionId={} awsCustomerId={} awsProductCode={} subscriptionStartDate={} value={}", + "{} aggregate={}, rhSubscriptionId={} awsCustomerId={} awsProductCode={} subscriptionStartDate={}", e.getMessage(), - billableUsageAggregate.getAggregateKey().getOrgId(), - billableUsageAggregate.getRemittanceUuids(), - billableUsageAggregate.getAggregateId(), - billableUsageAggregate.getAggregateKey().getProductId(), - billableUsageAggregate.getWindowTimestamp(), + billableUsageAggregate, context.getRhSubscriptionId(), context.getCustomerId(), context.getProductCode(), - context.getSubscriptionStartDate(), - billableUsageAggregate.getTotalValue()); + context.getSubscriptionStartDate()); ignoreCounter.increment(); } catch (AwsThrottlingException e) { emitRetryableStatusOnUsage( billableUsageAggregate, BillableUsage.ErrorCode.MARKETPLACE_RATE_LIMIT); log.error( - "Error sending aws usage due to rate limit for rhSubscriptionId={} aggregateId={} awsCustomerId={} awsProductCode={} orgId={} remittanceUUIDs={}", + "Error sending aws usage due to rate limit for rhSubscriptionId={} aggregate={} awsCustomerId={} awsProductCode={}", context.getRhSubscriptionId(), - billableUsageAggregate.getAggregateId(), + billableUsageAggregate, context.getCustomerId(), context.getProductCode(), - billableUsageAggregate.getAggregateKey().getOrgId(), - billableUsageAggregate.getRemittanceUuids(), e); } catch (Exception e) { emitErrorStatusOnUsage(billableUsageAggregate, BillableUsage.ErrorCode.UNKNOWN); log.error( - "Error sending aws usage for rhSubscriptionId={} aggregateId={} awsCustomerId={} awsProductCode={} orgId={} remittanceUUIDs={}", + "Error sending aws usage for rhSubscriptionId={} aggregate={} awsCustomerId={} awsProductCode={}", context.getRhSubscriptionId(), - billableUsageAggregate.getAggregateId(), + billableUsageAggregate, context.getCustomerId(), context.getProductCode(), - billableUsageAggregate.getAggregateKey().getOrgId(), - billableUsageAggregate.getRemittanceUuids(), e); } } @@ -254,19 +228,12 @@ private void transformAndSend( if (isDryRun.isPresent() && Boolean.TRUE.equals(isDryRun.get())) { log.info( - "[DRY RUN] Sending usage request to AWS: {}, organization={}, remittanceUUIDs={}, product_id={}", + "[DRY RUN] Sending usage request to AWS: {}, aggregate={}", request, - billableUsageAggregate.getAggregateKey().getOrgId(), - billableUsageAggregate.getRemittanceUuids(), - billableUsageAggregate.getAggregateKey().getProductId()); + billableUsageAggregate); return; } else { - log.info( - "Sending usage request to AWS: {}, organization={}, remittanceUUIDs={}, product_id={}", - request, - billableUsageAggregate.getAggregateKey().getOrgId(), - billableUsageAggregate.getRemittanceUuids(), - billableUsageAggregate.getAggregateKey().getProductId()); + log.info("Sending usage request to AWS: {}, aggregate={}", request, billableUsageAggregate); } try { @@ -280,23 +247,13 @@ private void transformAndSend( result -> { if (result.status() == UsageRecordResultStatus.CUSTOMER_NOT_SUBSCRIBED) { log.warn( - "No subscription found for organization={}, remittanceUUIDs={} product_id={}, result={}", - billableUsageAggregate.getAggregateKey().getOrgId(), - billableUsageAggregate.getRemittanceUuids(), - billableUsageAggregate.getAggregateKey().getProductId(), + "No subscription found for aggregate={}, result={}", + billableUsageAggregate, result); } else if (result.status() != UsageRecordResultStatus.SUCCESS) { - log.warn( - "{}, organization={} remittanceUUIDs={}", - result, - billableUsageAggregate.getAggregateKey().getOrgId(), - billableUsageAggregate.getRemittanceUuids()); + log.warn("{}, aggregate={}", result, billableUsageAggregate); } else { - log.info( - "{}, organization={}, remittanceUUIDs={},", - result, - billableUsageAggregate.getAggregateKey().getOrgId(), - billableUsageAggregate.getRemittanceUuids()); + log.info("{}, aggregate={}", result, billableUsageAggregate); acceptedCounter.increment(response.results().size()); } }); @@ -312,10 +269,9 @@ private void transformAndSend( throw new AwsUnprocessedRecordsException(request.usageRecords().size(), e); } catch (AwsMissingCredentialsException e) { log.warn( - "{} for organization={}, remittanceUUIDs={}, awsCustomerId={}", + "{} for aggregate={}, awsCustomerId={}", e.getMessage(), - billableUsageAggregate.getAggregateKey().getOrgId(), - billableUsageAggregate.getRemittanceUuids(), + billableUsageAggregate, context.getCustomerId()); } } diff --git a/swatch-producer-azure/src/main/java/com/redhat/swatch/azure/service/AzureBillableUsageAggregateConsumer.java b/swatch-producer-azure/src/main/java/com/redhat/swatch/azure/service/AzureBillableUsageAggregateConsumer.java index bc641443ae..fb43093aab 100644 --- a/swatch-producer-azure/src/main/java/com/redhat/swatch/azure/service/AzureBillableUsageAggregateConsumer.java +++ b/swatch-producer-azure/src/main/java/com/redhat/swatch/azure/service/AzureBillableUsageAggregateConsumer.java @@ -124,42 +124,28 @@ public void process(BillableUsageAggregate billableUsageAggregate) { emitErrorStatusOnUsage( billableUsageAggregate, BillableUsage.ErrorCode.SUBSCRIPTION_TERMINATED); log.info( - "Subscription recently terminated for billableUsageAggregateId={} orgId={} remittanceUUIDs={}", - billableUsageAggregate.getAggregateId(), - billableUsageAggregate.getAggregateKey().getOrgId(), - billableUsageAggregate.getRemittanceUuids(), + "Subscription recently terminated for billableUsageAggregate={}", + billableUsageAggregate, e); return; } catch (SubscriptionCanNotBeDeterminedException e) { if (!isUsageDateValid(billableUsageAggregate)) { log.warn( - "Skipping billable usage with id={} orgId={} remittanceUUIDs={} because the subscription was not found and the snapshot '{}' is past the azure time window of '{}'", - billableUsageAggregate.getAggregateId(), - billableUsageAggregate.getAggregateKey().getOrgId(), - billableUsageAggregate.getRemittanceUuids(), + "Skipping billable usage aggregate={} because the subscription was not found and the snapshot '{}' is past the azure time window of '{}'", + billableUsageAggregate, billableUsageAggregate.getWindowTimestamp(), azureUsageWindow, e); emitErrorStatusOnUsage(billableUsageAggregate, BillableUsage.ErrorCode.INACTIVE); } else { - log.warn( - "Subscription not found for for aggregateId={} orgId={} remittanceUUIDs={}", - billableUsageAggregate.getAggregateId(), - billableUsageAggregate.getAggregateKey().getOrgId(), - billableUsageAggregate.getRemittanceUuids(), - e); + log.warn("Subscription not found for for aggregate={}", billableUsageAggregate, e); emitRetryableStatusOnUsage( billableUsageAggregate, BillableUsage.ErrorCode.SUBSCRIPTION_NOT_FOUND); } return; } catch (AzureUsageContextLookupException e) { emitErrorStatusOnUsage(billableUsageAggregate, BillableUsage.ErrorCode.USAGE_CONTEXT_LOOKUP); - log.error( - "Error looking up usage context for aggregateId={} orgId={} remittanceUUIDs={}", - billableUsageAggregate.getAggregateId(), - billableUsageAggregate.getAggregateKey().getOrgId(), - billableUsageAggregate.getRemittanceUuids(), - e); + log.error("Error looking up usage context for aggregate={}", billableUsageAggregate, e); return; } try { @@ -168,11 +154,9 @@ public void process(BillableUsageAggregate billableUsageAggregate) { } catch (Exception e) { emitErrorStatusOnUsage(billableUsageAggregate, BillableUsage.ErrorCode.UNKNOWN); log.error( - "Error sending azure usage for aggregateId={} azureResourceId={} orgId={} remittanceUUIDs={}", - billableUsageAggregate.getAggregateId(), + "Error sending azure usage for aggregate={}, azureResourceId={}", + billableUsageAggregate, context.getAzureResourceId(), - billableUsageAggregate.getAggregateKey().getOrgId(), - billableUsageAggregate.getRemittanceUuids(), e); } } @@ -191,36 +175,24 @@ private void transformAndSend( var usageEvent = transformToAzureUsage(context, billableUsageAggregate, metric); if (isDryRun.isPresent() && Boolean.TRUE.equals(isDryRun.get())) { log.info( - "[DRY RUN] Sending usage request to Azure: {}, organization={}, remittanceUUIDs={}, product_id={}", + "[DRY RUN] Sending usage request to Azure: {}, for aggregate={}", usageEvent, - billableUsageAggregate.getAggregateKey().getOrgId(), - billableUsageAggregate.getRemittanceUuids(), - billableUsageAggregate.getAggregateKey().getProductId()); + billableUsageAggregate); return; } else { log.info( - "Sending usage request to Azure: {}, organization={}, remittanceUUIDs={}, product_id={}", + "Sending usage request to Azure: {}, for aggregate={}", usageEvent, - billableUsageAggregate.getAggregateKey().getOrgId(), - billableUsageAggregate.getRemittanceUuids(), - billableUsageAggregate.getAggregateKey().getProductId()); + billableUsageAggregate); } try { var response = azureMarketplaceService.sendUsageEventToAzureMarketplace(usageEvent); log.debug("{}", response); if (response.getStatus() != UsageEventStatusEnum.ACCEPTED) { - log.warn( - "{}, organization={}, remittanceUUIDs={}", - response, - billableUsageAggregate.getAggregateKey().getOrgId(), - billableUsageAggregate.getRemittanceUuids()); + log.warn("{}, aggregate={}", response, billableUsageAggregate); } else { - log.info( - "{}, organization={}, remittanceUUIDs={},", - response, - billableUsageAggregate.getAggregateKey().getOrgId(), - billableUsageAggregate.getRemittanceUuids()); + log.info("{}, aggregate={}", response, billableUsageAggregate); acceptedCounter.increment(); } } catch (AzureMarketplaceRequestFailedException e) {