File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -146,6 +146,18 @@ int main(int argc, char *argv[]) {
146146 auto cancel = ddog_CancellationToken_new ();
147147 auto cancel_for_background_thread = ddog_CancellationToken_clone (&cancel);
148148
149+ // Eagerly initialize the tokio runtime. This is optional, but required
150+ // to avoid race conditions if another thread might be using the
151+ // the cancellation token at the same time as the profile is being sent
152+ // (as is the case here).
153+ ddog_VoidResult init_result = ddog_prof_Exporter_init_runtime (exporter);
154+ if (init_result.tag != DDOG_VOID_RESULT_OK) {
155+ print_error (" Failed to initialize exporter runtime: " , init_result.err );
156+ ddog_Error_drop (&init_result.err );
157+ ddog_prof_Exporter_drop (exporter);
158+ return 1 ;
159+ }
160+
149161 // As an example of CancellationToken usage, here we create a background
150162 // thread that sleeps for some time and then cancels a request early (e.g.
151163 // before the timeout in ddog_prof_Exporter_send_blocking is hit).
You can’t perform that action at this time.
0 commit comments