SlideShare ist ein Scribd-Unternehmen logo
1 von 51
Downloaden Sie, um offline zu lesen
Debugging, Monitoring and
Profiling
Fabrizio Branca
fabrizio (dot) branca (at) aoemedia (dot) de
Twitter: @fbrnc
This talk is…
• sharing some best practices
• sharing some tools with you
• an (incomplete) checklist
• a reminder (hopefully)
Fabrizio Branca
What is this all about?
• Make your website run smoothly!
• during development…
• and when the site is online
• “Smoothly” is
• No bugs (unexpected behaviour)
• Stability
• Performance
Fabrizio Branca
This talk is about
How to…
• avoid errors
• detect errors
• deal with errors
• notify yourself when errors have occurred
Fabrizio Branca
It„s all about bugs
Fabrizio Branca
It„s all about bugs
Everybody creates bugs. Nobody is perfect.
A high percentage of coding time goes into
• searching for bugs
• fixing bugs
Increase your productivity by reducing this time!
Fabrizio Branca
Automating
• Automatize error recognition
• Use proper tools
• Automatize error reporting
• Route detailed error reports into your mailbox
Fabrizio Branca
Bugs
• Avoid bugs
• through programming style
• Spot bugs fast
• “Safety nets”: Unit tests, Assertions
• Detect them before the customer and/or
the website user finds them
Fabrizio Branca
Avoid bugs
• Use a proper IDE
• Syntax checks
• Code Completion
Coding style
• Cover all cases: No if without else!
• Use type hints wherever possible
• Stick to patterns
• Increase crearity
• Convention over configuration
• KISS
• Use object collections
• Make it easier for team members to find and fix bugs
(increase the truck factor) by sticking to coding
guidelines and patterns
Fabrizio Branca
What does PHP offer?
• log_errors
• display_errors
• error_log
Set values in
• php.ini
• .htaccess / vhost configuration
Fabrizio Branca
What does TYPO3 offer?
• devLog, sysLog, Tslog
• devIpMask
• Deprecation log
• Page not found / Page unavailable
• Exception handling
• Error handling
• Debug Console in the BE
Fabrizio Branca
Deal with exceptions (I)
How to react when an exception has
occurred?
• Don„t display any details to the user!
• Send a correct HTTP status code (for
search engines and log files)
$GLOBALS['TSFE']->pageNotFoundAndExit($errorHandlerMessage);
$GLOBALS['TSFE']->pageUnavailableAndExit($errorHandlerMessage);
Fabrizio Branca
Page not found
Fabrizio Branca
Page unavailable
Fabrizio Branca
Deal with exceptions (II)
Handle exceptions within your controllers.
Notify yourself:
• write a message to devLog
• write a message to sysLog
• write a message to TSLog
Fabrizio Branca
Exception Handler
Fabrizio Branca
Bug detection
• Bugs are harder to fix the later they are
detected
• Bugs become harder to diagnose the
further the symptom is removed from the
cause
Fabrizio Branca
Bug detection with assertions
• Make sure that variables contain what you
expect at any time (e.g. after calling a function)
• E.g.: Check incoming parameters for correct
type
• Simple one line call:
tx_pttools_assert::isValidUid($this->params['uid']);
• Throws an exception if assertion is not true
• http://articles.sitepoint.com/article/bug-detection-php-assertions
http://debuggable.com/posts/assert-the-yummyness-of-your-cake:480f4dd6-
7fe0-4113-9776-458acbdd56cb
Fabrizio Branca
Bug detection with assertions
• Assertions are easy to use.
• Don„t assume anything, check it!
• Example: ini_set()
• No substitute for unit tests!
Fabrizio Branca
Bug detection with assertions
See
EXT:pt_tools/res/staticlib/class.tx_pttools_assert.php
or
build your own assert class
Some examples:
• tx_pttools_assert::isValidUid();
• tx_pttools_assert::isNotEmptyString();
Fabrizio Branca
t3lib_div::devLog()
Fabrizio Branca
t3lib_div::sysLog()
Decides by configuration how to handle
syslog messages
• send mail
• write to log file
• write to OS syslog
Fabrizio Branca
Custom SysLog Handler
See
EXT:tcaobjects/res/class.tx_tcaobjects_syslog.php
Fabrizio Branca
SysLog notification mail
msg: Assertion "isValidUid" failed!
extKey: pt_tools
severity: 3
exceptionClass: tx_pttools_exceptionAssertion
debugMsg:
file: /var/www/burghalle/integration/htdocs/typo3conf/ext/aoe_burg/controller/class.tx_aoeburg_controller_extranet.php
line: 78
function: tx_aoeburg_controller_extranet::init
assertType: isValidUid
val:
expected: 1
Server:
TYPO3_REQUEST_URL: http://www.integration.burghalle.aoe-works.de/xtranet/uebersicht/artikel-
bearbeiten/e/typo3conf/ext/burghalle_template/i/white-75.png
HTTP_REFERER: http://www.integration.burghalle.aoe-works.de/xtranet/uebersicht/artikel-bearbeiten/e/saveContent.html
POST: -- none --
COOKIE:
condensed: 0
fe_typo_user: 6b7ccec749891321cb6e7e2fc4c685a4
PHPSESSID: 4b8712f5a4c845029da1f2332cf9132b
Client:
HTTP_USER_AGENT: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.4) Gecko/20100611 Firefox/3.6.4 ( .NET CLR
3.5.30729; .NET4.0C)
Spider: No
REMOTE_HOST: [null]
REMOTE_ADDR: 217.19.187.106
User:
FE_User: aoe
BE_User: -- no user --
Trace: [...]
$TYPO3_DB-
>debug_check_recordset()
• Check all database queries
• Debug_check_recordset takes care of
writing log messages
Fabrizio Branca
TSlog
Fabrizio Branca
$TT->push() / ->pull()
Use the timetrack object to keep track of
what happens in your code.
Fabrizio Branca
Reports module
Fabrizio Branca
Reports module
Write your own reports
Examples:
• Table size
• Outdated extensions (extension manager)
• TCA Integrity
• TCA/database integrity (Like Compare tool)
• Extension integrity (dependencies, conflicts)
• Free disk space
• Server load
Fabrizio Branca
Define a strong api
• Provide interfaces for hooks.
• Allow alternatives (pagerStrategy,
viewClass,…)
Fabrizio Branca
Keep an eye on the logs…
• Webserver
• Apache error log
• PHP error log
• TYPO3
• Log module (Core error handler…)
• Admin Panel
• RealUrl
• error log
• are all paramters encoded?
• Deprecation log
• Reports module
Fabrizio Branca
Keep an eye on the logs…
• External tools
• Google Webmaster Tools
• Wget
• Piwik
• MySQL
• Slow query log
• OS (*nix)
• Syslog
Fabrizio Branca
Log Module
Fabrizio Branca
Google Webmaster Tools
Fabrizio Branca
Let tools do the analysis
• PHP
• TSFE
• TypoScript
• jQuery code
• HTML
• CSS
• RSS
Fabrizio Branca
Visualizing xdebug profiling
Visualizing xdebug profiling
Visualizing pdepend xml
jQuery Lint
„Runtime Reporter“
http://james.padolsey.com/javascript/jquery-lint/
Fabrizio Branca
TypoScript Check (lint)
Proof of concept!
Xclassing tslib_content:
function stdWrap($content,$conf) {
$this->getLinkChecker()->check($conf, 'stdWrap');
return parent::stdWrap($content, $conf);
}
Fabrizio Branca
Tick
Tick
Fabrizio Branca
Tick
Use validators
Use validators for validating
• HTML
• CSS
• RSS
Keep an eye on editor„s content
Fabrizio Branca
Spot performance killers
• Use USER_INTs only if really needed.
• Create links with cHashes
• Avoid putting USER_INTs on all pages
(load them via ajax)
• Cache headers
• Static publishing
Fabrizio Branca
Monitoring
• Configure your TYPO3 instances to notify
you when errors occur.
• Use Monitoring tools (e.g. Nagios,
Caretaker?)
Fabrizio Branca
Pingdom
Maintainance
• Delete old temp files
find ../htdocs/typo3temp -type f -mtime +28 -delete
• Delete deleted records
• Delete unreferenced files
• Cleanup/check database
Fabrizio Branca

