forked from Sunbird-Lern/userorg-service
-
Notifications
You must be signed in to change notification settings - Fork 16
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
sreeragksgh
wants to merge
1
commit into
sunbird-cb:cbrelease-4.8.12
from
sreeragksgh:cbrelease-4.8.12_OTPLogs
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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."); | ||
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); | ||
|
@@ -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( | ||
|
@@ -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()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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()); | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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