1- use crate :: allocation:: { ALLOCATION_PROFILING_COUNT , ALLOCATION_PROFILING_SIZE } ;
21use crate :: config:: AgentEndpoint ;
3- use crate :: exception:: EXCEPTION_PROFILING_EXCEPTION_COUNT ;
42use crate :: profiling:: { UploadMessage , UploadRequest } ;
53use crate :: { PROFILER_NAME_STR , PROFILER_VERSION_STR } ;
64use chrono:: { DateTime , Utc } ;
@@ -10,9 +8,15 @@ use log::{debug, info, warn};
108use serde_json:: json;
119use std:: borrow:: Cow ;
1210use std:: str;
13- use std:: sync:: atomic:: Ordering ;
1411use std:: sync:: { Arc , Barrier } ;
1512
13+ #[ cfg( feature = "debug_stats" ) ]
14+ use crate :: allocation:: { ALLOCATION_PROFILING_COUNT , ALLOCATION_PROFILING_SIZE } ;
15+ #[ cfg( feature = "debug_stats" ) ]
16+ use crate :: exception:: EXCEPTION_PROFILING_EXCEPTION_COUNT ;
17+ #[ cfg( feature = "debug_stats" ) ]
18+ use std:: sync:: atomic:: Ordering ;
19+
1620pub struct Uploader {
1721 fork_barrier : Arc < Barrier > ,
1822 receiver : Receiver < UploadMessage > ,
@@ -40,6 +44,7 @@ impl Uploader {
4044
4145 /// This function will not only create the internal metadata JSON representation, but is also
4246 /// in charge to reset all those counters back to 0.
47+ #[ cfg( feature = "debug_stats" ) ]
4348 fn create_internal_metadata ( ) -> Option < serde_json:: Value > {
4449 Some ( json ! ( {
4550 "exceptions_count" : EXCEPTION_PROFILING_EXCEPTION_COUNT . swap( 0 , Ordering :: SeqCst ) ,
@@ -83,7 +88,8 @@ impl Uploader {
8388 & [ ] ,
8489 & [ ] ,
8590 None ,
86- Self :: create_internal_metadata ( ) ,
91+ #[ cfg( feature = "debug_stats" ) ] Self :: create_internal_metadata ( ) ,
92+ #[ cfg( not( feature = "debug_stats" ) ) ] None ,
8793 self . create_profiler_info ( ) ,
8894 ) ?;
8995 debug ! ( "Sending profile to: {agent_endpoint}" ) ;
@@ -158,6 +164,7 @@ mod tests {
158164 use super :: * ;
159165
160166 #[ test]
167+ #[ cfg( feature = "debug_stats" ) ]
161168 fn test_create_internal_metadata ( ) {
162169 // Set up all counters with known values
163170 EXCEPTION_PROFILING_EXCEPTION_COUNT . store ( 42 , Ordering :: SeqCst ) ;
0 commit comments