Weitere ähnliche Inhalte

Mehr von AOE

Flamingo presentation at code.talks commerce by Daniel Pötzinger
Flamingo presentation at code.talks commerce by Daniel PötzingerFlamingo presentation at code.talks commerce by Daniel Pötzinger
Flamingo presentation at code.talks commerce by Daniel PötzingerAOE
 
A bag full of trust - Christof Braun at AOE Conference 2018
A bag full of trust - Christof Braun at AOE Conference 2018A bag full of trust - Christof Braun at AOE Conference 2018
A bag full of trust - Christof Braun at AOE Conference 2018AOE
 
Digitalizing the Global Travel Retail World - Kian Gould at Global Retailing ...
Digitalizing the Global Travel Retail World - Kian Gould at Global Retailing ...Digitalizing the Global Travel Retail World - Kian Gould at Global Retailing ...
Digitalizing the Global Travel Retail World - Kian Gould at Global Retailing ...AOE
 
Frankfurt Airport Digitalization Case Study
Frankfurt Airport Digitalization Case StudyFrankfurt Airport Digitalization Case Study
Frankfurt Airport Digitalization Case StudyAOE
 
This is what has to change for Travel Retail to survive - Manuel Heidler, AOE
This is what has to change for Travel Retail to survive - Manuel Heidler, AOEThis is what has to change for Travel Retail to survive - Manuel Heidler, AOE
This is what has to change for Travel Retail to survive - Manuel Heidler, AOEAOE
 
