-
Notifications
You must be signed in to change notification settings - Fork 10
Minor refactoring - libddprof helper #244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -174,10 +174,8 @@ static DDRes add_single_tag(ddog_Vec_Tag &tags_exporter, std::string_view key, | |
| ddog_Vec_Tag_PushResult push_tag_res = | ||
| ddog_Vec_Tag_push(&tags_exporter, to_CharSlice(key), to_CharSlice(value)); | ||
| if (push_tag_res.tag == DDOG_VEC_TAG_PUSH_RESULT_ERR) { | ||
| defer { ddog_Error_drop(&push_tag_res.err); }; | ||
|
|
||
| LG_ERR("[EXPORTER] Failure generate tag (%.*s)", | ||
| (int)push_tag_res.err.message.len, push_tag_res.err.message.ptr); | ||
| log_warn_and_drop_error("[EXPORTER] Failure generate tag", | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Won't the error message be logged twice ?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So I was not using ddog_Error_message. The aim is to have a function you can always call in case of error and not think too hard about what to do. |
||
| &push_tag_res.err); | ||
| DDRES_RETURN_ERROR_LOG(DD_WHAT_EXPORTER, "Failed to generate tags"); | ||
| } | ||
| return ddres_init(); | ||
|
|
@@ -240,7 +238,8 @@ DDRes ddprof_exporter_new(const UserTags *user_tags, DDProfExporter *exporter) { | |
| if (res_exporter.tag == DDOG_PROF_EXPORTER_NEW_RESULT_OK) { | ||
| exporter->_exporter = res_exporter.ok; | ||
| } else { | ||
| defer { ddog_Error_drop(&res_exporter.err); }; | ||
| log_warn_and_drop_error("[EXPORTER] Failure form ddog_prof_Exporter_new", | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. double log to be fixed |
||
| &res_exporter.err); | ||
| DDRES_RETURN_ERROR_LOG(DD_WHAT_EXPORTER, "Failure creating exporter - %s", | ||
| res_exporter.err.message.ptr); | ||
| } | ||
|
|
@@ -294,7 +293,8 @@ DDRes ddprof_exporter_export(const ddog_prof_Profile *profile, | |
| ddog_prof_Profile_SerializeResult serialized_result = | ||
| ddog_prof_Profile_serialize(profile, nullptr, nullptr); | ||
| if (serialized_result.tag != DDOG_PROF_PROFILE_SERIALIZE_RESULT_OK) { | ||
| defer { ddog_Error_drop(&serialized_result.err); }; | ||
| log_warn_and_drop_error("[EXPORTER] Failure in ddog_prof_Profile_serialize", | ||
| &serialized_result.err); | ||
| DDRES_RETURN_ERROR_LOG(DD_WHAT_EXPORTER, "Failed to serialize: %s", | ||
| serialized_result.err.message.ptr); | ||
| } | ||
|
|
@@ -349,10 +349,9 @@ DDRes ddprof_exporter_export(const ddog_prof_Profile *profile, | |
| ddog_prof_Exporter_send(exporter->_exporter, &request, nullptr); | ||
|
|
||
| if (result.tag == DDOG_PROF_EXPORTER_SEND_RESULT_ERR) { | ||
| defer { ddog_Error_drop(&result.err); }; | ||
| LG_WRN("Failure to establish connection, check url %s", exporter->_url); | ||
| LG_WRN("Failure to send profiles (%.*s)", (int)result.err.message.len, | ||
| result.err.message.ptr); | ||
| log_warn_and_drop_error("[EXPORTER] Failure to send profiles", | ||
| &result.err); | ||
| // Free error buffer (prefer this API to the free API) | ||
| if (exporter->_nb_consecutive_errors++ >= | ||
| K_NB_CONSECUTIVE_ERRORS_ALLOWED) { | ||
|
|
@@ -367,9 +366,8 @@ DDRes ddprof_exporter_export(const ddog_prof_Profile *profile, | |
| res = check_send_response_code(result.http_response.code); | ||
| } | ||
| } else { | ||
| defer { ddog_Error_drop(&res_request.err); }; | ||
| LG_ERR("[EXPORTER] Failure to build request: %s", | ||
| res_request.err.message.ptr); | ||
| log_warn_and_drop_error("[EXPORTER] Failure to build request", | ||
| &res_request.err); | ||
| res = ddres_error(DD_WHAT_EXPORTER); | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why use defer here ?