SlideShare a Scribd company logo
1 of 47
Download to read offline
LOGS IN CODE
MODEN APPLICATION
Jannarong Wadthong


1/Sept/2020
▸ Part I — Software Development and S.O.L.I.D ~ 10 mins


▸ Part II — Logs in Code ~ 30 mins


▸ Part III — Logs in Architecture ~ 15 mins


▸ Part IV — Log Framework ~ xx mins
SOFTWARE DEVELOPMENT
AND S.O.L.D
PART I
S.O.L.I.D
S.O.L.I.D
S.O.L.I.D
TEXT
MAINTAINABILITY CAN BE QUANTIFIED:
▸ Extensibility — how hard is it to add features


▸ Stability — how hard is it to make changes?


▸ Understandability — how hard is it for someone else to pick
up your code?
S.O.L.I.D
12 PRINCIPLES BEHIND THE AGILE MANIFESTO
HOW TO AVOID TECHNICAL DEBT?
▸ Avoid code smells as you go, and practice regular
refactoring. Don’t Repeat Yourself (DRY), use clear &
consistent variable & method names, practice Test Driven
Development (TDD), follow the Single Responsibility
Principle (SRP), avoid long/complex methods, and
maintain thin interfaces / don’t hard-code


▸ Conduct code reviews.


▸ Use automated testing.
LOGS IN CODE
PART II
PUBLIC VS INTERNAL BANKING API
▸ Transfer Money API


▸ Deposit Money API


