Skip to content

Commit 56472a8

Browse files
author
Илья
committed
Added application.php and added query latency
1 parent b50c1d7 commit 56472a8

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

slo-workload/application.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
require_once './vendor/autoload.php';
3+
/**
4+
* @var \YdbPlatform\Ydb\Slo\Command[] $commands
5+
*/
6+
$commands = [
7+
"create" =>new \YdbPlatform\Ydb\Slo\Commands\CreateCommand(),
8+
"run" =>new \YdbPlatform\Ydb\Slo\Commands\RunCommand(),
9+
"cleanup" =>new \YdbPlatform\Ydb\Slo\Commands\CleanupCommand()
10+
];
11+
12+
if ($argc == 1 || !isset($commands[$argv[1]])){
13+
echo "Commands:\n";
14+
foreach ($commands as $name=>$command) {
15+
echo "- ".$name."\t"."- ".$command->description."\n";
16+
}
17+
exit(0);
18+
}
19+
20+
if ($argc<4||substr($argv[2],0,4)!="grpc" || substr($argv[3],0,1)!="/"){
21+
echo $commands[$argv[1]]->help;
22+
exit(0);
23+
}
24+
25+
$data = $commands[$argv[1]]->generateOptions(array_slice($argv, 4));
26+
27+
$command = $commands[$argv[1]];
28+
29+
$commands[$argv[1]]->execute($argv[2],$argv[3], $data);

slo-workload/src/Commands/RunCommand.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ protected function metricsJob(int $reportPeriod, float $startTime, int $time, st
242242
$pushGateway = new PushGateway($promPgw);
243243

244244
$latencies = $registry->getOrRegisterSummary('', 'latency', 'summary of latencies in ms', ['jobName', 'status'], 15, [0.5, 0.99, 0.999]);
245+
$queryLatencies = $registry->getOrRegisterSummary('', 'query_latency', 'summary of latencies in ms in query',[], 15, [0.5, 0.99, 0.999]);
245246
$oks = $registry->getOrRegisterGauge('', 'oks', 'amount of OK requests', ['jobName']);
246247
$notOks = $registry->getOrRegisterGauge('', 'not_oks', 'amount of not OK requests', ['jobName']);
247248
$inflight = $registry->getOrRegisterGauge('', 'inflight', 'amount of requests in flight', ['jobName']);
@@ -269,6 +270,7 @@ protected function metricsJob(int $reportPeriod, float $startTime, int $time, st
269270

270271
while (microtime(true) <= $startTime + $time) {
271272
msg_receive($msgQueue, Utils::MSG_TYPE, $msgType, PHP_INT_MAX, $message);
273+
$queryLatencies->observe($this->getLatency($message["sent"]));
272274
switch ($message['type']) {
273275
case 'reset':
274276
$pushGateway->delete('workload-php', [

slo-workload/src/Utils.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ public static function metricFail(string $job, int $queueId, int $attemps, strin
7171

7272
public static function postData(int $queueId, array $data)
7373
{
74+
$data["sent"] = microtime(true);
7475
$msgQueue = msg_get_queue($queueId);
7576
msg_send($msgQueue, static::MSG_TYPE, $data);
7677
}

0 commit comments

Comments
 (0)