@@ -141,27 +141,17 @@ mod tests {
141141 cfg_if:: cfg_if! {
142142 if #[ cfg( feature = "function_call_metrics" ) ] {
143143 use metrics:: Label ;
144- // Verify that the histogram metrics are recorded correctly
145- assert_eq!( snapshot. len( ) , 4 , "Expected two metrics in the snapshot" ) ;
146144
147- // 1. Host print duration
148- let histogram_key = CompositeKey :: new(
149- metrics_util:: MetricKind :: Histogram ,
150- Key :: from_parts(
151- METRIC_HOST_FUNC_DURATION ,
152- vec![ Label :: new( "function_name" , "HostPrint" ) ] ,
153- ) ,
154- ) ;
155- let histogram_value = & snapshot. get( & histogram_key) . unwrap( ) . 2 ;
156- assert!(
157- matches!(
158- histogram_value,
159- metrics_util:: debugging:: DebugValue :: Histogram ( ref histogram) if histogram. len( ) == 1
160- ) ,
161- "Histogram metric does not match expected value"
162- ) ;
145+ let expected_num_metrics = if cfg!( feature = "seccomp" ) {
146+ 3 // if seccomp enabled, the host call duration metric is emitted on a separate thread which this local recorder doesn't capture
147+ } else {
148+ 4
149+ } ;
150+
151+ // Verify that the histogram metrics are recorded correctly
152+ assert_eq!( snapshot. len( ) , expected_num_metrics) ;
163153
164- // 2 . Guest call duration
154+ // 1 . Guest call duration
165155 let histogram_key = CompositeKey :: new(
166156 metrics_util:: MetricKind :: Histogram ,
167157 Key :: from_parts(
@@ -178,7 +168,7 @@ mod tests {
178168 "Histogram metric does not match expected value"
179169 ) ;
180170
181- // 3 . Guest cancellation
171+ // 2 . Guest cancellation
182172 let counter_key = CompositeKey :: new(
183173 metrics_util:: MetricKind :: Counter ,
184174 Key :: from_name( METRIC_GUEST_CANCELLATION ) ,
@@ -188,7 +178,7 @@ mod tests {
188178 metrics_util:: debugging:: DebugValue :: Counter ( 1 )
189179 ) ;
190180
191- // 4 . Guest call duration
181+ // 3 . Guest call duration
192182 let histogram_key = CompositeKey :: new(
193183 metrics_util:: MetricKind :: Histogram ,
194184 Key :: from_parts(
@@ -204,9 +194,28 @@ mod tests {
204194 ) ,
205195 "Histogram metric does not match expected value"
206196 ) ;
197+
198+ if !cfg!( feature = "seccomp" ) {
199+ // 4. Host call duration
200+ let histogram_key = CompositeKey :: new(
201+ metrics_util:: MetricKind :: Histogram ,
202+ Key :: from_parts(
203+ METRIC_HOST_FUNC_DURATION ,
204+ vec![ Label :: new( "function_name" , "HostPrint" ) ] ,
205+ ) ,
206+ ) ;
207+ let histogram_value = & snapshot. get( & histogram_key) . unwrap( ) . 2 ;
208+ assert!(
209+ matches!(
210+ histogram_value,
211+ metrics_util:: debugging:: DebugValue :: Histogram ( ref histogram) if histogram. len( ) == 1
212+ ) ,
213+ "Histogram metric does not match expected value"
214+ ) ;
215+ }
207216 } else {
208217 // Verify that the counter metrics are recorded correctly
209- assert_eq!( snapshot. len( ) , 1 , "Expected two metrics in the snapshot" ) ;
218+ assert_eq!( snapshot. len( ) , 1 ) ;
210219
211220 let counter_key = CompositeKey :: new(
212221 metrics_util:: MetricKind :: Counter ,
0 commit comments