Introducing airbrake.io or opensource errbit in to your company software development process. Word about error handling in php. Some more about integrating an php application with errbit.
The code in live coding show was: https://github.com/emgiezet/symfony2-errbit
3. Agenda
1. PHP error tracking
2. Airbrake
3. Errbit
4. emgiezet/errbitPHP
5. Case Study
meet.php #11
3
4. How I can track errors in PHP?
●
Override error handler
●
set_error_handler(
array($this, 'onError'),
error_reporting()
);
Override exception handler
set_exception_handler(
array($this, 'onException')
);
●
Use the shutdown
function
register_shutdown_function(
array($this, 'onShutdown')
);
meet.php #11
4
5. How do you track the errors?
●
Common Strategies:
–
Read Apache / ngnix / PHP Logs
–
Read application logs (ex. monolog)
–
Emails with Stack Traces
–
Wait until customer report some errors.
–
I'm so PRO that my application never crash on
production. xoxo
meet.php #11
5
6. Sudden error rate of 50% for your
Application
http://devopsreactions.tumblr.com/post/67741920428/sudden-error-rate-of-50-for-your-application
meet.php #11
6
7. How your customers reports an
error?
●
Link to the page is attached?
●
Time-stamp of the error occurrence to grep the log?
●
Is there any screen-shot or screen-cast attached?
●
Maybe some unicorns are dancing on rainbow?
meet.php #11
7
8. To repeat the error you must..
a) Play email ping-pong.
b) Dig the logs for the next few hours.
c) Daft Punk - Get Lucky?
d) Have a Error tracking application.
meet.php #11
8
13. Errbit
●
●
●
●
●
meet.php #11
Compatible API with
Airbrake Notifier API
Written in Ruby srsly
must be cool
Can be hosted at Heroku
freebie!
You know first when sth
is screwed up.
Setup takes one hour.
13
14. AirBrake vs Errbit
●
●
●
●
●
●
App count limited by plan
(max 40)
Hosted in atomic bomb
proof shelter
Freebie
●
Unlimited Apps and Users
●
God damn expensive
Can be hosted on heroku
Unlimited error retention
●
Super-fast notifications.
Application don't lags on
error reporting
●
meet.php #11
15 MB of MongoDB on
heroku free plan
Sleeping after 5 min of
inactivity
14
22. Not enough?
●
Error Comments
●
Issue tracker integration:
–
Deploy hook
–
To clean your error
counter for previous
deploy
meet.php #11
BitBucket
Gitlab
Redmine
–
FogBugz
–
Mingle
–
Pivotal Labs
–
and replies with
notifications
Github
–
●
–
–
–
Sorry no Jira.
22
23. But how can I integrate Errbit with
my PHP App?
Requires:
●
–
–
●
PHP >= 5.3.2
Without cURL
Integrates with
–
–
Symfony2
–
Kohana 3
–
meet.php #11
Plain PHP esoteric mutants
...
23
24. History of errbit-php
●
Original concept was made
by:
flippa/errbit-php and
dbtlr/php-airbrake
●
90% of code were rewritten to match
psr-2.
●
80% LOC were covered by unit tests.
●
Added TravisCI build for
–
–
●
●
But both of them doesn't
work at all. And wasn't OOP.
Flippa don't accept any
pull-requests so:
PHP 5.4
–
●
PHP 5.3
PHP 5.5
Already have merged few pull
request
●
Got more than 200 Installs
●
Is linked in a readme of errbit/errbit ;)
meet.php #11
24
25. Enough bullshit. Time to code!
●
Symfony2 Integration
●
Plain PHP Integration
1. Add to composer.json
1. Download
2. Composer update
2. Add the “use” in your
“kernel” file
3. Create a Listener
onKernelException
3. Create an Errbit
instance
4. Register a service
4. Call the start()
5. Set the api key in
parameters.yml
5. Collect the errors
6. Collect the errors
meet.php #11
25
33. Advantages of using Errbit
●
You know first that error occurred.
●
You know much more than customer will report you.
●
●
●
You can fix the bug and make a #ninja deploy before customer
will notice the error.
Cloud solution friendly – no more grep'ing the error logs from
all PHP nodes
You care about the support and maintenance you gain lots of
professional #swag
meet.php #11
33
34. Things to remember
“Writing tests is our
professional responsibility”
●
●
~@jakub_zalas
meet.php #11
This is your last line of
defense.
Fix bugs and do the
homework in your next
projects
34