@@ -139,12 +139,11 @@ impl ProfilerOptionsBuilder {
139139 /// ```
140140 /// # use async_profiler_agent::profiler::{ProfilerBuilder, ProfilerOptionsBuilder};
141141 /// # use async_profiler_agent::profiler::SpawnError;
142- /// # use async_profiler_agent::reporter::local::LocalReporter;
143142 /// # fn main() -> Result<(), SpawnError> {
144143 /// let opts = ProfilerOptionsBuilder::default().with_native_mem("10m".into()).build();
145144 /// let profiler = ProfilerBuilder::default()
146145 /// .with_profiler_options(opts)
147- /// .with_reporter(LocalReporter::new( "/tmp/profiles") )
146+ /// .with_local_reporter( "/tmp/profiles")
148147 /// .build();
149148 /// # if false { // don't spawn the profiler in doctests
150149 /// profiler.spawn()?;
@@ -174,12 +173,11 @@ impl ProfilerOptionsBuilder {
174173 /// ```
175174 /// # use async_profiler_agent::profiler::{ProfilerBuilder, ProfilerOptionsBuilder};
176175 /// # use async_profiler_agent::profiler::SpawnError;
177- /// # use async_profiler_agent::reporter::local::LocalReporter;
178176 /// # fn main() -> Result<(), SpawnError> {
179177 /// let opts = ProfilerOptionsBuilder::default().with_native_mem_bytes(10_000_000).build();
180178 /// let profiler = ProfilerBuilder::default()
181179 /// .with_profiler_options(opts)
182- /// .with_reporter(LocalReporter::new( "/tmp/profiles") )
180+ /// .with_local_reporter( "/tmp/profiles")
183181 /// .build();
184182 /// # if false { // don't spawn the profiler in doctests
185183 /// profiler.spawn()?;
@@ -192,12 +190,11 @@ impl ProfilerOptionsBuilder {
192190 /// ```
193191 /// # use async_profiler_agent::profiler::{ProfilerBuilder, ProfilerOptionsBuilder};
194192 /// # use async_profiler_agent::profiler::SpawnError;
195- /// # use async_profiler_agent::reporter::local::LocalReporter;
196193 /// # fn main() -> Result<(), SpawnError> {
197194 /// let opts = ProfilerOptionsBuilder::default().with_native_mem_bytes(0).build();
198195 /// let profiler = ProfilerBuilder::default()
199196 /// .with_profiler_options(opts)
200- /// .with_reporter(LocalReporter::new( "/tmp/profiles") )
197+ /// .with_local_reporter( "/tmp/profiles")
201198 /// .build();
202199 /// # if false { // don't spawn the profiler in doctests
203200 /// profiler.spawn()?;
@@ -237,7 +234,6 @@ impl ProfilerOptionsBuilder {
237234 /// ```
238235 /// # use async_profiler_agent::profiler::{ProfilerBuilder, ProfilerOptionsBuilder};
239236 /// # use async_profiler_agent::profiler::SpawnError;
240- /// # use async_profiler_agent::reporter::local::LocalReporter;
241237 /// # use std::time::Duration;
242238 /// # fn main() -> Result<(), SpawnError> {
243239 /// let opts = ProfilerOptionsBuilder::default()
@@ -246,7 +242,7 @@ impl ProfilerOptionsBuilder {
246242 /// .build();
247243 /// let profiler = ProfilerBuilder::default()
248244 /// .with_profiler_options(opts)
249- /// .with_reporter(LocalReporter::new( "/tmp/profiles") )
245+ /// .with_local_reporter( "/tmp/profiles")
250246 /// .build();
251247 /// # if false { // don't spawn the profiler in doctests
252248 /// profiler.spawn()?;
@@ -283,7 +279,6 @@ impl ProfilerOptionsBuilder {
283279 /// ```
284280 /// # use async_profiler_agent::profiler::{ProfilerBuilder, ProfilerOptionsBuilder};
285281 /// # use async_profiler_agent::profiler::SpawnError;
286- /// # use async_profiler_agent::reporter::local::LocalReporter;
287282 /// # use std::time::Duration;
288283 /// # fn main() -> Result<(), SpawnError> {
289284 /// let opts = ProfilerOptionsBuilder::default()
@@ -292,7 +287,7 @@ impl ProfilerOptionsBuilder {
292287 /// .build();
293288 /// let profiler = ProfilerBuilder::default()
294289 /// .with_profiler_options(opts)
295- /// .with_reporter(LocalReporter::new( "/tmp/profiles") )
290+ /// .with_local_reporter( "/tmp/profiles")
296291 /// .build();
297292 /// # if false { // don't spawn the profiler in doctests
298293 /// profiler.spawn()?;
@@ -342,10 +337,9 @@ impl ProfilerBuilder {
342337 /// # use std::path::PathBuf;
343338 /// # use std::time::Duration;
344339 /// # use async_profiler_agent::profiler::{ProfilerBuilder, SpawnError};
345- /// # use async_profiler_agent::reporter::local::LocalReporter;
346340 /// # let path = PathBuf::from(".");
347341 /// let agent = ProfilerBuilder::default()
348- /// .with_reporter(LocalReporter::new( path) )
342+ /// .with_local_reporter( path)
349343 /// .with_reporting_interval(Duration::from_secs(15))
350344 /// .build()
351345 /// .spawn()?;
@@ -466,7 +460,7 @@ impl ProfilerBuilder {
466460 ///
467461 /// ## Example
468462 ///
469- /// This will write profiles as `.jfr` files to `./path-to-profiles`
463+ /// This will write profiles as `.jfr` files to `./path-to-profiles`:
470464 ///
471465 /// ```no_run
472466 /// # use std::path::PathBuf;
@@ -506,9 +500,12 @@ impl ProfilerBuilder {
506500 #[ cfg_attr( feature = "s3-no-defaults" , doc = "" ) ]
507501 #[ cfg_attr(
508502 feature = "s3-no-defaults" ,
509- doc = "This will create a reporter with empty ([AgentMetadata::Other])"
503+ doc = "This will create a profiler that will upload to S3 with"
504+ ) ]
505+ #[ cfg_attr(
506+ feature = "s3-no-defaults" ,
507+ doc = "empty ([AgentMetadata::Other]) metadata."
510508 ) ]
511- #[ cfg_attr( feature = "s3-no-defaults" , doc = "metadata." ) ]
512509 #[ cfg_attr( feature = "s3-no-defaults" , doc = r#""# ) ]
513510 #[ cfg_attr( feature = "s3-no-defaults" , doc = r#"```no_run"# ) ]
514511 #[ cfg_attr( feature = "s3-no-defaults" , doc = r#"# use std::path::PathBuf;"# ) ]
@@ -597,6 +594,26 @@ impl ProfilerBuilder {
597594 }
598595
599596 /// Provide custom profiler options.
597+ ///
598+ /// ### Example
599+ ///
600+ /// This will sample allocations for every 10 megabytes allocated:
601+ ///
602+ /// ```
603+ /// # use async_profiler_agent::profiler::{ProfilerBuilder, ProfilerOptionsBuilder};
604+ /// # use async_profiler_agent::profiler::SpawnError;
605+ /// # fn main() -> Result<(), SpawnError> {
606+ /// let opts = ProfilerOptionsBuilder::default().with_native_mem("10m".into()).build();
607+ /// let profiler = ProfilerBuilder::default()
608+ /// .with_profiler_options(opts)
609+ /// .with_local_reporter("/tmp/profiles")
610+ /// .build();
611+ /// # if false { // don't spawn the profiler in doctests
612+ /// profiler.spawn()?;
613+ /// # }
614+ /// # Ok(())
615+ /// # }
616+ /// ```
600617 pub fn with_profiler_options ( mut self , c : ProfilerOptions ) -> ProfilerBuilder {
601618 self . profiler_options = Some ( c) ;
602619 self
@@ -878,18 +895,15 @@ impl Profiler {
878895 ///
879896 /// ### Example
880897 ///
881- /// This example uses a [LocalReporter] which reports the profiles to
882- /// a directory. It works with any other [Reporter].
883- ///
884- /// [LocalReporter]: crate::reporter::local::LocalReporter
898+ /// This example uses [ProfilerBuilder::with_local_reporter] which reports the profiles to
899+ /// a directory. It works with any other [Reporter] using [ProfilerBuilder::with_reporter].
885900 ///
886901 /// ```
887902 /// # use async_profiler_agent::profiler::{ProfilerBuilder, SpawnError};
888- /// # use async_profiler_agent::reporter::local::LocalReporter;
889903 /// # #[tokio::main]
890904 /// # async fn main() -> Result<(), SpawnError> {
891905 /// let profiler = ProfilerBuilder::default()
892- /// .with_reporter(LocalReporter::new( "/tmp/profiles") )
906+ /// .with_local_reporter( "/tmp/profiles")
893907 /// .build();
894908 /// # if false { // don't spawn the profiler in doctests
895909 /// profiler.spawn()?;
@@ -917,19 +931,16 @@ impl Profiler {
917931 ///
918932 /// ### Example
919933 ///
920- /// This example uses a [LocalReporter] which reports the profiles to
921- /// a directory. It works with any other [Reporter].
922- ///
923- /// [LocalReporter]: crate::reporter::local::LocalReporter
934+ /// This example uses [ProfilerBuilder::with_local_reporter] which reports the profiles to
935+ /// a directory. It works with any other [Reporter] using [ProfilerBuilder::with_reporter].
924936 ///
925937 /// ```no_run
926938 /// # use async_profiler_agent::profiler::{ProfilerBuilder, SpawnError};
927- /// # use async_profiler_agent::reporter::local::LocalReporter;
928939 /// let rt = tokio::runtime::Builder::new_current_thread()
929940 /// .enable_all()
930941 /// .build()?;
931942 /// let profiler = ProfilerBuilder::default()
932- /// .with_reporter(LocalReporter::new( "/tmp/profiles") )
943+ /// .with_local_reporter( "/tmp/profiles")
933944 /// .build();
934945 ///
935946 /// profiler.spawn_thread_to_runtime(
@@ -970,16 +981,14 @@ impl Profiler {
970981 ///
971982 /// ### Example
972983 ///
973- /// This example uses a [LocalReporter] which reports the profiles to
974- /// a directory. It works with any other [Reporter].
975- ///
976- /// [LocalReporter]: crate::reporter::local::LocalReporter
984+ /// This example uses [ProfilerBuilder::with_local_reporter] which reports the profiles to
985+ /// a directory. It works with any other [Reporter] using [ProfilerBuilder::with_reporter].
977986 ///
978987 /// ```no_run
979988 /// # use async_profiler_agent::profiler::{ProfilerBuilder, SpawnError};
980989 /// # use async_profiler_agent::reporter::local::LocalReporter;
981990 /// let profiler = ProfilerBuilder::default()
982- /// .with_reporter(LocalReporter::new( "/tmp/profiles") )
991+ /// .with_local_reporter( "/tmp/profiles")
983992 /// .build();
984993 ///
985994 /// profiler.spawn_thread()?;
@@ -1031,18 +1040,15 @@ impl Profiler {
10311040 ///
10321041 /// ### Example
10331042 ///
1034- /// This example uses a [LocalReporter] which reports the profiles to
1035- /// a directory. It works with any other [Reporter].
1036- ///
1037- /// [LocalReporter]: crate::reporter::local::LocalReporter
1043+ /// This example uses [ProfilerBuilder::with_local_reporter] which reports the profiles to
1044+ /// a directory. It works with any other [Reporter] using [ProfilerBuilder::with_reporter].
10381045 ///
10391046 /// ```no_run
10401047 /// # use async_profiler_agent::profiler::{ProfilerBuilder, SpawnError};
1041- /// # use async_profiler_agent::reporter::local::LocalReporter;
10421048 /// # #[tokio::main]
10431049 /// # async fn main() -> Result<(), SpawnError> {
10441050 /// let profiler = ProfilerBuilder::default()
1045- /// .with_reporter(LocalReporter::new( "/tmp/profiles") )
1051+ /// .with_local_reporter( "/tmp/profiles")
10461052 /// .build();
10471053 ///
10481054 /// let profiler = profiler.spawn_controllable()?;
@@ -1077,19 +1083,16 @@ impl Profiler {
10771083 ///
10781084 /// ### Example
10791085 ///
1080- /// This example uses a [LocalReporter] which reports the profiles to
1081- /// a directory. It works with any other [Reporter].
1082- ///
1083- /// [LocalReporter]: crate::reporter::local::LocalReporter
1086+ /// This example uses [ProfilerBuilder::with_local_reporter] which reports the profiles to
1087+ /// a directory. It works with any other [Reporter] using [ProfilerBuilder::with_reporter].
10841088 ///
10851089 /// ```no_run
10861090 /// # use async_profiler_agent::profiler::{ProfilerBuilder, SpawnError};
1087- /// # use async_profiler_agent::reporter::local::LocalReporter;
10881091 /// let rt = tokio::runtime::Builder::new_current_thread()
10891092 /// .enable_all()
10901093 /// .build()?;
10911094 /// let profiler = ProfilerBuilder::default()
1092- /// .with_reporter(LocalReporter::new( "/tmp/profiles") )
1095+ /// .with_local_reporter( "/tmp/profiles")
10931096 /// .build();
10941097 ///
10951098 /// let profiler = profiler.spawn_controllable_thread_to_runtime(
0 commit comments