beberlei / metrics

Simple library that abstracts different metrics collectors. I find this necessary to have a consistent and simple metrics (functional) API that doesn't cause vendor lock-in.
316 stars 38 forks source link

Add context logger #45

Closed davidfuhr closed 7 years ago

davidfuhr commented 8 years ago

The context logger makes use of the context array replacement feature defined in PSR-3. See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md#12-message for an example.

If you use monolog you should add the PsrLogMessageProcessor to your logger to enable replacement of the variables.

lyrixx commented 8 years ago

I know well logging and PSR3, but I really fail to see a valid use case for this logger here.

davidfuhr commented 8 years ago

We use text files as data store for metrics.

So we utilize the logger to write our data files with the JsonFormatter and the ContextLogger.

lyrixx commented 8 years ago

What is the ContextLogger ?

davidfuhr commented 8 years ago

The logger class introduced with this pull request.

lyrixx commented 8 years ago

I mean, I don't understand the point to write many lines like {type}:{variable} [type:foobar, varible 10] in a file.

davidfuhr commented 8 years ago

The lines look like this

{"message":"measure:my.metric.name:3.8000","context":{"type":"measure","variable":"my.metric.name","value":"3.8000"},"level":100,"level_name":"DEBUG","channel":"metrics","datetime":{"date":"2015-11-11 00:00:01.312270","timezone_type":3,"timezone":"Europe\/Berlin"},"extra":[]}

We have another application that parses these files and exposes the data through an API for our Metrics Dashboard for consumption.

lyrixx commented 8 years ago

So, you replace the {type} by the real type? So why not logging directly the real type to avoid a useless overhead

lyrixx commented 7 years ago

As there is not feedback, I'm closing this PR.