▸ Withdrawal Money API
TEXT
PUBLIC TRANSFER MONEY FLOW
CONTROLLER ACCEPTS
REQUEST
CONTROLLER ACK BACK TO USER
CHECK BALANCE WITHDRAW DEPOSIT
CHECK
AUTHORISATION
TEXT
INTERNAL TRANSFER MONEY FLOW
CONTROLLER ACCEPTS
REQUEST
CONTROLLER ACK BACK TO USER
CHECK BALANCE WITHDRAW DEPOSIT
INTERNAL TRANSFER
void transfer(Account fromAcc, Account toAcc, int amount) throws Exception {


if (fromAcc.getBalance() < amount)


throw new InsufficientFundsException();




fromAcc.withdraw(amount);


toAcc.deposit(amount);


}
PUBLIC TRANSFER
void transfer(Account fromAcc, Account toAcc, int amount, User user) throws Exception {




if (!isUserAuthorised(user, fromAcc)) {


logger.info("User has no permission.");


throw new UnauthorisedUserException();


}




if (fromAcc.getBalance() < amount) {


logger.info("Insufficient funds.");


throw new InsufficientFundsException();


}


fromAcc.withdraw(amount);


toAcc.deposit(amount);


}
PUBLIC TRANSFER WITH PERFORMANCE LOGGING
void transfer(Account fromAcc, Account toAcc, int amount, User user) throws Exception {


long startTime = currentTime();


if (!isUserAuthorised(user, fromAcc)) {


logger.info("User has no permission.");


throw new UnauthorisedUserException();


}




if (fromAcc.getBalance() < amount) {


logger.info("Insufficient funds.");


throw new InsufficientFundsException();


}


fromAcc.withdraw(amount);


toAcc.deposit(amount);


long endTime = currentTime();


logger.info("Execution time:" + (endTime - startTime);


}
S.O.L.I.D
S.O.L.I.D — HOW?
TEXT
WITHDRAW MONEY
CONTROLLER
CHECK BALANCE
DO WITHDRAW
CHECK AUTHORISATION
CONTROLLER
CHECK BALANCE
DO WITHDRAW
START TIME
END TIME
START TIME
END TIME
TEXT
DEPOSIT MONEY
CONTROLLER
DO DEPOSIT
CHECK AUTHORISATION
CONTROLLER
DO DEPOSIT
START TIME
END TIME
START TIME
END TIME
TEXT
TRANSFER MONEY
CONTROLLER
CHECK BALANCE
WITHDRAW
CHECK AUTHORISATION
DEPOSIT
START TIME
END TIME
CONTROLLER
CHECK BALANCE
WITHDRAW
DEPOSIT
START TIME
END TIME
TEXT
WITHDRAW MONEY
CONTROLLER
CHECK BALANCE
DO WITHDRAW
CHECK AUTHORISATION
CONTROLLER
CHECK BALANCE
DO WITHDRAW
START TIME
END TIME
START TIME
END TIME
DO WITHDRAW
TEXT
DEPOSIT MONEY
CONTROLLER
DO DEPOSIT
CHECK AUTHORISATION
CONTROLLER
DO DEPOSIT
START TIME
END TIME
START TIME
END TIME
DO DEPOSIT
ALL PUBLIC API
WITHDRAW
CONTROLLER
CHECK BALANCE
DO WITHDRAW
CHECK AUTHORISATION
START TIME
END TIME
CONTROLLER
CHECK BALANCE
DO WITHDRAW
CHECK AUTHORISATION
START TIME
END TIME
CONTROLLER
DO DEPOSIT
CHECK AUTHORISATION
START TIME
END TIME
CONTROLLER
CHECK BALANCE
WITHDRAW
CHECK AUTHORISATION
DEPOSIT
START TIME
END TIME
DEPOSIT TRANSFER
ALL PUBLIC API
WITHDRAW
CONTROLLER
CHECK BALANCE
DO WITHDRAW
CHECK AUTHORISATION
START TIME
END TIME
CONTROLLER
CHECK BALANCE
DO WITHDRAW
CHECK AUTHORISATION
START TIME
END TIME
CONTROLLER
DO DEPOSIT
CHECK AUTHORISATION
START TIME
END TIME
CONTROLLER
CHECK BALANCE
WITHDRAW
CHECK AUTHORISATION
DEPOSIT
START TIME
END TIME
DEPOSIT TRANSFER
PERFORMANCE LOGGING CONCERN
ALL PUBLIC API
WITHDRAW
CONTROLLER
CHECK BALANCE
DO WITHDRAW
CHECK AUTHORISATION
START TIME
END TIME
CONTROLLER
CHECK BALANCE
DO WITHDRAW
CHECK AUTHORISATION
START TIME
END TIME
CONTROLLER
DO DEPOSIT
CHECK AUTHORISATION
START TIME
END TIME
CONTROLLER
CHECK BALANCE
WITHDRAW
CHECK AUTHORISATION
DEPOSIT
START TIME
END TIME
DEPOSIT TRANSFER
PERFORMANCE LOGGING CONCERN SECURITY CONCERN
PROBLEM HAVING LOGS IN CODE
PROBLEM HAVING LOGS IN CODE
PROBLEM HAVING LOGS IN CODE
PROBLEM HAVING LOGS IN CODE
CODE TANGLING AND CODE SCATTERING
WITHDRAW
CONTROLLER
CHECK BALANCE
DO WITHDRAW
CHECK AUTHORISATION
START TIME
END TIME
CONTROLLER
CHECK BALANCE
DO WITHDRAW
CHECK AUTHORISATION
START TIME
END TIME
CONTROLLER
DO DEPOSIT
CHECK AUTHORISATION
START TIME
END TIME
CONTROLLER
CHECK BALANCE
WITHDRAW
CHECK AUTHORISATION
DEPOSIT
START TIME
END TIME
DEPOSIT TRANSFER
PERFORMANCE LOGGING CONCERN SECURITY CONCERN
CODE TANGLING AND CODE SCATTERING
WITHDRAW
CONTROLLER
CHECK BALANCE
DO WITHDRAW
CONTROLLER
CHECK BALANCE
DO WITHDRAW
CONTROLLER
DO DEPOSIT
CONTROLLER
CHECK BALANCE
WITHDRAW
DEPOSIT
DEPOSIT TRANSFER
PERFORMANCE LOGGING ASPECT SECURITY ASPECT
WE WANT THIS
@LogExecutionTime


@Authorize


void transfer(Account fromAcc, Account toAcc, int amount, User user) throws Exception {


checkBalance(fromAcc);


fromAcc.withdraw(amount);


toAcc.deposit(amount);


}
TEXT
AOP IMPLEMENTATION: DYNAMIC PROXY
@Aspect


Performance Logging Proxy


1.start time


2.end time
ATMController Target Service
+ transfer()


+ withdraw()


+ deposit()
As you can see from that diagram, the proxy has one job.
• Opening and closing times.
• And then delegating to the real target service, the one we wrote.
• And ATMController will never know that they are talking to a proxy, and not the real thing.
2 MARKERS: @BEFORE AND @AFTER
OR 1 MARKER: @AROUND
TEXT
AOP IMPLEMENTATION
@Aspect


Authorisation Proxy


1.check if user is valid


ATMController Real ATMService
+ transfer()


+ withdraw()


+ deposit()
1 MARKER: @BEFORE
TEXT
ASPECT
@Aspect
public class PerformanceAspect {
@Around("@annotation(LogExecutionTime)")
public Object logExecutionTime(ProceedingJoinPoint joinPoint) throws Throwable {
long start = System.currentTimeMillis();
Object proceed = joinPoint.proceed();
long executionTime = System.currentTimeMillis() - start;
log.info(joinPoint.getSignature() + " executed in " + executionTime + "ms");
return proceed;
}
}
LOGS IN ARCHITECTURE
PART III
This slide is intentionally left blank :)
TEXT
LOGS IN ACTION
▸ Troubleshooting


