Application Diagnosis with Zend Server Tracing


Published on

Talk by Kevin Schroeder of Zend at ZendCon 2009

Published in: Technology
1 Like
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • When code tracing is activated we ignore other activation requests.
  • Application Diagnosis with Zend Server Tracing

    1. 1. Application Diagnosis with Zend Server Tracing<br />Kevin Schroeder<br />Zend Technologies<br />
    2. 2. About me<br />Kevin Schroeder<br />Consultant for Zend<br />Programmer<br />Sys Admin<br />Author<br />Etc.<br />Me!<br />
    3. 3. &quot;As soon as we started programming, we found to our surprise that it wasn&apos;t as easy to get programs right as we had thought. Debugging had to be discovered. I can remember the exact instant when I realized that a large part of my life from then on was going to spent in finding mistakes in my own programs&quot; <br /> - Maurice Wilkes, 1949 <br />
    4. 4. Why do we need diagnostic tools?<br />
    5. 5. Let’s see that again in slow motion<br />
    6. 6. The point<br />NOT to highlight an individual company<br />Why not?<br />How many web-based applications look like this when an error occurs?<br />Answer<br />All of them<br />Web requests are intended to be short and quick<br />If an error occurs, recover, quit and go on to the next request<br />
    7. 7. Debugging the old way<br />var_dump($var)(I still use this occasionally)<br />Some obvious problems<br />What if you forget to remove it?<br />Are you doing this in a production environment? If you are …<br />Very limited scope<br />
    8. 8. Debugging the better way – ZS Debugging<br />You can see what the variable values are at run time and modify them too<br />Good for development<br />Not good for production<br />
    9. 9. Monitoring<br />MUCH better for production systems<br />You get a lot of really good information to help replay the issue<br />
    10. 10. Monitoring<br />You are able to debug or profile the event on a remote machine<br />
    11. 11. Events that can be monitored<br />
    12. 12. Instrumentation on the next level<br />Zend Code Tracing<br />
    13. 13. Code Tracing: Rapid Problem Resolution<br />Similar in concept to a black box flight recorder - Eliminates the need to reproduce problems in order to find root cause<br />Activated automatically (through rules) or manually<br />Records live application execution <br />Function calls<br />Arguments and return values<br />Errors<br />Duration<br />Useful in all parts of the software development lifecycle<br />
    14. 14. Practical Code Tracing Functionality<br />By capturing PHP applications code in real time:<br />Code Tracing enables to capture problems when they occur.<br />Code Tracing recorded data eliminate the need to reproduce the steps led up to a failure.<br />Code Tracing enables to analyze PHP applications execution both in production and in test lab environments, by that, it enables to quickly find the root cause of problems.<br />14<br />Insert-&gt;Header & Footer<br />
    15. 15. Supported Workflows<br />Manual workflow: <br />Used while performing unit tests during development or when running functional tests in QA. <br />Calling URLs as part of the testing process<br />Monitoring events workflow<br />Used when running automated tests and load tests and when running your application in staging or production environments. <br />Code tracing extends the monitoring rules mechanism by enabling to save trace data when a monitoring event is generated. <br />Suitable for production in Standby mode<br />
    16. 16. Detailed Runtime Instrumentation<br />Pinpoint root cause by viewing the sequence of events that led up to an error<br />
    17. 17. Detailed Runtime Instrumentation<br />Optimize your code by analyzing application performance at the function level<br />
    18. 18. Code Tracing – Monitoring Level Modes<br />Always on<br />Collects trace data when monitoring event is kicked off<br />Collects trace data for manual requests.<br />Inactive<br />Collects data only for manual requests.<br />Standby<br />Off (turn code tracing extension off)<br />
    19. 19. Code Tracing – Operating Modes<br />Standby mode<br />A monitoring event activates code tracing<br />Trace mode:<br />On<br />Standby<br />Tracing switches back for “Standby” mode<br />Tracing is activated for X minutes<br />Time<br />A monitoring event with an “Activate Trace” action is generated<br />Collect trace data according to the monitoring set of rules<br />
    20. 20. The basics<br />Trace a Request<br />
    21. 21. Interpreting the results<br />Screenshots are boring. Let’s look at live data<br />
    22. 22. Setup<br />Attaching traces to events <br />Tracing can be attached to any PHP-specific events<br />
    23. 23. Tracing Events – Standby Mode<br />Set zend_monitor.event_tracing_mode<br />Active, Inactive or Standby<br />Determines integration with tracer mechanism in case of events that require a trace data dump<br /><ul><li>Create an Event Action – “Enable Tracing” will change</li></li></ul><li>Tracing Process Signals<br />Tracing can also be initiated upon a fatal signal<br />
    24. 24. Tracing Log<br />Step 1 – Make sure that you have it set to log<br />Step 2 – Set the verbosity between 1 and 5<br />Restart<br />
    25. 25. Example log file<br />[Tracing Log 08.10.2009 14:14:56 DBG1] 5387 Tracer request startup <br />[Tracing Log 08.10.2009 14:14:56 DBG3] 5387 Setting dump reason to 0 <br />[Tracing Log 08.10.2009 14:14:56 DBG3] 5387 Dump reason is now 0 <br />[Tracing Log 08.10.2009 14:14:56 DBG1] 5387 Remote address is <br />[Tracing Log 08.10.2009 14:14:56 DBG2] 5387 Allow hostmask is,,, <br />[Tracing Log 08.10.2009 14:14:56 DBG2] 5387 Deny hostmask is <br />[Tracing Log 08.10.2009 14:14:56 DBG1] 5387 Remote access allowed <br />[Tracing Log 08.10.2009 14:14:56 DBG1] 5387 Request parameter requires dump <br />[Tracing Log 08.10.2009 14:14:56 DBG3] 5387 Setting dump reason to 2 <br />[Tracing Log 08.10.2009 14:14:56 NOTICE] 5387 Installing signal handler <br />[Tracing Log 08.10.2009 14:14:56 DBG2] 5387 Staring trace generation <br />[Tracing Log 08.10.2009 14:14:56 DBG2] 5387 Tracer request startup done <br />[Tracing Log 08.10.2009 14:14:56 DBG3] 5387 Options updated to 7FFF <br />[Tracing Log 08.10.2009 14:14:57 DBG1] 5387 Tracer request shutdown <br />[Tracing Log 08.10.2009 14:14:57 WARNING] 5387 Code tracing buffer full <br />[Tracing Log 08.10.2009 14:14:57 DBG1] Using socket /usr/local/zend/tmp/monitor_events.sock rules /usr/local/zend/etc/events_rules.xml <br />[Tracing Log 08.10.2009 14:14:58 NOTICE] Event type 1 (0) reported <br />[Tracing Log 08.10.2009 14:14:58 NOTICE] 5387 Generating trace dump, format 2 <br />[Tracing Log 08.10.2009 14:14:58 DBG2] 5387 Dump name is /usr/local/zend/var/codetracing/dump.5387.1 <br />Monitoring Event was triggered<br />
    26. 26. Functional Examples<br />Uncaught exceptions<br />Destructor being called<br />Prepared Statements<br />
    27. 27. Where did all my memory go?<br />Memory usage<br />Large variable going out of scope<br />
    28. 28. Impact<br />
    29. 29. The all-important question…<br />“Where should I use this?”<br />Development – Possibly, though profiling and debugging may be more pertinent<br />Testing – Absolutely<br />Staging – Absolutely<br />Production - Absolutely<br />In Standby mode<br />Activated on a subset of servers<br />
    30. 30. Questions?<br />Want to join in the public beta? Go to <br /><br />for more information<br /><br />
    31. 31. Additional Information<br />
    32. 32. What happens when you have too much data<br />Need to up the zend_codetracing.buffer_size setting<br />
    33. 33. Increasing the buffer size to 5MB<br />That’s better<br />
    34. 34. Settings<br />
    35. 35. Settings<br />
    36. 36. Settings<br />
    37. 37. Settings<br />