not log null, memory leak, skip empty, default config
This commit is contained in:
parent
4605f6b011
commit
7752a57580
|
@ -95,7 +95,7 @@ int32_t tsMonitorMaxLogs = 100;
|
|||
bool tsMonitorComp = false;
|
||||
bool tsMonitorLogProtocol = false;
|
||||
int32_t tsMonitorIntervalForBasic = 30;
|
||||
bool tsMonitorForceV2 = false;
|
||||
bool tsMonitorForceV2 = true;
|
||||
|
||||
// audit
|
||||
bool tsEnableAudit = true;
|
||||
|
|
|
@ -638,8 +638,13 @@ void monSendPromReport() {
|
|||
char* promStr = NULL;
|
||||
char* pCont = (char *)taos_collector_registry_bridge_new(TAOS_COLLECTOR_REGISTRY_DEFAULT, ts, "%" PRId64, &promStr);
|
||||
if(tsMonitorLogProtocol){
|
||||
uInfoL("report cont:\n%s\n", pCont);
|
||||
uDebugL("report cont prom:\n%s\n", promStr);
|
||||
if(pCont != NULL){
|
||||
uInfoL("report cont:\n%s", pCont);
|
||||
uDebugL("report cont prom:\n%s", promStr);
|
||||
}
|
||||
else{
|
||||
uInfo("report cont is null");
|
||||
}
|
||||
}
|
||||
if (pCont != NULL) {
|
||||
EHttpCompFlag flag = tsMonitor.cfg.comp ? HTTP_GZIP : HTTP_FLAT;
|
||||
|
|
|
@ -601,7 +601,12 @@ void monGenAndSendReport() {
|
|||
void monSendReportBasic(SMonInfo *pMonitor){
|
||||
char *pCont = tjsonToString(pMonitor->pJson);
|
||||
if(tsMonitorLogProtocol){
|
||||
uInfoL("report cont basic:\n%s", pCont);
|
||||
if(pCont != NULL){
|
||||
uInfoL("report cont basic:\n%s", pCont);
|
||||
}
|
||||
else{
|
||||
uInfo("report cont basic is null");
|
||||
}
|
||||
}
|
||||
if (pCont != NULL) {
|
||||
EHttpCompFlag flag = tsMonitor.cfg.comp ? HTTP_GZIP : HTTP_FLAT;
|
||||
|
@ -614,13 +619,13 @@ void monSendReportBasic(SMonInfo *pMonitor){
|
|||
|
||||
void monGenAndSendReportBasic() {
|
||||
SMonInfo *pMonitor = monCreateMonitorInfo();
|
||||
if (pMonitor == NULL) return;
|
||||
if (pMonitor->mmInfo.cluster.first_ep_dnode_id == 0) return;
|
||||
|
||||
monGenBasicJsonBasic(pMonitor);
|
||||
monGenClusterJsonBasic(pMonitor);
|
||||
|
||||
monSendReportBasic(pMonitor);
|
||||
if (pMonitor->mmInfo.cluster.first_ep_dnode_id != 0) {
|
||||
monSendReportBasic(pMonitor);
|
||||
}
|
||||
|
||||
monCleanupMonitorInfo(pMonitor);
|
||||
}
|
|
@ -234,6 +234,11 @@ const char *taos_collector_registry_bridge_new(taos_collector_registry_t *self,
|
|||
|
||||
taos_metric_formatter_load_metrics_new(self->metric_formatter, self->collectors, ts, format, array);
|
||||
|
||||
if(tjsonGetArraySize(array) == 0){
|
||||
tjsonDelete(pJson);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//caller free this
|
||||
//generate prom protocol for debug
|
||||
if(prom_str != NULL){
|
||||
|
@ -245,36 +250,40 @@ const char *taos_collector_registry_bridge_new(taos_collector_registry_t *self,
|
|||
char* old_str = taos_string_builder_str(self->string_builder_batch);
|
||||
if(old_str[0] != '\0'){
|
||||
r = taos_string_builder_add_str(self->string_builder_batch, ",");
|
||||
if (r) return NULL;
|
||||
if (r) goto _OVER;
|
||||
}
|
||||
char * item_str = tjsonToString(item);
|
||||
r = taos_string_builder_add_str(self->string_builder_batch, item_str);
|
||||
taos_free(item_str);
|
||||
if (r) return NULL;
|
||||
|
||||
tjsonDelete(pJson);
|
||||
if (r) goto _OVER;;
|
||||
|
||||
//generate final array format result, ie, add [] to str in batch cache
|
||||
taos_string_builder_t* tmp_builder = taos_string_builder_new();
|
||||
|
||||
r = taos_string_builder_add_str(tmp_builder, "[");
|
||||
if (r) return NULL;
|
||||
if (r) goto _OVER;;
|
||||
|
||||
r = taos_string_builder_add_str(tmp_builder, taos_string_builder_str(self->string_builder_batch));
|
||||
if (r) return NULL;
|
||||
if (r) goto _OVER;;
|
||||
|
||||
r = taos_string_builder_add_str(tmp_builder, "]");
|
||||
if (r) return NULL;
|
||||
if (r) goto _OVER;;
|
||||
|
||||
//caller free this
|
||||
char *data = taos_string_builder_dump(tmp_builder);
|
||||
if (data == NULL) return NULL;
|
||||
if (data == NULL) goto _OVER;;
|
||||
r = taos_string_builder_clear(tmp_builder);
|
||||
if (r) return NULL;
|
||||
if (r) goto _OVER;;
|
||||
|
||||
r = taos_string_builder_destroy(tmp_builder);
|
||||
tmp_builder = NULL;
|
||||
if (r) return NULL;
|
||||
if (r) goto _OVER;;
|
||||
|
||||
tjsonDelete(pJson);
|
||||
return data;
|
||||
|
||||
_OVER:
|
||||
tjsonDelete(pJson);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue