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

Let's talk about Metrics 2.0 #27

Closed lyrixx closed 9 years ago

lyrixx commented 9 years ago

fixes #24

lyrixx commented 9 years ago

About the lib:

What do you think?

lyrixx commented 9 years ago

Actually, I did not see that the Factory and the Registry where used in the Bundle. So now, I just want to remove the functions.php ;)

lyrixx commented 9 years ago

And finally, The bundle does't use the Factory nor the Registry anymore...

stof commented 9 years ago

I would rather keep tests in a separate folder rather than nesting them inside the library codebase

lyrixx commented 9 years ago

I would rather keep tests in a separate folder rather than nesting them inside the library codebase

Why? Symfony and lot of other lib share the same folder

stof commented 9 years ago

Why? Symfony and lot of other lib share the same folder

Symfony has it in the code because of the subtree splits which should include tests. Before that, they were in a separate folder

lyrixx commented 9 years ago

I know, But it there a valid reason to have 2 different folders? For me, tests are part of code, and so should live inside the same folder.

adrienbrault commented 9 years ago

Disappointed that functions.php is gone. It was awesome being able to add the metrics functions to my code without having to update tests

lyrixx commented 9 years ago

1/ You can still use version 1.X 2/ IMHO, it's a bad practice to use a "Singleton". It's better to inject a Collector inside your code. More over, if you don't want to update your tests, you can use this kind of code:

use Beberlei\Metrics\Collector\Collector;
use Beberlei\Metrics\Collector\Null;

class ServiceFooBar
{
    private $collector;

    public function __construct(Collector $collector = null)
    {
        $this->collector = $collector ?: new Null();
    }
//.....

I always use this "hack" for a logger / collector / ...