Download the PHP package michaelesmith/metric-data without Composer
On this page you can find all versions of the php package michaelesmith/metric-data. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download michaelesmith/metric-data
More information about michaelesmith/metric-data
Files in michaelesmith/metric-data
Package metric-data
Short Description Abstracts event data handling
License MIT
Homepage https://github.com/michaelesmith/EventData
Informations about the package metric-data
What is it?
This is a library that allows for easy abstraction of metric data collection and storage, allowing it to be stored locally or via external API.
Installation
composer require "michaelesmith/metric-data"
All About Metrics
For this library all data points are referred to as metrics and used via MetricData\Metric\MetricInterface
which defines 3 required methods getDateTime()
, getType()
and getData()
. You can implement the interface to define your own metrics based on your specific business logic but a few basic implementations are provided in:
MetricData\Metric\Metric
: Data can be any typeMetricData\Metric\IntegerMetric
: Data is typed to an integerMetricData\Metric\FloatMetric
: Data is typed to an floatMetricData\Metric\ArrayMetric
: Data is an array
Basic Storage Examples
This section will walk through examples for each of the storage types. In these examples when a child sotrage is needed a NullStorage
is generally used for illustration.
Closure
This storage allows you to quickly integrate virtually any backend via a closure. It is till recommend in most case to create a full blown extension class once you prototype the system and are ready for production.
Delayed
This storage allows you to queue up metric data during a request and the flush them to another storage, which will allow you to delay the possibly long processing time until after the response has been sent to the user.
File
This storage will store the metrics in a JOSN encoded file. This can be usefully for testing or if you want to process the events in mass with some other tool out of band of the user request / response cycle.
KeenIO
This storage allows you to send metric data to the KeenIO API.
Logging
This storage will log to a PSR-3 logger before passing the metric to a child storage.
Memory
This storage is not particularly useful in production but is very fast when used in a testing environment while still allowing for the storing of events to be tested.
Multiple
This storage allows metrics to be sent to multiple child storages.
Null
This storage is the equivalent of /dev/null
, any metric stored here will simple disappear into the ether. Not useful for production but can be used in scenarios where you don't need to store metrics like unit tests.
Advanced Storage Examples
While these storages can be used individually, their power comes from the ability to combine them to build powerful functionality specific to the needs of different application environments but which can easily interchange allowing the application to be unaware of the particular configuration.
Development
Testing
Production
Contributing
Have an idea to make something better? Submit a pull request. Need integration of some other backend service? Build it. I would be happy to add a link here. PR's make the open source world turn. :earth_americas: :earth_asia: :earth_africa: :octocat: Happy Coding!