New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
[馃悰 BUG]: Error while declaring metrics by on_init command: duplicate metrics collector registration attempted #1648
Comments
Hey @Kaspiman 馃憢馃徎 |
You can use lock plugin: https://github.com/roadrunner-php/lock to prevent registration of the same metrics. Registration should be done by one process (worker). Lock the resource with a wait time like 1 millisecond. Only 1 worker would be able to get a lock. Then register all needed metrics and release the lock. |
@rustatian on_init does not called for every worker. As you see |
Two calls of rpc
|
I tried on_init but it does not working |
It's hard to tell what's happening in your env. The |
It's easy to see what's happening in my env because i attached DEMO with simple reproduce steps |
As I mentioned, the problem is somewhere in your env.
version: '3'
metrics:
address: '0.0.0.0:9254'
logs:
level: debug
mode: development
rpc:
listen: 'tcp://0.0.0.0:6001'
server:
command: "php foo"
on_init:
command: "php ../../php_test_files/on-init-metrics.php"
require __DIR__ . '/vendor/autoload.php';
use Spiral\Goridge\Relay;
use Spiral\Goridge\RPC\RPC;
$rpc = new RPC(
Relay::create('tcp://0.0.0.0:6001')
);
echo "foo";
$rpc = $rpc->withServicePrefix('metrics');
$rpc->call('Declare', [
'name' => 'test',
'collector' => [
'namespace' => '',
'subsystem' => '',
'type' => 'counter',
'help' => '',
'labels' => [],
'buckets' => [],
],
]);
echo "foo2";
$rpc->call('Add', [
'name' => 'test',
'value' => 1.0,
'labels' => [],
]);
echo "ON INIT";
|
I would be happy to help you, but I do not have a reproduction of the problem. |
Reopening, looks like I found a problem. |
No duplicates 馃ゲ.
What happened?
A bug happened!
Version (rr --version)
version: 2023.2.0, buildtime: 2023-07-06T19:02:05+0000
How to reproduce the issue?
Try to init some metrics by on_init command and got error "duplicate metrics collector registration attempted".
Demo: see
metric.php
,rr.yaml
and README.mdRelevant log output
The text was updated successfully, but these errors were encountered: