/** * Returns an array, indexed by provider name, of telemetry data gathered during the period defined by $start to $end * * @param string|array|null $providers The providers to query * @param string|int|null $start The period start (greater or equal to >=). Null == today * @param string|int|null $end The period end (less than <). Null == today * @param bool $store If true, the response is stored for posterity * * @return array */ public function getTelemetry($providers = null, $start = null, $end = null, $store = true) { $_providers = $providers ?: $this->providers; is_string($_providers) && ($_providers = [$_providers]); // Identify our data $_telemetry = ['_meta' => ['source-uri' => config('app.url', \Request::getSchemeAndHttpHost()), 'request-timestamp' => Carbon::now(), 'request-host' => 'cli' == PHP_SAPI ? 'localhost' : \Request::getSchemeAndHttpHost(), 'request-ip' => 'cli' == PHP_SAPI ? ['127.0.0.1'] : \Request::getClientIps()]]; foreach ($_providers as $_provider) { $_telemetry[$_provider] = $this->make($_provider)->getTelemetry(); } $store && Telemetry::storeTelemetry(TelemetryServiceProvider::IOC_NAME, $_telemetry); return is_string($providers) ? current($_telemetry) : $_telemetry; }
/** * @param array $telemetry * * @return static * @throws \DreamFactory\Enterprise\Common\Exceptions\NotImplementedException */ protected function store($telemetry = []) { return Telemetry::storeTelemetry($this->getProviderId(), $telemetry); }