@@ -36,12 +36,14 @@ use crate::signal_handler::with_simple_sigint_handler;
36
36
use crate :: subscribers:: build_graph_stats:: BuildGraphStats ;
37
37
use crate :: subscribers:: build_id_writer:: BuildIdWriter ;
38
38
use crate :: subscribers:: event_log:: EventLog ;
39
+ use crate :: subscribers:: health_check_subscriber:: HealthCheckSubscriber ;
39
40
use crate :: subscribers:: re_log:: ReLog ;
40
41
use crate :: subscribers:: recorder:: try_get_invocation_recorder;
41
42
use crate :: subscribers:: subscriber:: EventSubscriber ;
42
43
use crate :: subscribers:: subscribers:: EventSubscribers ;
43
44
44
45
const HEALTH_CHECK_CHANNEL_SIZE : usize = 100 ;
46
+
45
47
fn default_subscribers < T : StreamingCommand > (
46
48
cmd : & T ,
47
49
matches : BuckArgMatches < ' _ > ,
@@ -55,10 +57,24 @@ fn default_subscribers<T: StreamingCommand>(
55
57
// and log it in another (invocation_recorder)
56
58
let log_size_counter_bytes = Some ( Arc :: new ( AtomicU64 :: new ( 0 ) ) ) ;
57
59
58
- let ( _health_check_tags_sender, health_check_tags_receiver) =
59
- tokio:: sync:: mpsc:: channel ( HEALTH_CHECK_CHANNEL_SIZE ) ;
60
- let ( _health_check_display_reports_sender, health_check_display_reports_receiver) =
61
- tokio:: sync:: mpsc:: channel ( HEALTH_CHECK_CHANNEL_SIZE ) ;
60
+ let enable_health_checks = ctx
61
+ . immediate_config
62
+ . daemon_startup_config ( ) ?
63
+ . health_check_config
64
+ . enable_health_checks ;
65
+
66
+ let (
67
+ health_check_tags_receiver,
68
+ health_check_display_reports_receiver,
69
+ health_check_subscriber,
70
+ ) = if enable_health_checks {
71
+ let ( tag_tx, tag_rx) = tokio:: sync:: mpsc:: channel ( HEALTH_CHECK_CHANNEL_SIZE ) ;
72
+ let ( report_tx, report_rx) = tokio:: sync:: mpsc:: channel ( HEALTH_CHECK_CHANNEL_SIZE ) ;
73
+ let subscriber = HealthCheckSubscriber :: new ( tag_tx, report_tx) ;
74
+ ( Some ( tag_rx) , Some ( report_rx) , Some ( subscriber) )
75
+ } else {
76
+ ( None , None , None )
77
+ } ;
62
78
63
79
subscribers. push ( get_console_with_root (
64
80
ctx. trace_id . dupe ( ) ,
@@ -68,7 +84,7 @@ fn default_subscribers<T: StreamingCommand>(
68
84
None ,
69
85
T :: COMMAND_NAME ,
70
86
console_opts. superconsole_config ( ) ,
71
- Some ( health_check_display_reports_receiver) ,
87
+ health_check_display_reports_receiver,
72
88
) ?) ;
73
89
74
90
if let Some ( event_log) = try_get_event_log_subscriber ( cmd, ctx, log_size_counter_bytes. clone ( ) ) ?
@@ -96,16 +112,15 @@ fn default_subscribers<T: StreamingCommand>(
96
112
cmd. sanitize_argv ( ctx. argv . clone ( ) ) . argv ,
97
113
representative_config_flags,
98
114
log_size_counter_bytes,
99
- Some ( health_check_tags_receiver) ,
115
+ health_check_tags_receiver,
100
116
) ?;
101
117
recorder. update_metadata_from_client_metadata ( & ctx. client_metadata ) ;
102
118
subscribers. push ( recorder) ;
103
119
104
- // TODO(rajneeshl): Enable this after we have a cleaner kill switch for health checks.
105
- // subscribers.push(HealthCheckSubscriber::new(
106
- // health_check_tags_sender,
107
- // health_check_display_reports_sender,
108
- // ));
120
+ if let Some ( subscriber) = health_check_subscriber {
121
+ subscribers. push ( subscriber) ;
122
+ }
123
+
109
124
subscribers. extend ( cmd. extra_subscribers ( ) ) ;
110
125
Ok ( EventSubscribers :: new ( subscribers) )
111
126
}
0 commit comments