summaryrefslogtreecommitdiff
path: root/tests/metrics-issue-571.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/metrics-issue-571.php')
-rw-r--r--tests/metrics-issue-571.php37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/metrics-issue-571.php b/tests/metrics-issue-571.php
new file mode 100644
index 00000000..947ae1f7
--- /dev/null
+++ b/tests/metrics-issue-571.php
@@ -0,0 +1,37 @@
+<?php
+
+use Spiral\Goridge;
+use Spiral\RoadRunner;
+use Nyholm\Psr7\Factory;
+
+ini_set('display_errors', 'stderr');
+require __DIR__ . "/vendor/autoload.php";
+
+$worker = new RoadRunner\Http\PSR7Worker(
+ RoadRunner\Worker::create(),
+ new Factory\Psr17Factory(),
+ new Factory\Psr17Factory(),
+ new Factory\Psr17Factory()
+);
+
+$metrics = new RoadRunner\Metrics\Metrics(
+ Goridge\RPC\RPC::create(RoadRunner\Environment::fromGlobals()->getRPCAddress())
+);
+
+$metrics->declare(
+ 'test',
+ RoadRunner\Metrics\Collector::counter()->withHelp('Test counter')
+);
+
+while ($req = $worker->waitRequest()) {
+ try {
+ $rsp = new \Nyholm\Psr7\Response();
+ $rsp->getBody()->write("hello world");
+
+ $metrics->add('test', 1);
+
+ $worker->respond($rsp);
+ } catch (\Throwable $e) {
+ $worker->getWorker()->error((string)$e);
+ }
+}