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

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 2016Joe Ferguson
 
Product! - The road to production deployment
Product! - The road to production deploymentProduct! - The road to production deployment
Product! - The road to production deploymentFilippo Zanella
 
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...Joe Ferguson
 
Top 30 Scalability Mistakes
Top 30 Scalability MistakesTop 30 Scalability Mistakes
Top 30 Scalability MistakesJohn Coggeshall
 
Throwing Laravel into your Legacy App™
Throwing Laravel into your Legacy App™Throwing Laravel into your Legacy App™
Throwing Laravel into your Legacy App™Joe Ferguson
 
NET Event - Migrating WinForm
NET Event - Migrating WinFormNET Event - Migrating WinForm
NET Event - Migrating WinFormRaffaele Garofalo
 
An Introduction to Microservices
An Introduction to MicroservicesAn Introduction to Microservices
An Introduction to MicroservicesAd van der Veer
 
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.pptxsarah david
 
System design for Web Application
System design for Web ApplicationSystem design for Web Application
System design for Web ApplicationMichael Choi
 
Aspect Oriented Software Development
Aspect Oriented Software DevelopmentAspect Oriented Software Development
Aspect Oriented Software DevelopmentJignesh Patel
 
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-20Dennis de Greef
 
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 HelpNarola Infotech
 
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 WorldLorna Mitchell
 
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-10Dennis de Greef
 
Cs121 Unit Test
Cs121 Unit TestCs121 Unit Test
Cs121 Unit TestJill Bell
 
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.pdfsarah david
 
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 2015Mirco Hering
 

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

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é...Jackson F. de A. Mafra
 
Phprs meetup - deploys automatizados com gitlab
Phprs   meetup - deploys automatizados com gitlabPhprs   meetup - deploys automatizados com gitlab
Phprs meetup - deploys automatizados com gitlabJackson F. de A. Mafra
 
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 chatbotsJackson F. de A. Mafra
 
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 aplicativosJackson F. de A. Mafra
 
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 aplicativosJackson F. de A. Mafra
 
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 WordPressJackson F. de A. Mafra
 
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çõesJackson F. de A. Mafra
 
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 ...Jackson F. de A. Mafra
 
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...Jackson F. de A. Mafra
 
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 PassosJackson F. de A. Mafra
 
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 PassosJackson F. de A. Mafra
 
Conexao kinghost - Vendas inteligentes com intelibots
Conexao kinghost - Vendas inteligentes com intelibotsConexao kinghost - Vendas inteligentes com intelibots
Conexao kinghost - Vendas inteligentes com intelibotsJackson F. de A. Mafra
 
Php Conference Brazil - Phalcon Giant Killer
Php Conference Brazil - Phalcon Giant KillerPhp Conference Brazil - Phalcon Giant Killer
Php Conference Brazil - Phalcon Giant KillerJackson 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

Gram Darshan PPT cyber rural in villages of india
Gram Darshan PPT cyber rural  in villages of indiaGram Darshan PPT cyber rural  in villages of india
Gram Darshan PPT cyber rural in villages of indiaimessage0108
 
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779Delhi Call girls
 
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024APNIC
 
10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls
10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls
10.pdfMature Call girls in Dubai +971563133746 Dubai Call girlsstephieert
 
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts servicesonalikaur4
 
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012rehmti665
 
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call GirlVIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girladitipandeya
 
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Russian Call Girls in Kolkata Ishita 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Ishita 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Ishita 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Ishita 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
Networking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOGNetworking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOGAPNIC
 
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts servicevipmodelshub1
 
Radiant Call girls in Dubai O56338O268 Dubai Call girls
Radiant Call girls in Dubai O56338O268 Dubai Call girlsRadiant Call girls in Dubai O56338O268 Dubai Call girls
Radiant Call girls in Dubai O56338O268 Dubai Call girlsstephieert
 
On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024APNIC
 
Challengers I Told Ya ShirtChallengers I Told Ya Shirt
Challengers I Told Ya ShirtChallengers I Told Ya ShirtChallengers I Told Ya ShirtChallengers I Told Ya Shirt
Challengers I Told Ya ShirtChallengers I Told Ya Shirtrahman018755
 
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...SofiyaSharma5
 

Recently uploaded (20)

Gram Darshan PPT cyber rural in villages of india
Gram Darshan PPT cyber rural  in villages of indiaGram Darshan PPT cyber rural  in villages of india
Gram Darshan PPT cyber rural in villages of india
 
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
 
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
 
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
 
10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls
10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls
10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls
 
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
 
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
 
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call GirlVIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
 
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
 
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
 
Russian Call Girls in Kolkata Ishita 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Ishita 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Ishita 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Ishita 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
Networking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOGNetworking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOG
 
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
 
Call Girls In South Ex 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICE
Call Girls In South Ex 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICECall Girls In South Ex 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICE
Call Girls In South Ex 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICE
 
Radiant Call girls in Dubai O56338O268 Dubai Call girls
Radiant Call girls in Dubai O56338O268 Dubai Call girlsRadiant Call girls in Dubai O56338O268 Dubai Call girls
Radiant Call girls in Dubai O56338O268 Dubai Call girls
 
On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024
 
Challengers I Told Ya ShirtChallengers I Told Ya Shirt
Challengers I Told Ya ShirtChallengers I Told Ya ShirtChallengers I Told Ya ShirtChallengers I Told Ya Shirt
Challengers I Told Ya ShirtChallengers I Told Ya Shirt
 
Rohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No AdvanceRohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
 
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
 

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?