@@ -110,7 +110,17 @@ fn try_init_logger(dst: LogDestination) -> Result<impl Sized, String> {
110110 }
111111 ( Some ( tracy_layer ( ) . boxed ( ) ) , Default :: default ( ) )
112112 }
113- Ok ( s) => return Err ( format ! ( "unknown profiler '{s}'; valid values: 'chrome', 'tracy'" ) ) ,
113+ Ok ( "samply" ) => {
114+ if !cfg ! ( feature = "tracing-samply" ) {
115+ return Err ( "samply profiler support is not compiled in" . to_string ( ) ) ;
116+ }
117+ ( Some ( samply_layer ( ) . map_err ( |e| e. to_string ( ) ) ?. boxed ( ) ) , Default :: default ( ) )
118+ }
119+ Ok ( s) => {
120+ return Err ( format ! (
121+ "unknown profiler '{s}'; valid values: 'chrome', 'tracy', 'samply'"
122+ ) ) ;
123+ }
114124 Err ( _) => Default :: default ( ) ,
115125 } ;
116126 tracing_subscriber:: Registry :: default ( )
@@ -140,7 +150,6 @@ fn tracy_layer() -> tracing_tracy::TracyLayer<impl tracing_tracy::Config> {
140150
141151 tracing_tracy:: TracyLayer :: new ( Config ( Default :: default ( ) ) )
142152}
143-
144153#[ cfg( feature = "tracing" ) ]
145154#[ cfg( not( feature = "tracy" ) ) ]
146155fn tracy_layer ( ) -> tracing_subscriber:: layer:: Identity {
@@ -158,13 +167,23 @@ where
158167{
159168 tracing_chrome:: ChromeLayerBuilder :: new ( ) . include_args ( true ) . build ( )
160169}
161-
162170#[ cfg( feature = "tracing" ) ]
163171#[ cfg( not( feature = "tracing-chrome" ) ) ]
164172fn chrome_layer ( ) -> ( tracing_subscriber:: layer:: Identity , ( ) ) {
165173 ( tracing_subscriber:: layer:: Identity :: new ( ) , ( ) )
166174}
167175
176+ #[ cfg( feature = "tracing" ) ]
177+ #[ cfg( feature = "tracing-samply" ) ]
178+ fn samply_layer ( ) -> std:: io:: Result < tracing_samply:: SamplyLayer > {
179+ tracing_samply:: SamplyLayer :: new ( )
180+ }
181+ #[ cfg( feature = "tracing" ) ]
182+ #[ cfg( not( feature = "tracing-samply" ) ) ]
183+ fn samply_layer ( ) -> std:: io:: Result < tracing_subscriber:: layer:: Identity > {
184+ Ok ( tracing_subscriber:: layer:: Identity :: new ( ) )
185+ }
186+
168187/*
169188pub(crate) fn env_to_bool(value: Option<&std::ffi::OsStr>) -> bool {
170189 value.is_some_and(|value| value == "1" || value == "true")
0 commit comments