Collecting Stats behind the scenes with Laravel 5

Integrating Graphite in your apps

Information is always welcome and, in a real and professional environment, it is a must. Monitoring is very common in the "sys" side. Yup, these people (?), sysadmins are all the day typing in a shell, but, believe it or not they  also like charts and graphs. Likely you have heard or you know about monitoring stuff like Nagios, if you haven't yet, I recommend you to do it.
Well yes, they cpu-usage or net traffic is really important and it is really good to have this information, however, we developers would rather having some kind of different information. Imagine, how many queries your request are performing, what is the request per second ratio, or what is "whatever-you-can-imagine" ratio in you app.

Graphite, remember name. I'll add a second post to help you to install a Graphite/statsD server. Maybe you currently have a server like this or you just prefer using a statsd/graphite service. Anyways, if you don't know what Graphite is, the only thing you need to know it that it is a super fast (it uses UDP protocol) and versatile tool to collect stats. It is a system where 3 subsystems (StatsD, Whisper and Graphite) work together to take care of this.

Let's leave this here by now (I promise to write this second post shortly)

Ok, how can I send this cool stats to be collected. (Assuming that you have a statsD host somewhere just) use StatsCollector. As usual, just include the ServiceProvider and Facade, publish the config file, tweak your .env and your are ready to go. Optionally, include the Middleware within you 'web' middleware group, and just enjoy.