AOEconf17: Application Security
AOEconf17: Application SecurityAOEconf17: Application Security
AOEconf17: Application SecurityAOE
 
AOEconf17: AOE Tech Radar Insights
AOEconf17: AOE Tech Radar InsightsAOEconf17: AOE Tech Radar Insights
AOEconf17: AOE Tech Radar InsightsAOE
 
AOEconf17: A flight through our OM³ Systems
AOEconf17: A flight through our OM³ SystemsAOEconf17: A flight through our OM³ Systems
AOEconf17: A flight through our OM³ SystemsAOE
 
AOEconf17: AOE Tech Radar Insights
AOEconf17: AOE Tech Radar InsightsAOEconf17: AOE Tech Radar Insights
AOEconf17: AOE Tech Radar InsightsAOE
 
AOEconf17: Pets vs. Cattle - modern Application Infrastructure - by Fabrizio ...
AOEconf17: Pets vs. Cattle - modern Application Infrastructure - by Fabrizio ...AOEconf17: Pets vs. Cattle - modern Application Infrastructure - by Fabrizio ...
AOEconf17: Pets vs. Cattle - modern Application Infrastructure - by Fabrizio ...AOE
 
AOEconf17: Agile scaling concepts
AOEconf17: Agile scaling conceptsAOEconf17: Agile scaling concepts
AOEconf17: Agile scaling conceptsAOE
 
AOEcon17: Searchperience - The journey from PHP and Solr to Scala and Elastic...
AOEcon17: Searchperience - The journey from PHP and Solr to Scala and Elastic...AOEcon17: Searchperience - The journey from PHP and Solr to Scala and Elastic...
AOEcon17: Searchperience - The journey from PHP and Solr to Scala and Elastic...AOE
 
AOEconf17: UI challenges in a microservice world
AOEconf17: UI challenges in a microservice worldAOEconf17: UI challenges in a microservice world
AOEconf17: UI challenges in a microservice worldAOE
 
AOEconf17: Application Security - Bastian Ike
AOEconf17: Application Security - Bastian IkeAOEconf17: Application Security - Bastian Ike
AOEconf17: Application Security - Bastian IkeAOE
 
AOEconf17: Management 3.0 - the secret to happy, performing and motivated sel...
AOEconf17: Management 3.0 - the secret to happy, performing and motivated sel...AOEconf17: Management 3.0 - the secret to happy, performing and motivated sel...
AOEconf17: Management 3.0 - the secret to happy, performing and motivated sel...AOE
 
AOEconf17: How to eat an elePHPant, congstar style - Timo Fuchs & Stefan Rotsch
AOEconf17: How to eat an elePHPant, congstar style - Timo Fuchs & Stefan RotschAOEconf17: How to eat an elePHPant, congstar style - Timo Fuchs & Stefan Rotsch
AOEconf17: How to eat an elePHPant, congstar style - Timo Fuchs & Stefan RotschAOE
 
Joern Bock: The basic concept of an agile organisation
Joern Bock: The basic concept of an agile organisationJoern Bock: The basic concept of an agile organisation
Joern Bock: The basic concept of an agile organisationAOE
 
