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 @@ -135,6 +135,18 @@ int main(int argc, char *argv[]) {
135135 auto cancel = ddog_CancellationToken_new ();
136136 auto cancel_for_background_thread = ddog_CancellationToken_clone (&cancel);
137137
138+ // Eagerly initialize the tokio runtime. This is optional, but required
139+ // to avoid race conditions if another thread might be using the
140+ // the cancellation token at the same time as the profile is being sent
141+ // (as is the case here).
142+ ddog_VoidResult init_result = ddog_prof_Exporter_init_runtime (exporter);
143+ if (init_result.tag != DDOG_VOID_RESULT_OK) {
144+ print_error (" Failed to initialize exporter runtime: " , init_result.err );
145+ ddog_Error_drop (&init_result.err );
146+ ddog_prof_Exporter_drop (exporter);
147+ return 1 ;
148+ }
149+
138150 // As an example of CancellationToken usage, here we create a background
139151 // thread that sleeps for some time and then cancels a request early (e.g.
140152 // before the timeout in ddog_prof_Exporter_send_blocking is hit).
You can’t perform that action at this time.
0 commit comments