▸ Law


▸ User behaviours
TEXT
PUBLIC TRANSFER MONEY FLOW
TEXT
LOG FRAMEWORK: IMPLEMENTATION
LOG
HARDDISK
STOUT REST API
DATABASE
TEXT FILE
PROMETHEUS GRAFANA
TEXT
TEXT
TEXT
SUMMARY
Begin/End Transaction


Transaction Error Hand
TEXT
THANK YOU

More Related Content

What's hot

JavaScript promise
JavaScript promiseJavaScript promise
JavaScript promiseeslam_me
 
Smart Contract programming 101 with Solidity #PizzaHackathon
Smart Contract programming 101 with Solidity #PizzaHackathonSmart Contract programming 101 with Solidity #PizzaHackathon
Smart Contract programming 101 with Solidity #PizzaHackathonSittiphol Phanvilai
 
Demoiselle 2.0 no JavaOne Brasil 2010
Demoiselle 2.0 no JavaOne Brasil 2010Demoiselle 2.0 no JavaOne Brasil 2010
Demoiselle 2.0 no JavaOne Brasil 2010Cleverson Sacramento
 
The Ring programming language version 1.7 book - Part 85 of 196
The Ring programming language version 1.7 book - Part 85 of 196The Ring programming language version 1.7 book - Part 85 of 196
The Ring programming language version 1.7 book - Part 85 of 196Mahmoud Samir Fayed
 
Java Script Promise
Java Script PromiseJava Script Promise
Java Script PromiseAlok Guha
 
Xtext @ Profict Summer Camp
Xtext @ Profict Summer CampXtext @ Profict Summer Camp
Xtext @ Profict Summer CampSven Efftinge
 
VISUALIZAR REGISTROS EN UN JTABLE
VISUALIZAR REGISTROS EN UN JTABLEVISUALIZAR REGISTROS EN UN JTABLE
VISUALIZAR REGISTROS EN UN JTABLEDarwin Durand
 
JavaOne 2013: Java 8 - The Good Parts
JavaOne 2013: Java 8 - The Good PartsJavaOne 2013: Java 8 - The Good Parts
JavaOne 2013: Java 8 - The Good PartsKonrad Malawski
 
Reactive programming with RxSwift
Reactive programming with RxSwiftReactive programming with RxSwift
Reactive programming with RxSwiftScott Gardner
 
Functional Reactive Programming - RxSwift
Functional Reactive Programming - RxSwiftFunctional Reactive Programming - RxSwift
Functional Reactive Programming - RxSwiftRodrigo Leite
 
