Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SWATCH-2903 Marketplace throws vague error when handling Default api exception #3782

Merged
merged 1 commit into from
Oct 1, 2024

Conversation

kartikshahc
Copy link
Contributor

@kartikshahc kartikshahc commented Sep 24, 2024

Jira issue: SWATCH-2903

Description

Testing

IQE Test MR:

Setup

  1. Run azure app
SERVER_PORT=8004 WIREMOCK_HOSTNAME=localhost ENABLE_AZURE_DRY_RUN=false SWATCH_INTERNAL_SUBSCRIPTION_ENDPOINT=http://localhost:8000 QUARKUS_PROFILE=dev,wiremock ./gradlew :swatch-producer-azure:quarkusDev

Steps

  1. Send kafka message using producer billable-usage-hourly-aggregate
{"windowTimestamp":"2023-12-21T01:10:28Z","aggregateId": "e81bc918-6434-4a58-9192-8a8dd73ec8fb","aggregateKey": {"orgId": "org123","billingProvider": "azure","metricId": "CORES","productId": "rosa"}, "remittanceUuids": ["d125f119-0c98-43f2-a5de-ccf2e8e1ab55"]}

Verification

  1. Logs
2024-09-23 23:48:10,154 WARN  [com.red.swa.azu.ser.AzureBillableUsageAggregateConsumer] (vert.x-worker-thread-1) Subscription not found for for aggregateId=e81bc918-6434-4a58-9192-8a8dd73ec8fb orgId=org123 remittanceUUIDs=[d125f119-0c98-43f2-a5de-ccf2e8e1ab55]: com.redhat.swatch.azure.exception.SubscriptionCanNotBeDeterminedException: SUBSCRIPTION_CANNOT_BE_DETERMINED
        at com.redhat.swatch.azure.service.AzureBillableUsageAggregateConsumer.lookupAzureUsageContext(AzureBillableUsageAggregateConsumer.java:263)
        at com.redhat.swatch.azure.service.AzureBillableUsageAggregateConsumer_Subclass.lookupAzureUsageContext$$superforward(Unknown Source)
        at com.redhat.swatch.azure.service.AzureBillableUsageAggregateConsumer_Subclass$$function$$1.apply(Unknown Source)
        at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:73)
        at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:62)
        at io.smallrye.faulttolerance.FaultToleranceInterceptor.lambda$syncFlow$3(FaultToleranceInterceptor.java:267)

@kartikshahc kartikshahc added Dev Pull requests that need developer review QE Unneeded Pull request does not need QE approval labels Sep 24, 2024
@kflahert kflahert self-requested a review September 24, 2024 13:01
@kflahert kflahert self-assigned this Sep 24, 2024
billableUsageAggregate.getAggregateId(),
billableUsageAggregate.getAggregateKey().getOrgId(),
billableUsageAggregate.getRemittanceUuids(),
e);
emitErrorStatusOnUsage(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would move the "log.warn" statement to be done in "emitErrorStatusOnUsage".
Also, I don't think we need to print again the exception since this is already done in another log trace, and both logs use the same trace_id.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Sgitario I think the current way of handling exception is appropriate. If you observe that there are multiple log.warn and a log.error message preceding emitErrorStatusOnUsage. I have the option of removing all of them and implementing a unified log.warn, such as log.warn("Skipping billable usage with id={} orgId={} remittanceUUIDs={}) in the method emitErrorStatusOnUsage. However, this appears to be an inappropriate approach to me since I want log.error for usage not found and also little bit of customization in other logs. Additionally, I eliminated the printing exception in local; however, the line number of the caller method and class are not getting printed. It just prints com.redhat.swatch.azure.exception.DefaultApiException: Hence I am keeping the same implementation. Let me know if you have thoughts on this.

@mstead
Copy link
Contributor

mstead commented Sep 27, 2024

/retest

…exception

Signed-off-by: Kartik Shah <karshah@redhat.com>
@kartikshahc kartikshahc merged commit 75c9417 into main Oct 1, 2024
8 of 9 checks passed
@kartikshahc kartikshahc deleted the SWATCH-2903 branch October 1, 2024 15:36
@kartikshahc kartikshahc added Dev/approved Pull requests that have been approved by all assigned developers and removed Dev Pull requests that need developer review labels Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dev/approved Pull requests that have been approved by all assigned developers QE Unneeded Pull request does not need QE approval
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants