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

Adding logs to analyse OTP generation API 5xx issue in production #69

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions service/src/main/java/org/sunbird/actor/otp/OTPActor.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ else if (ActorOperations.VERIFY_OTP_V3.getValue().equals(request.getOperation())
}

private void generateOTP(Request request) {
logger.debug(request.getRequestContext(), "OTPActor:generateOTP method call start.");
logger.info(request.getRequestContext(), "OTPActor:generateOTP method call start.");
Copy link
Collaborator

Choose a reason for hiding this comment

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

the logs are unnecessary in this class

String type = (String) request.getRequest().get(JsonKey.TYPE);
String key = (String) request.getRequest().get(JsonKey.KEY);
String userId = (String) request.getRequest().get(JsonKey.USER_ID);
logger.info(request.getRequestContext(), "Received request with type = " + type + ", key = " + key + ", userId = " + userId);
if (StringUtils.isNotBlank(userId)) {
key = otpService.getEmailPhoneByUserId(userId, type, request.getRequestContext());
type = getType(type);
Expand All @@ -79,16 +80,18 @@ private void generateOTP(Request request) {
+ " ,key = "
+ OTPUtil.maskId(key, type));
}

logger.info(request.getRequestContext(), "Proceeding to rate limit check for key = " + OTPUtil.maskId(key, type));
rateLimitService.throttleByKey(
key,
type,
new RateLimiter[] {OtpRateLimiter.HOUR, OtpRateLimiter.DAY},
request.getRequestContext());

logger.info(request.getRequestContext(), "Rate limiting check passed for key = " + OTPUtil.maskId(key, type));
String otp;
Map<String, Object> details = otpService.getOTPDetails(type, key, request.getRequestContext());

logger.info(request.getRequestContext(), "Fetched OTP details for key = " + OTPUtil.maskId(key, type));
if (MapUtils.isEmpty(details)) {
otp = OTPUtil.generateOTP(request.getRequestContext());
logger.info(
Expand All @@ -110,8 +113,12 @@ private void generateOTP(Request request) {
logger.info(
request.getRequestContext(),
"OTPActor:sendOTP : Calling SendOTPActor for Key = " + OTPUtil.maskId(key, type));
sendOTP(request, otp, key, request.getRequestContext());

try {
sendOTP(request, otp, key, request.getRequestContext());
Copy link
Collaborator

Choose a reason for hiding this comment

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

this method doesn't return any exception - why try catch here

logger.info(request.getRequestContext(), "OTP Send Successfully for type = " + type + ", key = " + key + ", userId = " + userId);
} catch (Exception e){
logger.error("Failed to send OTP : "+e.getMessage(),e);
}
Response response = new Response();
response.put(JsonKey.RESPONSE, JsonKey.SUCCESS);
sender().tell(response, self());
Expand Down
Loading