Declaring friend function with inline code
Declaring friend function with inline codeDeclaring friend function with inline code
Declaring friend function with inline codeRajeev Sharan
 
Trisha gee concurrentprogrammingusingthedisruptor
Trisha gee concurrentprogrammingusingthedisruptorTrisha gee concurrentprogrammingusingthedisruptor
Trisha gee concurrentprogrammingusingthedisruptorEthanTu
 
Async js - Nemetschek Presentaion @ HackBulgaria
Async js - Nemetschek Presentaion @ HackBulgariaAsync js - Nemetschek Presentaion @ HackBulgaria
Async js - Nemetschek Presentaion @ HackBulgariaHackBulgaria
 
The account problem in Java and Clojure
The account problem in Java and ClojureThe account problem in Java and Clojure
The account problem in Java and ClojureAlf Kristian Støyle
 

What's hot (19)

JavaScript promise
JavaScript promiseJavaScript promise
JavaScript promise
 
Smart Contract programming 101 with Solidity #PizzaHackathon
Smart Contract programming 101 with Solidity #PizzaHackathonSmart Contract programming 101 with Solidity #PizzaHackathon
Smart Contract programming 101 with Solidity #PizzaHackathon
 
Demoiselle 2.0 no JavaOne Brasil 2010
Demoiselle 2.0 no JavaOne Brasil 2010Demoiselle 2.0 no JavaOne Brasil 2010
Demoiselle 2.0 no JavaOne Brasil 2010
 
The Ring programming language version 1.7 book - Part 85 of 196
The Ring programming language version 1.7 book - Part 85 of 196The Ring programming language version 1.7 book - Part 85 of 196
The Ring programming language version 1.7 book - Part 85 of 196
 
Java Script Promise
Java Script PromiseJava Script Promise
Java Script Promise
 
Clojure workshop
Clojure workshopClojure workshop
Clojure workshop
 
Xtext @ Profict Summer Camp
Xtext @ Profict Summer CampXtext @ Profict Summer Camp
Xtext @ Profict Summer Camp
 
VISUALIZAR REGISTROS EN UN JTABLE
VISUALIZAR REGISTROS EN UN JTABLEVISUALIZAR REGISTROS EN UN JTABLE
VISUALIZAR REGISTROS EN UN JTABLE
 
JavaOne 2013: Java 8 - The Good Parts
JavaOne 2013: Java 8 - The Good PartsJavaOne 2013: Java 8 - The Good Parts
JavaOne 2013: Java 8 - The Good Parts
 
Reactive programming with RxSwift
Reactive programming with RxSwiftReactive programming with RxSwift
Reactive programming with RxSwift
 
Functional Reactive Programming - RxSwift
Functional Reactive Programming - RxSwiftFunctional Reactive Programming - RxSwift
Functional Reactive Programming - RxSwift
 
Rxjs ppt
Rxjs pptRxjs ppt
Rxjs ppt
 
Introduction to typescript
Introduction to typescriptIntroduction to typescript
Introduction to typescript
 
Oop assignment 02
Oop assignment 02Oop assignment 02
Oop assignment 02
 
Declaring friend function with inline code
Declaring friend function with inline codeDeclaring friend function with inline code
Declaring friend function with inline code
 
ES2015 promise
ES2015 promiseES2015 promise
ES2015 promise
 
Trisha gee concurrentprogrammingusingthedisruptor
Trisha gee concurrentprogrammingusingthedisruptorTrisha gee concurrentprogrammingusingthedisruptor
Trisha gee concurrentprogrammingusingthedisruptor
 
Async js - Nemetschek Presentaion @ HackBulgaria
Async js - Nemetschek Presentaion @ HackBulgariaAsync js - Nemetschek Presentaion @ HackBulgaria
Async js - Nemetschek Presentaion @ HackBulgaria
 
The account problem in Java and Clojure
The account problem in Java and ClojureThe account problem in Java and Clojure
The account problem in Java and Clojure
 

Similar to Logging in code

Introduction to aop
Introduction to aopIntroduction to aop
Introduction to aopDror Helper
 
A Journey with React
A Journey with ReactA Journey with React
A Journey with ReactFITC
 
Rajeev oops 2nd march
Rajeev oops 2nd marchRajeev oops 2nd march
Rajeev oops 2nd marchRajeev Sharan
 
Dependency injection - the right way
Dependency injection - the right wayDependency injection - the right way
Dependency injection - the right wayThibaud Desodt
 
Formal Verification of Web Service Interaction Contracts
Formal Verification of Web Service Interaction ContractsFormal Verification of Web Service Interaction Contracts
Formal Verification of Web Service Interaction ContractsGera Shegalov
 
Inversion Of Control
Inversion Of ControlInversion Of Control
Inversion Of ControlChad Hietala
 
Working effectively with legacy code
Working effectively with legacy codeWorking effectively with legacy code
Working effectively with legacy codeShriKant Vashishtha
 
Stanfy MadCode Meetup #11: Why do you need to switch from Obj-C to Swift, or ...
Stanfy MadCode Meetup #11: Why do you need to switch from Obj-C to Swift, or ...Stanfy MadCode Meetup #11: Why do you need to switch from Obj-C to Swift, or ...
Stanfy MadCode Meetup #11: Why do you need to switch from Obj-C to Swift, or ...Stanfy
 
Taming event-driven software via formal verification
Taming event-driven software via formal verificationTaming event-driven software via formal verification
Taming event-driven software via formal verificationAdaCore
 
README.MD for building the first purely digital mobile bank in Indonesia
README.MD for building the first purely digital mobile bank in Indonesia README.MD for building the first purely digital mobile bank in Indonesia
README.MD for building the first purely digital mobile bank in Indonesia Richard Radics
 
Formal Verification of Transactional Interaction Contract
Formal Verification of Transactional Interaction ContractFormal Verification of Transactional Interaction Contract
Formal Verification of Transactional Interaction ContractGera Shegalov
 
Ruslan Platonov - Transactions
Ruslan Platonov - TransactionsRuslan Platonov - Transactions
Ruslan Platonov - TransactionsDmitry Buzdin
 
Test First Refresh Second: Test-Driven Development in Grails
Test First Refresh Second: Test-Driven Development in GrailsTest First Refresh Second: Test-Driven Development in Grails
Test First Refresh Second: Test-Driven Development in GrailsTim Berglund
 
Advanced iOS Debbuging (Reloaded)
Advanced iOS Debbuging (Reloaded)Advanced iOS Debbuging (Reloaded)
Advanced iOS Debbuging (Reloaded)Massimo Oliviero
 
Test First, Refresh Second: Web App TDD in Grails
Test First, Refresh Second: Web App TDD in GrailsTest First, Refresh Second: Web App TDD in Grails
Test First, Refresh Second: Web App TDD in GrailsTim Berglund
 
Developing ASP.NET Applications Using the Model View Controller Pattern
Developing ASP.NET Applications Using the Model View Controller PatternDeveloping ASP.NET Applications Using the Model View Controller Pattern
Developing ASP.NET Applications Using the Model View Controller Patterngoodfriday
 
Reactive programming every day
Reactive programming every dayReactive programming every day
Reactive programming every dayVadym Khondar
 
How to perform debounce in react
How to perform debounce in reactHow to perform debounce in react
How to perform debounce in reactBOSC Tech Labs
 
Aspect-Oriented Programming
Aspect-Oriented ProgrammingAspect-Oriented Programming
Aspect-Oriented ProgrammingAndrey Bratukhin
 

Similar to Logging in code (20)

Introduction to aop
Introduction to aopIntroduction to aop
Introduction to aop
 
A Journey with React
A Journey with ReactA Journey with React
A Journey with React
 
Rajeev oops 2nd march
Rajeev oops 2nd marchRajeev oops 2nd march
Rajeev oops 2nd march
 
