Skip to content

Commit 2346a39

Browse files
FedeDPpoiana
authored andcommitted
chore(userspace/falco): fix build for non linux minimal builds.
Signed-off-by: Federico Di Pierro <[email protected]>
1 parent 24f92df commit 2346a39

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

userspace/falco/app/actions/process_events.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -491,8 +491,9 @@ falco::app::run_result falco::app::actions::process_events(falco::app::state& s)
491491
}
492492

493493
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+
}
496497

497498
// optimization: with only one source we don't spawn additional threads
498499
process_inspector_events(s,
@@ -523,9 +524,8 @@ falco::app::run_result falco::app::actions::process_events(falco::app::state& s)
523524
break;
524525
}
525526
}
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();
529529
}
530530

531531
// wait for event processing to terminate for all sources

userspace/falco/app/actions/start_webserver.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ falco::app::run_result falco::app::actions::start_webserver(falco::app::state& s
4444
std::to_string(webserver_config.m_listen_port) + ssl_option + "\n");
4545

4646
state.webserver.start(state, webserver_config);
47+
state.on_inspectors_opened = [&state]() { state.webserver.enable_prometheus_metrics(state); };
4748
#endif
4849
return run_result::ok();
4950
}

userspace/falco/app/state.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ struct state {
116116

117117
falco_webserver webserver;
118118
#endif
119+
// Set by start_webserver to start prometheus metrics
120+
// once all inspectors are opened.
121+
std::function<void()> on_inspectors_opened = nullptr;
119122

120123
inline bool is_capture_mode() const { return config->m_engine_mode == engine_kind_t::REPLAY; }
121124

0 commit comments

Comments
 (0)