Closed shirokovnv closed 2 years ago
Hi Nickolai! I'm Nick and from Ekb too π
About your question - any listeners declared for the BeforeLoopStartedEvent
will be fired only once (after the app instance creation and before the first HTTP request processing) anyway:
And this is an ideal place for the metrics initialization, I think. Can I ask you - what is the main reason for the metrics syncing? Usually, something like a "metrics exporter" ("sidekick" container) grabs the metrics from each started container, and in the dashboard like a "Grafana", we can watch the summarized metric values. What kind of metrics processing do you want to implement?
Nice to meet you, Nick). Gladly we are fellow townsmans).
I didn't notice this:
$app = $this->createApplication($options, $psr7_worker);
$this->fireEvent($app, new Events\BeforeLoopStartedEvent($app));
Thanks!! (I printed out Log::info('before loop started event');
in my custom listener and
saw in laravel.log file, that my title appeared 2 times (I have 2 workers in rr config)). I decided, that beforeLoopStarted event
fired on every worker loop, without investigating. Sorry for that...
About metrics: in company, where I am working, we have a service, that needs to translate some of them:
We decided to experiment with roadrunner metrics interface, but encountered an issue:
when docker container with app restarts, the whole metrics resets.
And after that I have implemented simple redis storage for metric counters and sync metrics with storage.
But didnt know where sync must be invoked (did it in AppServiceProvider as singleton service, but that didn't work properly).
I suppose - the application doesn't have to worry about metrics syncing (this is a very-very deep rabbit hole), there are already proven and scalable solutions for that, such as Grafana. Maybe you should think again about the architecture of your solution as a whole?
I suppose - the application doesn't have to worry about metrics syncing (this is a very-very deep rabbit hole), there are already proven and scalable solutions for that, such as Grafana. Maybe you should think again about the architecture of your solution as a whole?
yes, definately.
we use prometheus and grafana for collecting and visualizing our metrics on other services.
this one was an experemental feature. RR presents metrics in special route port (2112 by default) and it seemed to me, that prometheus for example can grab it and store.
So, thanks for your feedback!
I will close the issue.
Greetings!
First of all, thanks for the awesome package!
I am using laravel-roadrunner in production and experimenting with Event Loop System.
I need to declare a couple of application metrics(counters) and load default values before application starts (default counter values saved in local redis storage and must be synced with app metrics after docker container with main app restarts).
The metrics I am doing in following way: https://roadrunner.dev/docs/beep-beep-metrics
As far as I understand, the package provides
BeforeLoopStarted
andBeforeLoopIteration
events and theoretically I can place the code of metrics syncing to the BeforeLoopStart event listener.But, if we have more than one rr worker, event will be listened many times.
So, my idea is to define something like
beforeApplicationStartedEvent
which will be listened only once.Can you provide such an event in the future or help to understand how to implement it?
Thanks.