Magento 2 Best Practice Workfow // David Lambauer // Meet Magento 2017 // Lei...
Magento 2 Best Practice Workfow // David Lambauer // Meet Magento 2017 // Lei...Magento 2 Best Practice Workfow // David Lambauer // Meet Magento 2017 // Lei...
Magento 2 Best Practice Workfow // David Lambauer // Meet Magento 2017 // Lei...AOE
 
SUPER-scaling E-Commerce with Magento
SUPER-scaling E-Commerce with MagentoSUPER-scaling E-Commerce with Magento
SUPER-scaling E-Commerce with MagentoAOE
 
How to eat an elephant
How to eat an elephantHow to eat an elephant
How to eat an elephantAOE
 

Mehr von AOE (20)

Flamingo presentation at code.talks commerce by Daniel Pötzinger
Flamingo presentation at code.talks commerce by Daniel PötzingerFlamingo presentation at code.talks commerce by Daniel Pötzinger
Flamingo presentation at code.talks commerce by Daniel Pötzinger
 
A bag full of trust - Christof Braun at AOE Conference 2018
A bag full of trust - Christof Braun at AOE Conference 2018A bag full of trust - Christof Braun at AOE Conference 2018
A bag full of trust - Christof Braun at AOE Conference 2018
 
Digitalizing the Global Travel Retail World - Kian Gould at Global Retailing ...
Digitalizing the Global Travel Retail World - Kian Gould at Global Retailing ...Digitalizing the Global Travel Retail World - Kian Gould at Global Retailing ...
Digitalizing the Global Travel Retail World - Kian Gould at Global Retailing ...
 
Frankfurt Airport Digitalization Case Study
Frankfurt Airport Digitalization Case StudyFrankfurt Airport Digitalization Case Study
Frankfurt Airport Digitalization Case Study
 
This is what has to change for Travel Retail to survive - Manuel Heidler, AOE
This is what has to change for Travel Retail to survive - Manuel Heidler, AOEThis is what has to change for Travel Retail to survive - Manuel Heidler, AOE
This is what has to change for Travel Retail to survive - Manuel Heidler, AOE
 
AOEconf17: Application Security
AOEconf17: Application SecurityAOEconf17: Application Security
AOEconf17: Application Security
 
AOEconf17: AOE Tech Radar Insights
AOEconf17: AOE Tech Radar InsightsAOEconf17: AOE Tech Radar Insights
AOEconf17: AOE Tech Radar Insights
 
AOEconf17: A flight through our OM³ Systems
AOEconf17: A flight through our OM³ SystemsAOEconf17: A flight through our OM³ Systems
AOEconf17: A flight through our OM³ Systems
 
AOEconf17: AOE Tech Radar Insights
AOEconf17: AOE Tech Radar InsightsAOEconf17: AOE Tech Radar Insights
AOEconf17: AOE Tech Radar Insights
 
AOEconf17: Pets vs. Cattle - modern Application Infrastructure - by Fabrizio ...
AOEconf17: Pets vs. Cattle - modern Application Infrastructure - by Fabrizio ...AOEconf17: Pets vs. Cattle - modern Application Infrastructure - by Fabrizio ...
AOEconf17: Pets vs. Cattle - modern Application Infrastructure - by Fabrizio ...
 
AOEconf17: Agile scaling concepts
AOEconf17: Agile scaling conceptsAOEconf17: Agile scaling concepts
AOEconf17: Agile scaling concepts
 
AOEcon17: Searchperience - The journey from PHP and Solr to Scala and Elastic...
AOEcon17: Searchperience - The journey from PHP and Solr to Scala and Elastic...AOEcon17: Searchperience - The journey from PHP and Solr to Scala and Elastic...
AOEcon17: Searchperience - The journey from PHP and Solr to Scala and Elastic...
 
AOEconf17: UI challenges in a microservice world
AOEconf17: UI challenges in a microservice worldAOEconf17: UI challenges in a microservice world
AOEconf17: UI challenges in a microservice world
 
AOEconf17: Application Security - Bastian Ike
AOEconf17: Application Security - Bastian IkeAOEconf17: Application Security - Bastian Ike
AOEconf17: Application Security - Bastian Ike
 
AOEconf17: Management 3.0 - the secret to happy, performing and motivated sel...
AOEconf17: Management 3.0 - the secret to happy, performing and motivated sel...AOEconf17: Management 3.0 - the secret to happy, performing and motivated sel...
AOEconf17: Management 3.0 - the secret to happy, performing and motivated sel...
 
