Merge pull request #2250 from ZhouBox/main

plugin:rm so and schema file when remove custom plugin && mqtt trace:add resp playload
This commit is contained in:
fengzeroz
2024-09-30 10:44:10 +08:00
committed by GitHub
5 changed files with 23 additions and 5 deletions
+1 -1
View File
@@ -330,7 +330,7 @@ static int azure_plugin_request(neu_plugin_t *plugin, neu_reqresp_head_t *head,
switch (head->type) {
case NEU_RESP_ERROR:
error = handle_write_response(plugin, head->ctx, data);
error = handle_write_response(plugin, head->ctx, data, NULL);
break;
case NEU_RESP_READ_GROUP:
// error = handle_read_response(plugin, head->ctx, data);
+5 -1
View File
@@ -460,7 +460,7 @@ void handle_write_req(neu_mqtt_qos_e qos, const char *topic,
}
int handle_write_response(neu_plugin_t *plugin, neu_json_mqtt_t *mqtt_json,
neu_resp_error_t *data)
neu_resp_error_t *data, void *trace_scope)
{
int rv = 0;
char *json_str = NULL;
@@ -485,6 +485,10 @@ int handle_write_response(neu_plugin_t *plugin, neu_json_mqtt_t *mqtt_json,
goto end;
}
if (trace_scope) {
neu_otel_scope_add_span_attr_string(trace_scope, "playload", json_str);
}
char * topic = plugin->config.write_resp_topic;
neu_mqtt_qos_e qos = plugin->config.qos;
rv = publish(plugin, qos, topic, json_str, strlen(json_str));
+1 -1
View File
@@ -40,7 +40,7 @@ void handle_write_req(neu_mqtt_qos_e qos, const char *topic,
trace_w3c_t *trace_w3c);
int handle_write_response(neu_plugin_t *plugin, neu_json_mqtt_t *mqtt_json,
neu_resp_error_t *data);
neu_resp_error_t *data, void *trace_scope);
void handle_read_req(neu_mqtt_qos_e qos, const char *topic,
const uint8_t *payload, uint32_t len, void *data,
+2 -2
View File
@@ -482,7 +482,7 @@ int mqtt_plugin_request(neu_plugin_t *plugin, neu_reqresp_head_t *head,
switch (head->type) {
case NEU_RESP_ERROR:
error = handle_write_response(plugin, head->ctx, data);
error = handle_write_response(plugin, head->ctx, data, scope);
break;
case NEU_RESP_GET_NODES_STATE: {
handle_nodes_state(head->ctx, (neu_resp_get_nodes_state_t *) data);
@@ -537,7 +537,7 @@ int mqtt_plugin_request(neu_plugin_t *plugin, neu_reqresp_head_t *head,
}
if (trace) {
neu_otel_scope_add_span_attr_int(scope, "error", error);
neu_otel_scope_add_span_attr_int(scope, "handle error", error);
neu_otel_scope_set_span_end_time(scope, neu_time_ms());
neu_otel_trace_set_final(trace);
}
+14
View File
@@ -252,6 +252,20 @@ int neu_plugin_manager_del(neu_plugin_manager_t *mgr, const char *plugin_name)
HASH_FIND_STR(mgr->plugins, plugin_name, plugin);
if (plugin != NULL) {
if (plugin->kind != NEU_PLUGIN_KIND_SYSTEM) {
char so_file_path[128] = { 0 };
char schema_file_path[128] = { 0 };
snprintf(so_file_path, sizeof(so_file_path), "%s/custom/%s",
g_plugin_dir, plugin->lib_name);
snprintf(schema_file_path, sizeof(schema_file_path),
"%s/custom/schema/%s.json", g_plugin_dir, plugin->schema);
if (remove(so_file_path) != 0) {
nlog_error("rm %s file fail!", so_file_path);
}
if (remove(schema_file_path) != 0) {
nlog_error("rm %s file fail!", schema_file_path);
}
HASH_DEL(mgr->plugins, plugin);
entity_free(plugin);
ret = NEU_ERR_SUCCESS;