Dependency injection - the right way
Dependency injection - the right wayDependency injection - the right way
Dependency injection - the right way
 
Formal Verification of Web Service Interaction Contracts
Formal Verification of Web Service Interaction ContractsFormal Verification of Web Service Interaction Contracts
Formal Verification of Web Service Interaction Contracts
 
Inversion Of Control
Inversion Of ControlInversion Of Control
Inversion Of Control
 
Working effectively with legacy code
Working effectively with legacy codeWorking effectively with legacy code
Working effectively with legacy code
 
Stanfy MadCode Meetup #11: Why do you need to switch from Obj-C to Swift, or ...
Stanfy MadCode Meetup #11: Why do you need to switch from Obj-C to Swift, or ...Stanfy MadCode Meetup #11: Why do you need to switch from Obj-C to Swift, or ...
Stanfy MadCode Meetup #11: Why do you need to switch from Obj-C to Swift, or ...
 
Taming event-driven software via formal verification
Taming event-driven software via formal verificationTaming event-driven software via formal verification
Taming event-driven software via formal verification
 
README.MD for building the first purely digital mobile bank in Indonesia
README.MD for building the first purely digital mobile bank in Indonesia README.MD for building the first purely digital mobile bank in Indonesia
README.MD for building the first purely digital mobile bank in Indonesia
 
Formal Verification of Transactional Interaction Contract
Formal Verification of Transactional Interaction ContractFormal Verification of Transactional Interaction Contract
Formal Verification of Transactional Interaction Contract
 
Ruslan Platonov - Transactions
Ruslan Platonov - TransactionsRuslan Platonov - Transactions
Ruslan Platonov - Transactions
 
Test First Refresh Second: Test-Driven Development in Grails
Test First Refresh Second: Test-Driven Development in GrailsTest First Refresh Second: Test-Driven Development in Grails
Test First Refresh Second: Test-Driven Development in Grails
 
Advanced iOS Debbuging (Reloaded)
Advanced iOS Debbuging (Reloaded)Advanced iOS Debbuging (Reloaded)
Advanced iOS Debbuging (Reloaded)
 
Test First, Refresh Second: Web App TDD in Grails
Test First, Refresh Second: Web App TDD in GrailsTest First, Refresh Second: Web App TDD in Grails
Test First, Refresh Second: Web App TDD in Grails
 
Developing ASP.NET Applications Using the Model View Controller Pattern
Developing ASP.NET Applications Using the Model View Controller PatternDeveloping ASP.NET Applications Using the Model View Controller Pattern
Developing ASP.NET Applications Using the Model View Controller Pattern
 
Reactive programming every day
Reactive programming every dayReactive programming every day
Reactive programming every day
 
How to perform debounce in react
How to perform debounce in reactHow to perform debounce in react
How to perform debounce in react
 
Aspect-Oriented Programming
Aspect-Oriented ProgrammingAspect-Oriented Programming
Aspect-Oriented Programming
 
ELEVATE Paris
ELEVATE ParisELEVATE Paris
ELEVATE Paris
 

Recently uploaded

why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 

Recently uploaded (20)

why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 