AOEconf17: How to eat an elePHPant, congstar style - Timo Fuchs & Stefan Rotsch
AOEconf17: How to eat an elePHPant, congstar style - Timo Fuchs & Stefan RotschAOEconf17: How to eat an elePHPant, congstar style - Timo Fuchs & Stefan Rotsch
AOEconf17: How to eat an elePHPant, congstar style - Timo Fuchs & Stefan Rotsch
 
Joern Bock: The basic concept of an agile organisation
Joern Bock: The basic concept of an agile organisationJoern Bock: The basic concept of an agile organisation
Joern Bock: The basic concept of an agile organisation
 
Magento 2 Best Practice Workfow // David Lambauer // Meet Magento 2017 // Lei...
Magento 2 Best Practice Workfow // David Lambauer // Meet Magento 2017 // Lei...Magento 2 Best Practice Workfow // David Lambauer // Meet Magento 2017 // Lei...
Magento 2 Best Practice Workfow // David Lambauer // Meet Magento 2017 // Lei...
 
SUPER-scaling E-Commerce with Magento
SUPER-scaling E-Commerce with MagentoSUPER-scaling E-Commerce with Magento
SUPER-scaling E-Commerce with Magento
 
How to eat an elephant
How to eat an elephantHow to eat an elephant
How to eat an elephant
 

Kürzlich hochgeladen

Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 

Kürzlich hochgeladen (20)

Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 

