File tree Expand file tree Collapse file tree 3 files changed +9
-5
lines changed Expand file tree Collapse file tree 3 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -491,8 +491,9 @@ falco::app::run_result falco::app::actions::process_events(falco::app::state& s)
491
491
}
492
492
493
493
if (s.enabled_sources .size () == 1 ) {
494
- // Since the inspector is now opened, we can enable prometheus metrics
495
- s.webserver .enable_prometheus_metrics (s);
494
+ if (s.on_inspectors_opened != nullptr ) {
495
+ s.on_inspectors_opened ();
496
+ }
496
497
497
498
// optimization: with only one source we don't spawn additional threads
498
499
process_inspector_events (s,
@@ -523,9 +524,8 @@ falco::app::run_result falco::app::actions::process_events(falco::app::state& s)
523
524
break ;
524
525
}
525
526
}
526
- if (s.enabled_sources .size () > 1 ) {
527
- // Since all inspectors are now opened, we can enable prometheus metrics
528
- s.webserver .enable_prometheus_metrics (s);
527
+ if (s.enabled_sources .size () > 1 && s.on_inspectors_opened != nullptr ) {
528
+ s.on_inspectors_opened ();
529
529
}
530
530
531
531
// wait for event processing to terminate for all sources
Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ falco::app::run_result falco::app::actions::start_webserver(falco::app::state& s
44
44
std::to_string (webserver_config.m_listen_port ) + ssl_option + " \n " );
45
45
46
46
state.webserver .start (state, webserver_config);
47
+ state.on_inspectors_opened = [&state]() { state.webserver .enable_prometheus_metrics (state); };
47
48
#endif
48
49
return run_result::ok ();
49
50
}
Original file line number Diff line number Diff line change @@ -116,6 +116,9 @@ struct state {
116
116
117
117
falco_webserver webserver;
118
118
#endif
119
+ // Set by start_webserver to start prometheus metrics
120
+ // once all inspectors are opened.
121
+ std::function<void ()> on_inspectors_opened = nullptr ;
119
122
120
123
inline bool is_capture_mode () const { return config->m_engine_mode == engine_kind_t ::REPLAY; }
121
124
You can’t perform that action at this time.
0 commit comments