Logging in code

  • 1. LOGS IN CODE MODEN APPLICATION Jannarong Wadthong 1/Sept/2020
  • 2. ▸ Part I — Software Development and S.O.L.I.D ~ 10 mins ▸ Part II — Logs in Code ~ 30 mins ▸ Part III — Logs in Architecture ~ 15 mins ▸ Part IV — Log Framework ~ xx mins
  • 7. TEXT MAINTAINABILITY CAN BE QUANTIFIED: ▸ Extensibility — how hard is it to add features ▸ Stability — how hard is it to make changes? ▸ Understandability — how hard is it for someone else to pick up your code?
  • 9. 12 PRINCIPLES BEHIND THE AGILE MANIFESTO
  • 10. HOW TO AVOID TECHNICAL DEBT? ▸ Avoid code smells as you go, and practice regular refactoring. Don’t Repeat Yourself (DRY), use clear & consistent variable & method names, practice Test Driven Development (TDD), follow the Single Responsibility Principle (SRP), avoid long/complex methods, and maintain thin interfaces / don’t hard-code ▸ Conduct code reviews. ▸ Use automated testing.
  • 12. PUBLIC VS INTERNAL BANKING API ▸ Transfer Money API ▸ Deposit Money API ▸ Withdrawal Money API
  • 13. TEXT PUBLIC TRANSFER MONEY FLOW CONTROLLER ACCEPTS REQUEST CONTROLLER ACK BACK TO USER CHECK BALANCE WITHDRAW DEPOSIT CHECK AUTHORISATION
  • 14. TEXT INTERNAL TRANSFER MONEY FLOW CONTROLLER ACCEPTS REQUEST CONTROLLER ACK BACK TO USER CHECK BALANCE WITHDRAW DEPOSIT
  • 15. INTERNAL TRANSFER void transfer(Account fromAcc, Account toAcc, int amount) throws Exception { if (fromAcc.getBalance() < amount) throw new InsufficientFundsException(); fromAcc.withdraw(amount); toAcc.deposit(amount); }
  • 16. PUBLIC TRANSFER void transfer(Account fromAcc, Account toAcc, int amount, User user) throws Exception { if (!isUserAuthorised(user, fromAcc)) { logger.info("User has no permission."); throw new UnauthorisedUserException(); } if (fromAcc.getBalance() < amount) { logger.info("Insufficient funds."); throw new InsufficientFundsException(); } fromAcc.withdraw(amount); toAcc.deposit(amount); }
  • 17. PUBLIC TRANSFER WITH PERFORMANCE LOGGING void transfer(Account fromAcc, Account toAcc, int amount, User user) throws Exception { long startTime = currentTime(); if (!isUserAuthorised(user, fromAcc)) { logger.info("User has no permission."); throw new UnauthorisedUserException(); } if (fromAcc.getBalance() < amount) { logger.info("Insufficient funds."); throw new InsufficientFundsException(); } fromAcc.withdraw(amount); toAcc.deposit(amount); long endTime = currentTime(); logger.info("Execution time:" + (endTime - startTime); }
  • 20. TEXT WITHDRAW MONEY CONTROLLER CHECK BALANCE DO WITHDRAW CHECK AUTHORISATION CONTROLLER CHECK BALANCE DO WITHDRAW START TIME END TIME START TIME END TIME
  • 21. TEXT DEPOSIT MONEY CONTROLLER DO DEPOSIT CHECK AUTHORISATION CONTROLLER DO DEPOSIT START TIME END TIME START TIME END TIME
  • 22. TEXT TRANSFER MONEY CONTROLLER CHECK BALANCE WITHDRAW CHECK AUTHORISATION DEPOSIT START TIME END TIME CONTROLLER CHECK BALANCE WITHDRAW DEPOSIT START TIME END TIME
  • 23. TEXT WITHDRAW MONEY CONTROLLER CHECK BALANCE DO WITHDRAW CHECK AUTHORISATION CONTROLLER CHECK BALANCE DO WITHDRAW START TIME END TIME START TIME END TIME DO WITHDRAW
  • 24. TEXT DEPOSIT MONEY CONTROLLER DO DEPOSIT CHECK AUTHORISATION CONTROLLER DO DEPOSIT START TIME END TIME START TIME END TIME DO DEPOSIT
  • 25. ALL PUBLIC API WITHDRAW CONTROLLER CHECK BALANCE DO WITHDRAW CHECK AUTHORISATION START TIME END TIME CONTROLLER CHECK BALANCE DO WITHDRAW CHECK AUTHORISATION START TIME END TIME CONTROLLER DO DEPOSIT CHECK AUTHORISATION START TIME END TIME CONTROLLER CHECK BALANCE WITHDRAW CHECK AUTHORISATION DEPOSIT START TIME END TIME DEPOSIT TRANSFER
  • 26. ALL PUBLIC API WITHDRAW CONTROLLER CHECK BALANCE DO WITHDRAW CHECK AUTHORISATION START TIME END TIME CONTROLLER CHECK BALANCE DO WITHDRAW CHECK AUTHORISATION START TIME END TIME CONTROLLER DO DEPOSIT CHECK AUTHORISATION START TIME END TIME CONTROLLER CHECK BALANCE WITHDRAW CHECK AUTHORISATION DEPOSIT START TIME END TIME DEPOSIT TRANSFER PERFORMANCE LOGGING CONCERN
  • 27. ALL PUBLIC API WITHDRAW CONTROLLER CHECK BALANCE DO WITHDRAW CHECK AUTHORISATION START TIME END TIME CONTROLLER CHECK BALANCE DO WITHDRAW CHECK AUTHORISATION START TIME END TIME CONTROLLER DO DEPOSIT CHECK AUTHORISATION START TIME END TIME CONTROLLER CHECK BALANCE WITHDRAW CHECK AUTHORISATION DEPOSIT START TIME END TIME DEPOSIT TRANSFER PERFORMANCE LOGGING CONCERN SECURITY CONCERN
  • 32. CODE TANGLING AND CODE SCATTERING WITHDRAW CONTROLLER CHECK BALANCE DO WITHDRAW CHECK AUTHORISATION START TIME END TIME CONTROLLER CHECK BALANCE DO WITHDRAW CHECK AUTHORISATION START TIME END TIME CONTROLLER DO DEPOSIT CHECK AUTHORISATION START TIME END TIME CONTROLLER CHECK BALANCE WITHDRAW CHECK AUTHORISATION DEPOSIT START TIME END TIME DEPOSIT TRANSFER PERFORMANCE LOGGING CONCERN SECURITY CONCERN
  • 33. CODE TANGLING AND CODE SCATTERING WITHDRAW CONTROLLER CHECK BALANCE DO WITHDRAW CONTROLLER CHECK BALANCE DO WITHDRAW CONTROLLER DO DEPOSIT CONTROLLER CHECK BALANCE WITHDRAW DEPOSIT DEPOSIT TRANSFER PERFORMANCE LOGGING ASPECT SECURITY ASPECT
  • 34. WE WANT THIS @LogExecutionTime @Authorize void transfer(Account fromAcc, Account toAcc, int amount, User user) throws Exception { checkBalance(fromAcc); fromAcc.withdraw(amount); toAcc.deposit(amount); }
  • 35. TEXT AOP IMPLEMENTATION: DYNAMIC PROXY @Aspect 
 Performance Logging Proxy 1.start time 2.end time ATMController Target Service + transfer() + withdraw() + deposit() As you can see from that diagram, the proxy has one job. • Opening and closing times. • And then delegating to the real target service, the one we wrote. • And ATMController will never know that they are talking to a proxy, and not the real thing. 2 MARKERS: @BEFORE AND @AFTER OR 1 MARKER: @AROUND
  • 36. TEXT AOP IMPLEMENTATION @Aspect 
 Authorisation Proxy 1.check if user is valid ATMController Real ATMService + transfer() + withdraw() + deposit() 1 MARKER: @BEFORE
  • 37. TEXT ASPECT @Aspect public class PerformanceAspect { @Around("@annotation(LogExecutionTime)") public Object logExecutionTime(ProceedingJoinPoint joinPoint) throws Throwable { long start = System.currentTimeMillis(); Object proceed = joinPoint.proceed(); long executionTime = System.currentTimeMillis() - start; log.info(joinPoint.getSignature() + " executed in " + executionTime + "ms"); return proceed; } }
  • 39. This slide is intentionally left blank :)
  • 40. TEXT LOGS IN ACTION ▸ Troubleshooting ▸ Law ▸ User behaviours
  • 42. TEXT LOG FRAMEWORK: IMPLEMENTATION LOG HARDDISK STOUT REST API DATABASE TEXT FILE PROMETHEUS GRAFANA
  • 43. TEXT
  • 44. TEXT
  • 45. TEXT