SlideShare a Scribd company logo
1 of 92
Download to read offline
Empower is the first step for
new revolutions
The first step in any revolution is going to be the
moment of realization.
If you've had enough, and are ready to commit to
your dreams, that is when the real revolution begins.
So i ask you...have YOU had enough?
O primeiro passo para qualquer revolução vai ser o momento da realização.
Se você já teve o suficiente, e está pronto para comprometer-se a seus sonhos, que é quando a
verdadeira revolução começa. Então pergunto a vocês ... Vocês já tem o suficiente?
Shit happens
Centralize logs and get your insight into the errors that
affect your customers.
Who?
Jackson F. de A. Mafra
http://about.me/jacksonfdam
https://bitbucket.org/jacksonfdam
https://github.com/jacksonfdam
http://linkedin.com/in/jacksonfdam
@jacksonfdam
Software Engineer at Aggrega Group, mobile training instructor at
Targettrust. Developer for 15 years with background in e-
commerce projects and real estate, since 2009 with focused
interests for the development of mobile and MEAP and applications
interfaces.
Aspect oriented programming (AOP) allows us
to keep implement different concerns in
isolation
What?
The term Aspect-Oriented Programming took
shape in the mid-1990s, inside a small group at
Xerox Palo Alto Research Center (PARC).
AOP was considered controversial in its early
days — as is the case with any new and
interesting technology — mostly due to its lack
of clear definition. The group made the
conscious decision to release it in a half-baked
form, in order to let the larger community
provide feedback. At the heart of the problem
was the "Separation of Concerns" concept. AOP
was one possible solution to separate
concerns.
Whereas DI helps you decouple your
application objects from each other, AOP helps
you decouple cross-cutting concerns from the
objects that they affect.
A PHP Developers Perspective...
Aspect Oriented Programming/Architecture is a
practice in SOLID design principles.
It is an attempt to further abstract specific cross
application concerns within your code - using a
techinique to intercept points within your call
stack to perform specific functionality at given
times.
A PHP Developers Perspective...
Concerns, like security, cut across the natural
units of modularity. For PHP the natural unit of
modularity is the class. But in PHP crosscutting
concerns are not easily turned into classes
precisely because they cut across classes, and
so these aren’t reusable, they can’t be refined
or inherited, they are spread through out the
program in an undisciplined way, in short, they
are difficult to work with.
Why?
Centralize concerns implementation
More reusable code
Cleaner code
Write less code
Easy to understand
More maintainable
Less boilerplate code
More interesting work
Why AOP?
Caching
Profiling
Security
Pooling
Exception Handling
Transactions
Logging
Concern
Program execution
Join Points
Advice
Pointcut
Terminology
Aspects are often described in terms of advice,
pointcuts, and join points.
Terminology
Advice defines what needs to be applied and
when.
Jointpoint is where the advice is applied.
Pointcut is the combination of different
joinpoints where the advice needs to be
applied.
Aspect is applying the Advice at the pointcuts.
Definitions
Definitions
Method Method Method
Concern
Concern
Advice
Join Points
Logger
Transaction
Manager
Advice Types
Method
Method
Method
Method
Exception
Before advice
After advice
After returning advice
Around advice
Throws advice
AOP is a PECL extension that enables you to use Aspect
Oriented Programming in PHP, without the need to compile
or proceed to any other intermediate step before publishing
your code.
The AOP extension is designed to be the easiest way you
can think of for integrating AOP to PHP.
AOP aims to allow separation of cross-cutting concerns
(cache, log, security, transactions, ...)
https://github.com/AOP-PHP/AOP
AOP
You can use pecl
sudo pecl install aop-beta
Installation
Basic tutorial
Now you want your code to be safe, you don't want non
admin users to be able to call authorize methods.
Basic tutorial
Add some code to check the credentials "IN" you
UsersServices class. The drawback is that it will pollute your
code, and your core service will be less readable.
Let the clients have the responsibility to check the
credentials when required. The drawbacks are that you will
duplicate lots of code client side if you have to call the
service from multiple places
Add some kind of credential proxy that will check the
credentials before calling the actual service.
The drawbacks are that you will have to write some extra
code, adding another class on the top of your services.
What are your solutions ?
Moreover, those solutions tends to increase in complexity
while you are adding more cross-cutting concerns like
caching or logging.
What are your solutions ?
That's where AOP comes into action as you will be able to
tell PHP to do some extra actions while calling your
MyServices's admin methods.
What are your solutions ?
So let's first write the rule needed to check if we can or
cannot access the admin services.
What are your solutions ?
Dead simple : we check the current PHP session to see if
there is something telling us the current user is an admin (Of
course we do realize that you may have more complex
routines to do that, be we'll keep this for the example)
What are your solutions ?
Now, let's use AOP to tell PHP to execute this method
"before" any execution of admin methods.
What are your solutions ?
Now, each time you'll invoke a method of an object of the
class UsersServices, starting by authorize, AOP will launch
the function basicAdminChecker before the called method.
What are your solutions ?
Logging is an important part of the app
development/maintenance cycle.
Logging
To know the best method of logging data of
different contexts for specific environments
such as test/dev and production
Take Away
Even with use of computers there was a real
need to measure the overall performance of any
reasearch
Early 1980's there was a Instrument called
VELA (virtual laboratory) used for data
harvesting
History of Logging
Late 1980's, A device was invented to collect
information through sensors
Later then data logging/harvesting has been
used widely in all applications/reasearches/
products.
History of Logging
Track Users activity/Movement
Transaction Logging
Track user errors
System level failures/warnings
Research Data collection and Interpretation
Need of Logging
Error / Exception logs
Access logs
System logs
Application logs
Database logs
Transaction logs
Mailer logs etc...
Types of Logging
Apache
NGINX
PostgreSQL
MySQL
php
php-fpm
System Logs
Debug Information - Errors (connections,
uncaught exceptions, resource exhaustion)
Narrative Information - Methods Calls, Event
Triggers
Business Events - Purchases, Logins,
Registrations, Unsubscribes
Application Log
ssh webserver@mydomain.net
tail -f /var/log/nginx/my-site.access.log
tail -f /var/log/my.application.log
ssh data@mydomain.net
tail -f /var/log/mysql/mysql.log
ssh q@mydomain.net
tail -f /var/log/rabbitmq/nodename.log
Keeping Track Of All This
Apache/PHP
<VirtualHost *:80>
<Directory /var/www/html/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Current Conventions
Monolog is a PHP library that support different levels of
logging for PHP Applications and depends on PSR.
Inspired by Python Logbook library
Provides stack of handlers
More Powerful than conventional way of logging in
applications
Monolog Enters Here
Monolog sends your logs to files, sockets, inboxes,
databases and various web services.
Channel based approach
Different stack of handlers for specific channels
Pile up handler stack based on severity.
Format Interpretation depending on severity and channel
Prevents Bubbling when severity is reached
What's different ?
Log Levels 2013 - PSR03 - PHP Logging Interface
Standard
Phrase / Severity
emergency Emergency: system is unusable
alert Alert: action must be taken immediately
critical Critical: critical conditions
error Error: error conditions
warning Warning: warning conditions
notice Notice: normal but significant condition
info Informational: informational messages
debug Debug: debug-level messages
http://www.php-fig.org/psr/psr-3/
Log Levels
What about Apache’s error_log?
error_log is too basic (message, file, line)
difficult to read / parse
depends on “error_reporting” setting
Why?
monolog
phpconsole
log4php
RavenPHP + Sentry
FirePHP (dev environment)
Roll your own Logging Options
Logging Options
Fire & forget
Minimum or zero latency
Highly available
Should be PSR-3 compatible
Log everything:
- Exceptions
- Errors
- Fatal Errors
Requirements (for everyone)
Typical PSR-3 Compatible Design
Capture Method
Logger (PSR-3)
Handler / Adapter
Data Storage
Monolog
MonologErrorHandler ->
handleException()
MonologLogger ->log()
MonologHandler ->handle()
MongoDB
Option to have different channel for different module
Custom detailing
Different handlers for different development
Thorough participation in different stages of lifecycle
Open for third party integration
Readable and Beautiful Layered message
Advantages
PSR-3 makes it easy
However you want…
Monolog has loads:
- syslog-compatible / error_log
- Email, HipChat
- AMQP, Sentry, Zend Monitor, Graylog2
- Redis, MongoDB, CouchDB
Sending Log Messages
CakePHP - https://github.com/jadb/cakephp-monolog
Symfony2 - https://github.com/symfony/MonologBundle
Slim – https://github.com/flynsarmy/Slim-Monolog
Zend2 - https://packagist.org/packages/enlitepro/enlite-monolog
CodeIgniter - https://github.com/pfote/Codeigniter-Monolog
Laravel – Inbuilt Support.
Drupal - https://drupal.org/project/monolog
Wordpress - https://packagist.org/packages/fancyguy/wordpress-
monolog
more: https://github.com/Seldaek/monolog#frameworks-integration
Do you use Frameworks / CMS ?
Monolog is available on Packagist, which means that you can
install it via Composer.
composer require 'monolog/monolog:1.13.*'
Installation
Basic Usage
Loggers And Handlers
Loggers And Handlers
Loggers And Handlers
Event Logging
http://www.sitepoint.com/logging-with-monolog-from-devtools-to-slack/
More usages
Stop logging exceptions the old
fashioned way.
The Elk Stack
Indexing and search engine
Near real-time
Distributed, auto-discover clustering
– AWS Plugin
Elasticsearch
Collects logs
Parses, extracts and formats data
Passes data to Elasticsearch
Logstash
example
filter {
if [file] == "/var/log/secure" and (
[syslog_message] =~ /Invalid user/ or
[syslog_message] =~ /User root from/ ) {
grok {
add_tag => [ "LOGIN" ]
match => {"syslog_message" => “user %{ WORD:username}
from %{IP:srcip}" }
}
}
}
Logstash
Web interface to query Elasticsearch
node.js
Kibana
Kibana
Kibana
WHAT IS REALTIME?
THERE IS ALWAYS A DELAY
HOW MUCH DELAY CAN YOU
ACCEPT?
ARCHITECTURE OF DELAY
DATA LIFECYCLE
DATA LIFECYCLE
DATA LIFECYCLE
DATA LIFECYCLE
DATA LIFECYCLE:ELK
DATA LIFECYCLE:ELK
DATA LIFECYCLE:ELK
DATA LIFECYCLE:ELK
DATA LIFECYCLE:ELK
Logstash Architecture
AWS Architecture
I recommend
Questions?
Thank you.

More Related Content

Similar to WoMakersCode 2016 - Shit Happens

Aspect Oriented Software Development
Aspect Oriented Software DevelopmentAspect Oriented Software Development
Aspect Oriented Software Development
Jignesh Patel
 
Passing The Joel Test In The PHP World
Passing The Joel Test In The PHP WorldPassing The Joel Test In The PHP World
Passing The Joel Test In The PHP World
Lorna Mitchell
 

Similar to WoMakersCode 2016 - Shit Happens (20)

So You Just Inherited a $Legacy Application… NomadPHP July 2016
So You Just Inherited a $Legacy Application… NomadPHP July 2016So You Just Inherited a $Legacy Application… NomadPHP July 2016
So You Just Inherited a $Legacy Application… NomadPHP July 2016
 
Product! - The road to production deployment
Product! - The road to production deploymentProduct! - The road to production deployment
Product! - The road to production deployment
 
So You Just Inherited a $Legacy Application...
So You Just Inherited a $Legacy Application...So You Just Inherited a $Legacy Application...
So You Just Inherited a $Legacy Application...
 
Top 30 Scalability Mistakes
Top 30 Scalability MistakesTop 30 Scalability Mistakes
Top 30 Scalability Mistakes
 
Throwing Laravel into your Legacy App™
Throwing Laravel into your Legacy App™Throwing Laravel into your Legacy App™
Throwing Laravel into your Legacy App™
 
Raptor 2
Raptor 2Raptor 2
Raptor 2
 
NET Event - Migrating WinForm
NET Event - Migrating WinFormNET Event - Migrating WinForm
NET Event - Migrating WinForm
 
An Introduction to Microservices
An Introduction to MicroservicesAn Introduction to Microservices
An Introduction to Microservices
 
8_reasons_php_developers_love_using_laravel.pptx
8_reasons_php_developers_love_using_laravel.pptx8_reasons_php_developers_love_using_laravel.pptx
8_reasons_php_developers_love_using_laravel.pptx
 
System design for Web Application
System design for Web ApplicationSystem design for Web Application
System design for Web Application
 
Aspect Oriented Software Development
Aspect Oriented Software DevelopmentAspect Oriented Software Development
Aspect Oriented Software Development
 
Profiling PHP - AmsterdamPHP Meetup - 2014-11-20
Profiling PHP - AmsterdamPHP Meetup - 2014-11-20Profiling PHP - AmsterdamPHP Meetup - 2014-11-20
Profiling PHP - AmsterdamPHP Meetup - 2014-11-20
 
Introducing symfony
Introducing symfonyIntroducing symfony
Introducing symfony
 
Data Security in Fintech App Development: How PHP Can Help
Data Security in Fintech App Development: How PHP Can HelpData Security in Fintech App Development: How PHP Can Help
Data Security in Fintech App Development: How PHP Can Help
 
Passing The Joel Test In The PHP World
Passing The Joel Test In The PHP WorldPassing The Joel Test In The PHP World
Passing The Joel Test In The PHP World
 
Profiling PHP - PHPAmersfoort Meetup 2015-03-10
Profiling PHP - PHPAmersfoort Meetup 2015-03-10Profiling PHP - PHPAmersfoort Meetup 2015-03-10
Profiling PHP - PHPAmersfoort Meetup 2015-03-10
 
Cs121 Unit Test
Cs121 Unit TestCs121 Unit Test
Cs121 Unit Test
 
8_reasons_php_developers_love_using_laravel.pdf
8_reasons_php_developers_love_using_laravel.pdf8_reasons_php_developers_love_using_laravel.pdf
8_reasons_php_developers_love_using_laravel.pdf
 
Lamp Zend Security
Lamp Zend SecurityLamp Zend Security
Lamp Zend Security
 
Dev Ops for systems of record - Talk at Agile Australia 2015
Dev Ops for systems of record - Talk at Agile Australia 2015Dev Ops for systems of record - Talk at Agile Australia 2015
Dev Ops for systems of record - Talk at Agile Australia 2015
 

More from Jackson F. de A. Mafra

More from Jackson F. de A. Mafra (20)

PHP Conference 2020 - A eterna luta: compatibilidade retroativa vs. dívida té...
PHP Conference 2020 - A eterna luta: compatibilidade retroativa vs. dívida té...PHP Conference 2020 - A eterna luta: compatibilidade retroativa vs. dívida té...
PHP Conference 2020 - A eterna luta: compatibilidade retroativa vs. dívida té...
 
PHP SSO no Zentyal
PHP SSO no ZentyalPHP SSO no Zentyal
PHP SSO no Zentyal
 
Phprs meetup - deploys automatizados com gitlab
Phprs   meetup - deploys automatizados com gitlabPhprs   meetup - deploys automatizados com gitlab
Phprs meetup - deploys automatizados com gitlab
 
O que você precisa saber sobre chatbots
O que você precisa saber sobre chatbotsO que você precisa saber sobre chatbots
O que você precisa saber sobre chatbots
 
WCPOA2019 - WordPress como um backend de seus aplicativos
WCPOA2019  - WordPress como um backend de seus aplicativosWCPOA2019  - WordPress como um backend de seus aplicativos
WCPOA2019 - WordPress como um backend de seus aplicativos
 
WordPress como um backend de seus aplicativos
WordPress como um backend de seus aplicativosWordPress como um backend de seus aplicativos
WordPress como um backend de seus aplicativos
 
The Ultimate Guide to Development in WordPress
The Ultimate Guide to Development in WordPressThe Ultimate Guide to Development in WordPress
The Ultimate Guide to Development in WordPress
 
Precisamos de um barco maior introdução ao dimensionamento de aplicações
Precisamos de um barco maior introdução ao dimensionamento de aplicaçõesPrecisamos de um barco maior introdução ao dimensionamento de aplicações
Precisamos de um barco maior introdução ao dimensionamento de aplicações
 
Hangout Tempo Real Eventos - ChatOps (ChatBots e DevOps) - Como bots podem ...
Hangout  Tempo Real Eventos - ChatOps (ChatBots e DevOps)  - Como bots podem ...Hangout  Tempo Real Eventos - ChatOps (ChatBots e DevOps)  - Como bots podem ...
Hangout Tempo Real Eventos - ChatOps (ChatBots e DevOps) - Como bots podem ...
 
Hangout Tempo Real Eventos - Android - Os primeiros passos do desenvolviment...
Hangout  Tempo Real Eventos - Android - Os primeiros passos do desenvolviment...Hangout  Tempo Real Eventos - Android - Os primeiros passos do desenvolviment...
Hangout Tempo Real Eventos - Android - Os primeiros passos do desenvolviment...
 
Hangout Tempo Real Eventos - Javascript - Os Primeiros Passos
Hangout  Tempo Real Eventos - Javascript - Os Primeiros PassosHangout  Tempo Real Eventos - Javascript - Os Primeiros Passos
Hangout Tempo Real Eventos - Javascript - Os Primeiros Passos
 
Hangout Tempo Real Eventos - Nodejs - Os Primeiros Passos
Hangout  Tempo Real Eventos - Nodejs - Os Primeiros PassosHangout  Tempo Real Eventos - Nodejs - Os Primeiros Passos
Hangout Tempo Real Eventos - Nodejs - Os Primeiros Passos
 
Desmistificando o DialogFlow
Desmistificando o DialogFlowDesmistificando o DialogFlow
Desmistificando o DialogFlow
 
ChatOps (ChatBots + DevOps)
ChatOps (ChatBots + DevOps) ChatOps (ChatBots + DevOps)
ChatOps (ChatBots + DevOps)
 
Conexao kinghost - Vendas inteligentes com intelibots
Conexao kinghost - Vendas inteligentes com intelibotsConexao kinghost - Vendas inteligentes com intelibots
Conexao kinghost - Vendas inteligentes com intelibots
 
Dev Heroes
Dev HeroesDev Heroes
Dev Heroes
 
Trilha Android - Android Evolved
Trilha Android - Android EvolvedTrilha Android - Android Evolved
Trilha Android - Android Evolved
 
Material design
Material designMaterial design
Material design
 
Phalcon 2 - PHP Brazil Conference
Phalcon 2 - PHP Brazil ConferencePhalcon 2 - PHP Brazil Conference
Phalcon 2 - PHP Brazil Conference
 
Php Conference Brazil - Phalcon Giant Killer
Php Conference Brazil - Phalcon Giant KillerPhp Conference Brazil - Phalcon Giant Killer
Php Conference Brazil - Phalcon Giant Killer
 

Recently uploaded

Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRLLucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
imonikaupta
 
💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
nirzagarg
 
( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...
( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...
( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...
nilamkumrai
 
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men 🔝mehsana🔝 Escorts...
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men  🔝mehsana🔝   Escorts...➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men  🔝mehsana🔝   Escorts...
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men 🔝mehsana🔝 Escorts...
nirzagarg
 
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 
📱Dehradun Call Girls Service 📱☎️ +91'905,3900,678 ☎️📱 Call Girls In Dehradun 📱
📱Dehradun Call Girls Service 📱☎️ +91'905,3900,678 ☎️📱 Call Girls In Dehradun 📱📱Dehradun Call Girls Service 📱☎️ +91'905,3900,678 ☎️📱 Call Girls In Dehradun 📱
📱Dehradun Call Girls Service 📱☎️ +91'905,3900,678 ☎️📱 Call Girls In Dehradun 📱
@Chandigarh #call #Girls 9053900678 @Call #Girls in @Punjab 9053900678
 

Recently uploaded (20)

Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRLLucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
 
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
 
💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
 
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
 
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service AvailableCall Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
 
( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...
( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...
( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...
 
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
 
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...
 
Pirangut | Call Girls Pune Phone No 8005736733 Elite Escort Service Available...
Pirangut | Call Girls Pune Phone No 8005736733 Elite Escort Service Available...Pirangut | Call Girls Pune Phone No 8005736733 Elite Escort Service Available...
Pirangut | Call Girls Pune Phone No 8005736733 Elite Escort Service Available...
 
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
 
APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53
 
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men 🔝mehsana🔝 Escorts...
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men  🔝mehsana🔝   Escorts...➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men  🔝mehsana🔝   Escorts...
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men 🔝mehsana🔝 Escorts...
 
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency""Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
 
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
 
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
 
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrStory Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
 
Katraj ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For S...
Katraj ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For S...Katraj ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For S...
Katraj ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For S...
 
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubai
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls DubaiDubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubai
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubai
 
Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...
Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...
Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...
 
📱Dehradun Call Girls Service 📱☎️ +91'905,3900,678 ☎️📱 Call Girls In Dehradun 📱
📱Dehradun Call Girls Service 📱☎️ +91'905,3900,678 ☎️📱 Call Girls In Dehradun 📱📱Dehradun Call Girls Service 📱☎️ +91'905,3900,678 ☎️📱 Call Girls In Dehradun 📱
📱Dehradun Call Girls Service 📱☎️ +91'905,3900,678 ☎️📱 Call Girls In Dehradun 📱
 

WoMakersCode 2016 - Shit Happens

  • 1.
  • 2. Empower is the first step for new revolutions The first step in any revolution is going to be the moment of realization. If you've had enough, and are ready to commit to your dreams, that is when the real revolution begins. So i ask you...have YOU had enough? O primeiro passo para qualquer revolução vai ser o momento da realização. Se você já teve o suficiente, e está pronto para comprometer-se a seus sonhos, que é quando a verdadeira revolução começa. Então pergunto a vocês ... Vocês já tem o suficiente?
  • 3. Shit happens Centralize logs and get your insight into the errors that affect your customers.
  • 4.
  • 6. Jackson F. de A. Mafra http://about.me/jacksonfdam https://bitbucket.org/jacksonfdam https://github.com/jacksonfdam http://linkedin.com/in/jacksonfdam @jacksonfdam Software Engineer at Aggrega Group, mobile training instructor at Targettrust. Developer for 15 years with background in e- commerce projects and real estate, since 2009 with focused interests for the development of mobile and MEAP and applications interfaces.
  • 7. Aspect oriented programming (AOP) allows us to keep implement different concerns in isolation
  • 9.
  • 10. The term Aspect-Oriented Programming took shape in the mid-1990s, inside a small group at Xerox Palo Alto Research Center (PARC). AOP was considered controversial in its early days — as is the case with any new and interesting technology — mostly due to its lack of clear definition. The group made the conscious decision to release it in a half-baked form, in order to let the larger community provide feedback. At the heart of the problem was the "Separation of Concerns" concept. AOP was one possible solution to separate concerns.
  • 11. Whereas DI helps you decouple your application objects from each other, AOP helps you decouple cross-cutting concerns from the objects that they affect.
  • 12. A PHP Developers Perspective... Aspect Oriented Programming/Architecture is a practice in SOLID design principles. It is an attempt to further abstract specific cross application concerns within your code - using a techinique to intercept points within your call stack to perform specific functionality at given times.
  • 13. A PHP Developers Perspective... Concerns, like security, cut across the natural units of modularity. For PHP the natural unit of modularity is the class. But in PHP crosscutting concerns are not easily turned into classes precisely because they cut across classes, and so these aren’t reusable, they can’t be refined or inherited, they are spread through out the program in an undisciplined way, in short, they are difficult to work with.
  • 14. Why?
  • 15. Centralize concerns implementation More reusable code Cleaner code Write less code Easy to understand More maintainable Less boilerplate code More interesting work Why AOP?
  • 18. Aspects are often described in terms of advice, pointcuts, and join points. Terminology
  • 19. Advice defines what needs to be applied and when. Jointpoint is where the advice is applied. Pointcut is the combination of different joinpoints where the advice needs to be applied. Aspect is applying the Advice at the pointcuts. Definitions
  • 21. Advice Types Method Method Method Method Exception Before advice After advice After returning advice Around advice Throws advice
  • 22. AOP is a PECL extension that enables you to use Aspect Oriented Programming in PHP, without the need to compile or proceed to any other intermediate step before publishing your code. The AOP extension is designed to be the easiest way you can think of for integrating AOP to PHP. AOP aims to allow separation of cross-cutting concerns (cache, log, security, transactions, ...) https://github.com/AOP-PHP/AOP AOP
  • 23. You can use pecl sudo pecl install aop-beta Installation
  • 25. Now you want your code to be safe, you don't want non admin users to be able to call authorize methods. Basic tutorial
  • 26. Add some code to check the credentials "IN" you UsersServices class. The drawback is that it will pollute your code, and your core service will be less readable. Let the clients have the responsibility to check the credentials when required. The drawbacks are that you will duplicate lots of code client side if you have to call the service from multiple places Add some kind of credential proxy that will check the credentials before calling the actual service. The drawbacks are that you will have to write some extra code, adding another class on the top of your services. What are your solutions ?
  • 27. Moreover, those solutions tends to increase in complexity while you are adding more cross-cutting concerns like caching or logging. What are your solutions ?
  • 28. That's where AOP comes into action as you will be able to tell PHP to do some extra actions while calling your MyServices's admin methods. What are your solutions ?
  • 29. So let's first write the rule needed to check if we can or cannot access the admin services. What are your solutions ?
  • 30. Dead simple : we check the current PHP session to see if there is something telling us the current user is an admin (Of course we do realize that you may have more complex routines to do that, be we'll keep this for the example) What are your solutions ?
  • 31. Now, let's use AOP to tell PHP to execute this method "before" any execution of admin methods. What are your solutions ?
  • 32. Now, each time you'll invoke a method of an object of the class UsersServices, starting by authorize, AOP will launch the function basicAdminChecker before the called method. What are your solutions ?
  • 33.
  • 34. Logging is an important part of the app development/maintenance cycle. Logging
  • 35.
  • 36. To know the best method of logging data of different contexts for specific environments such as test/dev and production Take Away
  • 37. Even with use of computers there was a real need to measure the overall performance of any reasearch Early 1980's there was a Instrument called VELA (virtual laboratory) used for data harvesting History of Logging
  • 38. Late 1980's, A device was invented to collect information through sensors Later then data logging/harvesting has been used widely in all applications/reasearches/ products. History of Logging
  • 39. Track Users activity/Movement Transaction Logging Track user errors System level failures/warnings Research Data collection and Interpretation Need of Logging
  • 40. Error / Exception logs Access logs System logs Application logs Database logs Transaction logs Mailer logs etc... Types of Logging
  • 42. Debug Information - Errors (connections, uncaught exceptions, resource exhaustion) Narrative Information - Methods Calls, Event Triggers Business Events - Purchases, Logins, Registrations, Unsubscribes Application Log
  • 43. ssh webserver@mydomain.net tail -f /var/log/nginx/my-site.access.log tail -f /var/log/my.application.log ssh data@mydomain.net tail -f /var/log/mysql/mysql.log ssh q@mydomain.net tail -f /var/log/rabbitmq/nodename.log Keeping Track Of All This
  • 44. Apache/PHP <VirtualHost *:80> <Directory /var/www/html/> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> Current Conventions
  • 45. Monolog is a PHP library that support different levels of logging for PHP Applications and depends on PSR. Inspired by Python Logbook library Provides stack of handlers More Powerful than conventional way of logging in applications Monolog Enters Here
  • 46. Monolog sends your logs to files, sockets, inboxes, databases and various web services. Channel based approach Different stack of handlers for specific channels Pile up handler stack based on severity. Format Interpretation depending on severity and channel Prevents Bubbling when severity is reached What's different ?
  • 47. Log Levels 2013 - PSR03 - PHP Logging Interface Standard Phrase / Severity emergency Emergency: system is unusable alert Alert: action must be taken immediately critical Critical: critical conditions error Error: error conditions warning Warning: warning conditions notice Notice: normal but significant condition info Informational: informational messages debug Debug: debug-level messages http://www.php-fig.org/psr/psr-3/ Log Levels
  • 48. What about Apache’s error_log?
  • 49.
  • 50. error_log is too basic (message, file, line) difficult to read / parse depends on “error_reporting” setting Why?
  • 51.
  • 52. monolog phpconsole log4php RavenPHP + Sentry FirePHP (dev environment) Roll your own Logging Options Logging Options
  • 53. Fire & forget Minimum or zero latency Highly available Should be PSR-3 compatible Log everything: - Exceptions - Errors - Fatal Errors Requirements (for everyone)
  • 54. Typical PSR-3 Compatible Design Capture Method Logger (PSR-3) Handler / Adapter Data Storage
  • 56. Option to have different channel for different module Custom detailing Different handlers for different development Thorough participation in different stages of lifecycle Open for third party integration Readable and Beautiful Layered message Advantages
  • 57. PSR-3 makes it easy However you want… Monolog has loads: - syslog-compatible / error_log - Email, HipChat - AMQP, Sentry, Zend Monitor, Graylog2 - Redis, MongoDB, CouchDB Sending Log Messages
  • 58. CakePHP - https://github.com/jadb/cakephp-monolog Symfony2 - https://github.com/symfony/MonologBundle Slim – https://github.com/flynsarmy/Slim-Monolog Zend2 - https://packagist.org/packages/enlitepro/enlite-monolog CodeIgniter - https://github.com/pfote/Codeigniter-Monolog Laravel – Inbuilt Support. Drupal - https://drupal.org/project/monolog Wordpress - https://packagist.org/packages/fancyguy/wordpress- monolog more: https://github.com/Seldaek/monolog#frameworks-integration Do you use Frameworks / CMS ?
  • 59. Monolog is available on Packagist, which means that you can install it via Composer. composer require 'monolog/monolog:1.13.*' Installation
  • 66. Stop logging exceptions the old fashioned way.
  • 67.
  • 69. Indexing and search engine Near real-time Distributed, auto-discover clustering – AWS Plugin Elasticsearch
  • 70. Collects logs Parses, extracts and formats data Passes data to Elasticsearch Logstash
  • 71. example filter { if [file] == "/var/log/secure" and ( [syslog_message] =~ /Invalid user/ or [syslog_message] =~ /User root from/ ) { grok { add_tag => [ "LOGIN" ] match => {"syslog_message" => “user %{ WORD:username} from %{IP:srcip}" } } } } Logstash
  • 72. Web interface to query Elasticsearch node.js Kibana
  • 76. THERE IS ALWAYS A DELAY
  • 77. HOW MUCH DELAY CAN YOU ACCEPT?