Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
[Server] Fix metric parse error: expected timestamp at 1:281 in Inf…
Browse files Browse the repository at this point in the history
…luxDB endpoint
  • Loading branch information
blackandred committed May 13, 2020
1 parent b62d085 commit ec78f9f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,6 @@ public function format(array $toFormat, string $baseUrl, string $appEnv): string
}
}

return $formattedAsInflux . ' ' . implode(',', $metricsToGlue) . ' ' . $this->getCurrentTimestamp() . 'us';
}

private function getCurrentTimestamp(): string
{
list($uSec, $sec) = explode(' ', microtime());

return sprintf('%d%06d', $sec, $uSec*1000000);
return $formattedAsInflux . ' ' . implode(',', $metricsToGlue);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,6 @@ public function testAppEnvAndBaseUrlArePresentAsTags(): void
$formatter = new InfluxDBMetricsFormatter();
$formatted = $formatter->format(['data' => []], 'http://localhost', 'test');

$this->assertStringContainsString('backup_repository_report,base_url="http://localhost",app_env="test" ', $formatted);
}

public function testTimestampIsPresentAtTheEndOfMetricString(): void
{
$formatter = new InfluxDBMetricsFormatter();
$formatted = $formatter->format(['data' => []], 'http://localhost', 'test');

$exp = explode(' ', $formatted);

$this->assertIsNumeric(str_replace('us', '', $exp[count($exp) - 1]));
$this->assertStringContainsString('backup_repository_report,base_url="http://localhost",app_env="test" ', $formatted);
}
}

0 comments on commit ec78f9f

Please sign in to comment.