Debugging, Monitoring and Profiling in TYPO3
Upcoming SlideShare
Loading in...5
×
 

Debugging, Monitoring and Profiling in TYPO3

on

  • 5,695 views

Slides of Fabrizio Branca's talk on the TYPO3 Developer Days 2010 (T3DD10)

Slides of Fabrizio Branca's talk on the TYPO3 Developer Days 2010 (T3DD10)

Statistics

Views

Total Views
5,695
Views on SlideShare
5,396
Embed Views
299

Actions

Likes
3
Downloads
21
Comments
0

2 Embeds 299

http://www.fabrizio-branca.de 298
http://translate.googleusercontent.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Debugging, Monitoring and Profiling in TYPO3 Debugging, Monitoring and Profiling in TYPO3 Presentation Transcript

    • Debugging, Monitoring andProfilingFabrizio Brancafabrizio (dot) branca (at) aoemedia (dot) deTwitter: @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 • PerformanceFabrizio Branca
    • This talk is about How to… • avoid errors • detect errors • deal with errors • notify yourself when errors have occurredFabrizio Branca
    • It„s all about bugsFabrizio 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 mailboxFabrizio 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 themFabrizio 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 patternsFabrizio Branca
    • What does PHP offer? • log_errors • display_errors • error_log Set values in • php.ini • .htaccess / vhost configurationFabrizio Branca
    • What does TYPO3 offer? • devLog, sysLog, Tslog • devIpMask • Deprecation log • Page not found / Page unavailable • Exception handling • Error handling • Debug Console in the BEFabrizio 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 foundFabrizio Branca
    • Page unavailableFabrizio 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 TSLogFabrizio Branca
    • Exception HandlerFabrizio 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 causeFabrizio 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-458acbdd56cbFabrizio 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 syslogFabrizio Branca
    • Custom SysLog Handler See EXT:tcaobjects/res/class.tx_tcaobjects_syslog.phpFabrizio Branca
    • SysLog notification mailmsg: Assertion "isValidUid" failed!extKey: pt_toolsseverity: 3exceptionClass: tx_pttools_exceptionAssertiondebugMsg: 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: 1Server: 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: 4b8712f5a4c845029da1f2332cf9132bClient: 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.106User: 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 messagesFabrizio Branca
    • TSlogFabrizio Branca
    • $TT->push() / ->pull() Use the timetrack object to keep track of what happens in your code.Fabrizio Branca
    • Reports moduleFabrizio 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 loadFabrizio 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 moduleFabrizio Branca
    • Keep an eye on the logs… • External tools • Google Webmaster Tools • Wget • Piwik • MySQL • Slow query log • OS (*nix) • SyslogFabrizio Branca
    • Log ModuleFabrizio Branca
    • Google Webmaster ToolsFabrizio Branca
    • Let tools do the analysis • PHP • TSFE • TypoScript • jQuery code • HTML • CSS • RSSFabrizio 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
    • TickFabrizio Branca
    • Tick
    • Use validators Use validators for validating • HTML • CSS • RSS Keep an eye on editor„s contentFabrizio 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 publishingFabrizio 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 databaseFabrizio Branca