Skip to content

Commit 7388ded

Browse files
refactor(profiling): use two-time upload api
1 parent bea334c commit 7388ded

1 file changed

Lines changed: 18 additions & 10 deletions

File tree

  • ddtrace/internal/datadog/profiling/dd_wrapper/src

ddtrace/internal/datadog/profiling/dd_wrapper/src/uploader.cpp

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,15 @@ Datadog::Uploader::upload_unlocked()
122122
.len = static_cast<uintptr_t>(to_compress_files.size()),
123123
};
124124

125-
bool ret = true;
125+
// Build and send the request in one call
126+
auto init_runtime_res = ddog_prof_Exporter_init_runtime(&ddog_exporter);
127+
if (init_runtime_res.tag != DDOG_VOID_RESULT_OK) {
128+
std::cerr << "Error initializing runtime: " << err_to_msg(&init_runtime_res.err, "Error initializing runtime")
129+
<< std::endl;
130+
ddog_Error_drop(&init_runtime_res.err);
131+
return false;
132+
}
133+
126134
// Before starting a new upload, we need to cancel the current one (if it exists).
127135
// To do that, we exchange the current cancellation token with a new one (which will be used for our own upload)
128136
// If the current cancellation token was not null, then we use it to cancel the ongoing upload, then drop it.
@@ -138,16 +146,16 @@ Datadog::Uploader::upload_unlocked()
138146
ddog_CancellationToken_drop(&current_cancel);
139147
}
140148

141-
// Build and send the request in one call
142-
ddog_prof_Result_HttpStatus res = ddog_prof_Exporter_send_blocking(&ddog_exporter,
143-
&encoded_profile,
144-
files_to_compress,
145-
nullptr, // optional_additional_tags
146-
optional_process_tags_ptr,
147-
&internal_metadata_json_slice,
148-
nullptr, // optional_info_json
149-
&new_cancel_clone_for_request);
149+
auto res = ddog_prof_Exporter_send_blocking(&ddog_exporter,
150+
&encoded_profile,
151+
files_to_compress,
152+
nullptr, // optional_additional_tags
153+
optional_process_tags_ptr,
154+
&internal_metadata_json_slice,
155+
nullptr, // optional_info_json
156+
&new_cancel_clone_for_request);
150157

158+
bool ret = true;
151159
if (res.tag == DDOG_PROF_RESULT_HTTP_STATUS_ERR_HTTP_STATUS) { // NOLINT (cppcoreguidelines-pro-type-union-access)
152160
auto err = res.err; // NOLINT (cppcoreguidelines-pro-type-union-access)
153161
errmsg = err_to_msg(&err, "Error uploading");

0 commit comments

Comments
 (0)