forked from digma-ai/otel-sample-app-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
Description
Issue Description
An ArithmeticException is occurring in the ClinicActivityDataService when calculating active logs ratio due to potential division by zero.
Current Behavior
- The
getActiveLogsRatiomethod performs division without checking for zero denominator - No input validation for null parameters
- Lacks proper error handling and logging
- Can throw ArithmeticException when no logs exist for a type
Root Cause
The method doesn't validate inputs or handle edge cases properly, leading to division by zero when no logs exist for a given type.
Solution
A fix has been implemented in PR that:
- Adds null check for type parameter
- Adds zero denominator check
- Implements proper error handling
- Adds comprehensive logging
- Returns 0.0 as default when division by zero would occur
Impact
This issue affects clinic activity reporting and could cause service disruption when calculating ratios for types with no logs.
Testing
The fix has been tested for:
- Null input handling
- Zero denominator cases
- Valid ratio calculations
- Proper logging output
Additional Notes
- Consider adding monitoring alerts for division by zero attempts
- Review other similar calculations for potential arithmetic exceptions