Filter loggers with zero-ish values.

@param array $loggers
@param array $metrics
@return array
428235
private static function shine_spotlight( $loggers, $metrics ) {

		foreach ( $loggers as $k => $logger ) {
			$non_zero = false;
			foreach ( $metrics as $metric ) {
				switch ( $metric ) {
					// 100% cache ratio is fine by us
					case 'cache_ratio':
					case 'cache_hits':
					case 'cache_misses':
						if ( $logger->cache_ratio && '100%' !== $logger->cache_ratio ) {
							$non_zero = true;
						}
						break;
					case 'time':
					case 'query_time':
						if ( $logger->$metric > 0.01 ) {
							$non_zero = true;
						}
						break;
					default:
						if ( $logger->$metric ) {
							$non_zero = true;
						}
						break;
				}
			}
			if ( ! $non_zero ) {
				unset( $loggers[ $k ] );
			}
		}

		return $loggers;
	}
1370060
public static function removeLogger($logger)
    {
        if ($logger instanceof Logger) {
            if (false !== ($idx = array_search($logger, self::$loggers, true))) {
                unset(self::$loggers[$idx]);
            }
        } else {
            unset(self::$loggers[$logger]);
        }
    }
57580
public function getPoints($metric, $tags, $granularity, $endDt, $timezone = 'utc') {
        if ( null == $metric ) {
            return [];
        }
        
        $where = [];

        $now = $this->normalizeUTC(date("Y-m-d H:i:s"));
        
        $min = intval(date('i'));
        $minutes = $min > 45 ? 45 : ( $min > 30 ? 30 : ( $min > 15 ? 15 : '00') );       
        $lastHourDt = date("Y-m-d") . "T" . date('H') . ":$minutes:00Z";
        
        if (strtotime($endDt) < strtotime($lastHourDt)) {
           return [];
        }
        
        $where[] = "time >= '" . $lastHourDt . "' AND time <= '" . $now  . "'";
        
        foreach ($tags as $key => $val) {
            $where[] = "$key = '" . $val . "'";
        }
        
        $query = $this->db->getQueryBuilder()
                ->sum('value')
                ->from($metric)
                ->where($where);

        $groupBy = "time(1d) tz('" . $timezone . "')";
        if ($granularity == self::GRANULARITY_HOURLY) {
            $groupBy = "time(1h) tz('" . $timezone . "')";
        } else if ($granularity == self::GRANULARITY_DAILY) {
            $groupBy = "time(1d) tz('" . $timezone . "')";
        } else if ($granularity == self::GRANULARITY_WEEKLY) {
            $groupBy = "time(1w) tz('" . $timezone . "')";
        }
        $query->groupBy($groupBy);
        
        return $query->getResultSet()->getPoints();        
    }
855330
protected static function getLogLevel(array $arguments)
    {
        $argumentsForSearch = implode(' ', $arguments);
        foreach (static::$levels as $argumentPattern => $currentLevel) {
            if (strpos($argumentsForSearch, $argumentPattern) !== false) {
                return $currentLevel;
            }
        }

        return LogLevel::ERROR;
    }
1198022
@Override
  public SortedMap<String, Counter> getCounters(MetricFilter filter) {
    return this.innerMetricContext.getCounters(filter);
  }
172367
public function readDiffLogs(array $logs)
    {
        $diffs = array();
        $lineNumOld = 0;
        $lineNumNew = 0;
        foreach ($logs as $log) {
            if ('diff' === substr($log, 0, 4)) {
                if (isset($diff)) {
                    $diffs[] = $diff;
                }

                $diff = new Diff();
                if (preg_match('/^diff --[\S]+ a\/?(.+) b\/?/', $log, $name)) {
                    $diff->setFile($name[1]);
                }
                continue;
            }

            if ('index' === substr($log, 0, 5)) {
                $diff->setIndex($log);
                continue;
            }

            if ('---' === substr($log, 0, 3)) {
                $diff->setOld($log);
                continue;
            }

            if ('+++' === substr($log, 0, 3)) {
                $diff->setNew($log);
                continue;
            }

            // Handle binary files properly.
            if ('Binary' === substr($log, 0, 6)) {
                $m = array();
                if (preg_match('/Binary files (.+) and (.+) differ/', $log, $m)) {
                    $diff->setOld($m[1]);
                    $diff->setNew("    {$m[2]}");
                }
            }

            if (!empty($log)) {
                switch ($log[0]) {
                    case '@':
                        // Set the line numbers
                        preg_match('/@@ -([0-9]+)/', $log, $matches);
                        $lineNumOld = $matches[1] - 1;
                        $lineNumNew = $matches[1] - 1;
                        break;
                    case '-':
                        $lineNumOld++;
                        break;
                    case '+':
                        $lineNumNew++;
                        break;
                    default:
                        $lineNumOld++;
                        $lineNumNew++;
                }
            } else {
                $lineNumOld++;
                $lineNumNew++;
            }

            if ($diff) {
                $diff->addLine($log, $lineNumOld, $lineNumNew);
            }
        }

        if (isset($diff)) {
            $diffs[] = $diff;
        }

        return $diffs;
    }
