endclothing / prometheus_client_php

Prometheus instrumentation library for PHP applications
https://prometheus.io/docs/concepts/metric_types/
Apache License 2.0
150 stars 77 forks source link

Add a helper method observeExecution #42

Open ns3777k opened 4 years ago

ns3777k commented 4 years ago

Hey!

What do you think about adding a helper method observeExecution to Histogram class:

public function observeExecution(callable $fn, array $labels = []): void
{
    $start = microtime(true);
    $fn();
    $duration = microtime(true) - $start;
    $this->observe($duration, $labels);
}

Can make a PR.