Debugging, Monitoring and Profiling in TYPO3

  • 1. Debugging, Monitoring and Profiling Fabrizio Branca fabrizio (dot) branca (at) aoemedia (dot) de Twitter: @fbrnc
  • 2. This talk is… • sharing some best practices • sharing some tools with you • an (incomplete) checklist • a reminder (hopefully) Fabrizio Branca
  • 3. What is this all about? • Make your website run smoothly! • during development… • and when the site is online • “Smoothly” is • No bugs (unexpected behaviour) • Stability • Performance Fabrizio Branca
  • 4. This talk is about How to… • avoid errors • detect errors • deal with errors • notify yourself when errors have occurred Fabrizio Branca
  • 5. It„s all about bugs Fabrizio Branca
  • 6. It„s all about bugs Everybody creates bugs. Nobody is perfect. A high percentage of coding time goes into • searching for bugs • fixing bugs Increase your productivity by reducing this time! Fabrizio Branca
  • 7. Automating • Automatize error recognition • Use proper tools • Automatize error reporting • Route detailed error reports into your mailbox Fabrizio Branca
  • 8. Bugs • Avoid bugs • through programming style • Spot bugs fast • “Safety nets”: Unit tests, Assertions • Detect them before the customer and/or the website user finds them Fabrizio Branca
  • 9. Avoid bugs • Use a proper IDE • Syntax checks • Code Completion
  • 10. Coding style • Cover all cases: No if without else! • Use type hints wherever possible • Stick to patterns • Increase crearity • Convention over configuration • KISS • Use object collections • Make it easier for team members to find and fix bugs (increase the truck factor) by sticking to coding guidelines and patterns Fabrizio Branca
  • 11. What does PHP offer? • log_errors • display_errors • error_log Set values in • php.ini • .htaccess / vhost configuration Fabrizio Branca
  • 12. What does TYPO3 offer? • devLog, sysLog, Tslog • devIpMask • Deprecation log • Page not found / Page unavailable • Exception handling • Error handling • Debug Console in the BE Fabrizio Branca
  • 13. Deal with exceptions (I) How to react when an exception has occurred? • Don„t display any details to the user! • Send a correct HTTP status code (for search engines and log files) $GLOBALS['TSFE']->pageNotFoundAndExit($errorHandlerMessage); $GLOBALS['TSFE']->pageUnavailableAndExit($errorHandlerMessage); Fabrizio Branca
  • 16. Deal with exceptions (II) Handle exceptions within your controllers. Notify yourself: • write a message to devLog • write a message to sysLog • write a message to TSLog Fabrizio Branca
  • 18. Bug detection • Bugs are harder to fix the later they are detected • Bugs become harder to diagnose the further the symptom is removed from the cause Fabrizio Branca
  • 19. Bug detection with assertions • Make sure that variables contain what you expect at any time (e.g. after calling a function) • E.g.: Check incoming parameters for correct type • Simple one line call: tx_pttools_assert::isValidUid($this->params['uid']); • Throws an exception if assertion is not true • http://articles.sitepoint.com/article/bug-detection-php-assertions http://debuggable.com/posts/assert-the-yummyness-of-your-cake:480f4dd6- 7fe0-4113-9776-458acbdd56cb Fabrizio Branca
  • 20. Bug detection with assertions • Assertions are easy to use. • Don„t assume anything, check it! • Example: ini_set() • No substitute for unit tests! Fabrizio Branca
  • 21. Bug detection with assertions See EXT:pt_tools/res/staticlib/class.tx_pttools_assert.php or build your own assert class Some examples: • tx_pttools_assert::isValidUid(); • tx_pttools_assert::isNotEmptyString(); Fabrizio Branca
  • 22.
  • 24. t3lib_div::sysLog() Decides by configuration how to handle syslog messages • send mail • write to log file • write to OS syslog Fabrizio Branca
  • 26. SysLog notification mail msg: Assertion "isValidUid" failed! extKey: pt_tools severity: 3 exceptionClass: tx_pttools_exceptionAssertion debugMsg: file: /var/www/burghalle/integration/htdocs/typo3conf/ext/aoe_burg/controller/class.tx_aoeburg_controller_extranet.php line: 78 function: tx_aoeburg_controller_extranet::init assertType: isValidUid val: expected: 1 Server: TYPO3_REQUEST_URL: http://www.integration.burghalle.aoe-works.de/xtranet/uebersicht/artikel- bearbeiten/e/typo3conf/ext/burghalle_template/i/white-75.png HTTP_REFERER: http://www.integration.burghalle.aoe-works.de/xtranet/uebersicht/artikel-bearbeiten/e/saveContent.html POST: -- none -- COOKIE: condensed: 0 fe_typo_user: 6b7ccec749891321cb6e7e2fc4c685a4 PHPSESSID: 4b8712f5a4c845029da1f2332cf9132b Client: HTTP_USER_AGENT: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.4) Gecko/20100611 Firefox/3.6.4 ( .NET CLR 3.5.30729; .NET4.0C) Spider: No REMOTE_HOST: [null] REMOTE_ADDR: 217.19.187.106 User: FE_User: aoe BE_User: -- no user -- Trace: [...]
  • 27. $TYPO3_DB- >debug_check_recordset() • Check all database queries • Debug_check_recordset takes care of writing log messages Fabrizio Branca
  • 29. $TT->push() / ->pull() Use the timetrack object to keep track of what happens in your code. Fabrizio Branca
  • 31. Reports module Write your own reports Examples: • Table size • Outdated extensions (extension manager) • TCA Integrity • TCA/database integrity (Like Compare tool) • Extension integrity (dependencies, conflicts) • Free disk space • Server load Fabrizio Branca
  • 32. Define a strong api • Provide interfaces for hooks. • Allow alternatives (pagerStrategy, viewClass,…) Fabrizio Branca
  • 33. Keep an eye on the logs… • Webserver • Apache error log • PHP error log • TYPO3 • Log module (Core error handler…) • Admin Panel • RealUrl • error log • are all paramters encoded? • Deprecation log • Reports module Fabrizio Branca
  • 34. Keep an eye on the logs… • External tools • Google Webmaster Tools • Wget • Piwik • MySQL • Slow query log • OS (*nix) • Syslog Fabrizio Branca
  • 36.
  • 38. Let tools do the analysis • PHP • TSFE • TypoScript • jQuery code • HTML • CSS • RSS Fabrizio Branca
  • 43. TypoScript Check (lint) Proof of concept! Xclassing tslib_content: function stdWrap($content,$conf) { $this->getLinkChecker()->check($conf, 'stdWrap'); return parent::stdWrap($content, $conf); } Fabrizio Branca
  • 44. Tick
  • 46. Tick
  • 47. Use validators Use validators for validating • HTML • CSS • RSS Keep an eye on editor„s content Fabrizio Branca
  • 48. Spot performance killers • Use USER_INTs only if really needed. • Create links with cHashes • Avoid putting USER_INTs on all pages (load them via ajax) • Cache headers • Static publishing Fabrizio Branca
  • 49. Monitoring • Configure your TYPO3 instances to notify you when errors occur. • Use Monitoring tools (e.g. Nagios, Caretaker?) Fabrizio Branca
  • 51. Maintainance • Delete old temp files find ../htdocs/typo3temp -type f -mtime +28 -delete • Delete deleted records • Delete unreferenced files • Cleanup/check database Fabrizio Branca