Skip to content

Commit 13abd1b

Browse files
author
Ariel Ben-Yehuda
committed
doc: add comment about uploading the last sample
1 parent 506718f commit 13abd1b

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

src/profiler.rs

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,18 @@ impl Profiler {
764764
///
765765
/// [JoinHandle]: tokio::task::JoinHandle
766766
///
767+
/// ### Uploading the last sample
768+
///
769+
/// When you return from the Tokio `main`, the agent will terminate without waiting
770+
/// for the last profiling JFR to be uploaded. Especially if you have a
771+
/// short-running program, if you want to ensure the last profiling JFR
772+
/// is uploaded, you should use [Profiler::spawn_controllable] and
773+
/// [RunningProfiler::stop] , which allows waiting for the upload
774+
/// to finish.
775+
///
776+
/// If you do not care about losing the last sample, it is fine to directly
777+
/// return from the Tokio `main` without stopping the profiler.
778+
///
767779
/// ### Tokio Runtime
768780
///
769781
/// This function must be run within a Tokio runtime, otherwise it will panic. If
@@ -806,6 +818,18 @@ impl Profiler {
806818
///
807819
/// This is to be used when your program does not have a "main" Tokio runtime already set up.
808820
///
821+
/// ### Uploading the last sample
822+
///
823+
/// When you return from `main`, the agent will terminate without waiting
824+
/// for the last profiling JFR to be uploaded. Especially if you have a
825+
/// short-running program, if you want to ensure the last profiling JFR
826+
/// is uploaded, you should use [Profiler::spawn_controllable_thread_to_runtime]
827+
/// and [RunningProfilerThread::stop], which allows waiting for the upload
828+
/// to finish.
829+
///
830+
/// If you do not care about losing the last sample, it is fine to directly
831+
/// return from the Tokio `main` without stopping the profiler.
832+
///
809833
/// ### Example
810834
///
811835
/// This example uses [ProfilerBuilder::with_local_reporter] which reports the profiles to
@@ -856,6 +880,18 @@ impl Profiler {
856880
///
857881
/// This is to be used when your program does not have a "main" Tokio runtime already set up.
858882
///
883+
/// ### Uploading the last sample
884+
///
885+
/// When you return from `main`, the agent will terminate without waiting
886+
/// for the last profiling JFR to be uploaded. Especially if you have a
887+
/// short-running program, if you want to ensure the last profiling JFR
888+
/// is uploaded, you should use [Profiler::spawn_controllable_thread_to_runtime]
889+
/// and [RunningProfilerThread::stop], which allows waiting for the upload
890+
/// to finish.
891+
///
892+
/// If you do not care about losing the last sample, it is fine to directly
893+
/// return from the Tokio `main` without stopping the profiler.
894+
///
859895
/// ### Example
860896
///
861897
/// This example uses [ProfilerBuilder::with_local_reporter] which reports the profiles to
@@ -909,6 +945,17 @@ impl Profiler {
909945
/// This function will fail if it is unable to start async-profiler, for example
910946
/// if it can't find or load `libasyncProfiler.so`.
911947
///
948+
/// ### Uploading the last sample
949+
///
950+
/// When you return from the Tokio `main`, the agent will terminate without waiting
951+
/// for the last profiling JFR to be uploaded. Especially if you have a
952+
/// short-running program, if you want to ensure the last profiling JFR
953+
/// is uploaded, you should use [RunningProfiler::stop], which allows waiting for
954+
/// the upload to finish.
955+
///
956+
/// If you do not care about losing the last sample, it is fine to directly
957+
/// return from the Tokio `main` without stopping the profiler.
958+
///
912959
/// ### Tokio Runtime
913960
///
914961
/// This function must be run within a Tokio runtime, otherwise it will panic. If
@@ -958,6 +1005,17 @@ impl Profiler {
9581005
///
9591006
/// This is to be used when your program does not have a "main" Tokio runtime already set up.
9601007
///
1008+
/// ### Uploading the last sample
1009+
///
1010+
/// When you return from `main`, the agent will terminate without waiting
1011+
/// for the last profiling JFR to be uploaded. Especially if you have a
1012+
/// short-running program, if you want to ensure the last profiling JFR
1013+
/// is uploaded, you should use [RunningProfilerThread::stop], which allows waiting
1014+
/// for the upload to finish.
1015+
///
1016+
/// If you do not care about losing the last sample, it is fine to directly
1017+
/// return from the Tokio `main` without stopping the profiler.
1018+
///
9611019
/// ### Example
9621020
///
9631021
/// This example uses [ProfilerBuilder::with_local_reporter] which reports the profiles to

0 commit comments

Comments
 (0)