public static function create(array $config = [])
    {
        $config        = self::mergeDefaults($config);
        $metricFactory = new MetricFactory($config['default_tags'], $config['prefix']);
        $eventFactory  = new EventFactory($config['hostname']);
        $logger        = $config['logger']['instance'] instanceof LoggerInterface ? $config['logger']['instance'] : null;
        $debug         = $config['logger']['debug'];
        $monitor       = new Monitor($metricFactory, $eventFactory, $debug ? $logger : null);

        if (!empty($config['datadog']['metrics'])) {
            $monitor->pushMetricSender(DataDogMetrics::create($config['datadog']['host'], $config['datadog']['port']));
        }

        if (!empty($config['datadog']['events'])) {
            $monitor->pushEventSender(DataDogEvents::create($config['datadog']['host'], $config['datadog']['port']));
        }

        if ($logger && $config['logger']['metrics']) {
            $monitor->pushMetricSender(new PsrLoggerMetrics($logger), $config['logger']['level']);
        }

        if ($logger && $config['logger']['events']) {
            $monitor->pushEventSender(new PsrLoggerEvents($logger), $config['logger']['level']);
        }

        return $monitor;
    }
public static function create(array $config = [])
    {
        $config        = self::mergeDefaults($config);
        $metricFactory = new MetricFactory($config['default_tags'], $config['prefix']);
        $eventFactory  = new EventFactory($config['hostname']);
        $logger        = $config['logger']['instance'] instanceof LoggerInterface ? $config['logger']['instance'] : null;
        $debug         = $config['logger']['debug'];
        $monitor       = new Monitor($metricFactory, $eventFactory, $debug ? $logger : null);

        if (!empty($config['datadog']['metrics'])) {
            $monitor->pushMetricSender(DataDogMetrics::create($config['datadog']['host'], $config['datadog']['port']));
        }

        if (!empty($config['datadog']['events'])) {
            $monitor->pushEventSender(DataDogEvents::create($config['datadog']['host'], $config['datadog']['port']));
        }

        if ($logger && $config['logger']['metrics']) {
            $monitor->pushMetricSender(new PsrLoggerMetrics($logger), $config['logger']['level']);
        }

        if ($logger && $config['logger']['events']) {
            $monitor->pushEventSender(new PsrLoggerEvents($logger), $config['logger']['level']);
        }

        return $monitor;
    }
public static function create ( array $ config = [ ] ) { $ config = self :: mergeDefaults ( $ config ) ; $ metricFactory = new MetricFactory ( $ config [ 'default_tags' ] , $ config [ 'prefix' ] ) ; $ eventFactory = new EventFactory ( $ config [ 'hostname' ] ) ; $ logger = $ config [ 'logger' ] [ 'instance' ] instanceof LoggerInterface ? $ config [ 'logger' ] [ 'instance' ] : null ; $ debug = $ config [ 'logger' ] [ 'debug' ] ; $ monitor = new Monitor ( $ metricFactory , $ eventFactory , $ debug ? $ logger : null ) ; if ( ! empty ( $ config [ 'datadog' ] [ 'metrics' ] ) ) { $ monitor -> pushMetricSender ( DataDogMetrics :: create ( $ config [ 'datadog' ] [ 'host' ] , $ config [ 'datadog' ] [ 'port' ] ) ) ; } if ( ! empty ( $ config [ 'datadog' ] [ 'events' ] ) ) { $ monitor -> pushEventSender ( DataDogEvents :: create ( $ config [ 'datadog' ] [ 'host' ] , $ config [ 'datadog' ] [ 'port' ] ) ) ; } if ( $ logger && $ config [ 'logger' ] [ 'metrics' ] ) { $ monitor -> pushMetricSender ( new PsrLoggerMetrics ( $ logger ) , $ config [ 'logger' ] [ 'level' ] ) ; } if ( $ logger && $ config [ 'logger' ] [ 'events' ] ) { $ monitor -> pushEventSender ( new PsrLoggerEvents ( $ logger ) , $ config [ 'logger' ] [ 'level' ] ) ; } return $ monitor ; }
Creates a monitor in a single command by passing a configuration

See the method 'mergeDefaults' for info on the config format

@param array $config

@return Monitor
Creates a monitor in a single command by passing a configuration