104122
public void setLoggers(java.util.Collection<Logger> loggers) {
        if (loggers == null) {
            this.loggers = null;
            return;
        }

        this.loggers = new java.util.ArrayList<Logger>(loggers);
    }
867157
public static function hasLogger($logger)
    {
        if ($logger instanceof Logger) {
            $index = array_search($logger, self::$loggers, true);

            return false !== $index;
        } else {
            return isset(self::$loggers[$logger]);
        }
    }
77712
public static function setupFromArray(array $loggers) {
        foreach ($loggers as $logger) {
            if (!isset($logger['class'])) {
                throw new LoggerManagerException('Each logger configuration defined in the file [' . $configurationFilePath . '] has to define a "class" property');
            }
            if (!is_string($logger['class'])) {
                throw new LoggerManagerException('Each logger configuration defined in the file [' . $configurationFilePath . '] has to define a "class" property, as a string');
            }
            if (!isset($logger['level'])) {
                throw new LoggerManagerException('Each logger configuration defined in the file [' . $configurationFilePath . '] has to define a "level" property');
            }
            if (!is_string($logger['level'])) {
                throw new LoggerManagerException('Each logger configuration defined in the file [' . $configurationFilePath . '] has to define a "level" property, as a string');
            }
            if (!isset($logger['writers'])) {
                throw new LoggerManagerException('Each logger configuration defined in the file [' . $configurationFilePath . '] has to define a "writers" property');
            }
            if (!is_array($logger['writers'])) {
                throw new LoggerManagerException('Each logger configuration defined in the file [' . $configurationFilePath . '] has to define a "writers" property, as an array');
            }
        }

        self::$_loggers = $loggers;
    }
130393
public static MetricsLogger getMetricsLogger(final String dimensions) {
        if (MetricsManager.instance != null) {
            final Map<String, String> dimensionsMap = DimensionsUtils.parseDimensions(dimensions);
            if (!dimensionsMap.isEmpty()) {
                dimensionsMap.put("service", MetricsManager.instance.serviceName);
                if (MetricsManager.instance.env.length() > 0) {
                    dimensionsMap.put("env", MetricsManager.instance.env);
                }
                return MetricsManager.instance.metricsLoggers.computeIfAbsent(
                        DimensionsUtils.serializeDimensionsToString(dimensionsMap), key -> new MetricsLogger(dimensionsMap));
            } else {
                throw new IllegalArgumentException("Dimensions must be valid and non-empty");
            }
        }
        return dummyLogger;
    }
1046858
@SuppressWarnings("rawtypes")
    public SortedMap<String, Gauge> getGauges(MetricFilter filter) {
        return getMetrics(Gauge.class, filter);
    }
577177
static void flushMetricsLogger(final MetricsLogger metricsLogger) {
        metricsLogger.flushToString(MetricsManager::queue);
        MetricsManager.rootMetricsLogger.flushToString(MetricsManager::queue);
    }
576053
public function gauge($metric, $level, array $tags = array(), $sampleRate = AbstractMetric::DEFAULT_SAMPLE_RATE)
    {
        return new Gauge($this->prefix($metric), $level, array_merge($this->defaultTags, $tags), $sampleRate);
    }
51069
public function endTiming($metric, array $tags = array())
    {
        $timer_start = $this->metricTiming[$metric];
        $timer_end = microtime(true);
        $time = round(($timer_end - $timer_start) * 1000, 4);
        return $this->timing($metric, $time, $tags);
    }
90122
protected function configureLoggers(array $loggers)
    {
        foreach ($loggers as $loggerName => $loggerOptions) {
            $loggerLoader = new LoggerLoader($loggerName, $loggerOptions, $this->handlers, $this->processors);
            $this->loggers[$loggerName] = $loggerLoader->load();
        }
    }
108583
private static void printMetrics(MetricArray metrics) {
        System.out.println();

        if (metrics.size() == 0) {
            System.out.println("No metrics found.");
            return;
        }

        List<List<String>> data = new ArrayList<>();
        List<String> flags = Arrays.asList("", "-");

        for (Metric metric : metrics) {
            data.add(Arrays.asList(metric.getName(), metric.getValue()));
        }

        new CliTablePrinter.Builder()
                .data(data)
                .flags(flags)
                .delimiterWidth(2)
                .build()
                .printTable();
    }
1334672
protected function _merge($metrics = [], $line = false)
    {
        $defaults = [
            'loc'      => [],
            'nlloc'    => [],
            'lloc'     => [],
            'cloc'     => [],
            'files'    => [],
            'methods'  => 0,
            'cmethods' => 0
        ];
        $metrics += $defaults;

        foreach (['loc', 'nlloc', 'lloc', 'cloc', 'coverage', 'files', 'methods', 'cmethods'] as $name) {
            $metrics[$name] += $this->_metrics[$name];
        }
        if (!$line) {
            unset($metrics['line']);
        }
        $this->data($metrics);
    }