format
This commit is contained in:
parent
4c401c39fb
commit
8e007f199b
|
@ -103,7 +103,7 @@ int taos_collector_registry_register_collector(taos_collector_registry_t *self,
|
|||
* @param self The target taos_collector_registry_t*
|
||||
* @return The string int he default metric exposition format.
|
||||
*/
|
||||
const char *taos_collector_registry_bridge(taos_collector_registry_t *self, char *ts);
|
||||
const char *taos_collector_registry_bridge(taos_collector_registry_t *self, char *ts, char *format);
|
||||
|
||||
int taos_collector_registry_clear_out(taos_collector_registry_t *self);
|
||||
|
||||
|
|
|
@ -99,13 +99,13 @@ void dmSendMonitorReport() {
|
|||
if (!tsEnableMonitor || tsMonitorFqdn[0] == 0 || tsMonitorPort == 0) return;
|
||||
dTrace("send monitor report to %s:%u", tsMonitorFqdn, tsMonitorPort);
|
||||
|
||||
//SDnode *pDnode = dmInstance();
|
||||
//dmGetDmMonitorInfo(pDnode);
|
||||
//dmGetMmMonitorInfo(pDnode);
|
||||
//dmGetVmMonitorInfo(pDnode);
|
||||
//dmGetQmMonitorInfo(pDnode);
|
||||
//dmGetSmMonitorInfo(pDnode);
|
||||
//monSendReport();
|
||||
SDnode *pDnode = dmInstance();
|
||||
dmGetDmMonitorInfo(pDnode);
|
||||
dmGetMmMonitorInfo(pDnode);
|
||||
dmGetVmMonitorInfo(pDnode);
|
||||
dmGetQmMonitorInfo(pDnode);
|
||||
dmGetSmMonitorInfo(pDnode);
|
||||
monSendReport();
|
||||
|
||||
monSendPromReport();
|
||||
}
|
||||
|
|
|
@ -554,7 +554,7 @@ void monSendReport() {
|
|||
void monSendPromReport() {
|
||||
char ts[50];
|
||||
sprintf(ts, "%" PRId64, taosGetTimestamp(TSDB_TIME_PRECISION_MILLI));
|
||||
char *pCont = (char *)taos_collector_registry_bridge(TAOS_COLLECTOR_REGISTRY_DEFAULT, ts);
|
||||
char *pCont = (char *)taos_collector_registry_bridge(TAOS_COLLECTOR_REGISTRY_DEFAULT, ts, "%" PRId64);
|
||||
//uInfoL("report cont:\n%s\n", pCont);
|
||||
if (pCont != NULL) {
|
||||
EHttpCompFlag flag = tsMonitor.cfg.comp ? HTTP_GZIP : HTTP_FLAT;
|
||||
|
|
|
@ -56,18 +56,18 @@ int taos_metric_formatter_load_l_value(taos_metric_formatter_t *metric_formatter
|
|||
/**
|
||||
* @brief API PRIVATE Loads the formatter with a metric sample
|
||||
*/
|
||||
int taos_metric_formatter_load_sample(
|
||||
taos_metric_formatter_t *metric_formatter, taos_metric_sample_t *sample, char *ts);
|
||||
int taos_metric_formatter_load_sample(taos_metric_formatter_t *metric_formatter, taos_metric_sample_t *sample,
|
||||
char *ts, char *format);
|
||||
|
||||
/**
|
||||
* @brief API PRIVATE Loads a metric in the string exposition format
|
||||
*/
|
||||
int taos_metric_formatter_load_metric(taos_metric_formatter_t *self, taos_metric_t *metric, char *ts);
|
||||
int taos_metric_formatter_load_metric(taos_metric_formatter_t *self, taos_metric_t *metric, char *ts, char *format);
|
||||
|
||||
/**
|
||||
* @brief API PRIVATE Loads the given metrics
|
||||
*/
|
||||
int taos_metric_formatter_load_metrics(taos_metric_formatter_t *self, taos_map_t *collectors, char *ts);
|
||||
int taos_metric_formatter_load_metrics(taos_metric_formatter_t *self, taos_map_t *collectors, char *ts, char *format);
|
||||
|
||||
/**
|
||||
* @brief API PRIVATE Clear the underlying string_builder
|
||||
|
|
|
@ -186,9 +186,9 @@ int taos_collector_registry_validate_metric_name(taos_collector_registry_t *self
|
|||
return 0;
|
||||
}
|
||||
|
||||
const char *taos_collector_registry_bridge(taos_collector_registry_t *self, char *ts) {
|
||||
const char *taos_collector_registry_bridge(taos_collector_registry_t *self, char *ts, char *format) {
|
||||
taos_metric_formatter_clear(self->metric_formatter);
|
||||
taos_metric_formatter_load_metrics(self->metric_formatter, self->collectors, ts);
|
||||
taos_metric_formatter_load_metrics(self->metric_formatter, self->collectors, ts, format);
|
||||
char *out = taos_metric_formatter_dump(self->metric_formatter);
|
||||
|
||||
int r = 0;
|
||||
|
|
|
@ -158,7 +158,8 @@ int taos_metric_formatter_load_l_value(taos_metric_formatter_t *self, const char
|
|||
return 0;
|
||||
}
|
||||
|
||||
int taos_metric_formatter_load_sample(taos_metric_formatter_t *self, taos_metric_sample_t *sample, char *ts) {
|
||||
int taos_metric_formatter_load_sample(taos_metric_formatter_t *self, taos_metric_sample_t *sample,
|
||||
char *ts, char *format) {
|
||||
TAOS_ASSERT(self != NULL);
|
||||
if (self == NULL) return 1;
|
||||
|
||||
|
@ -171,7 +172,7 @@ int taos_metric_formatter_load_sample(taos_metric_formatter_t *self, taos_metric
|
|||
if (r) return r;
|
||||
|
||||
char buffer[50];
|
||||
sprintf(buffer, "%ld", sample->r_value);
|
||||
sprintf(buffer, format, sample->r_value);
|
||||
r = taos_string_builder_add_str(self->string_builder, buffer);
|
||||
if (r) return r;
|
||||
|
||||
|
@ -205,7 +206,7 @@ char *taos_metric_formatter_dump(taos_metric_formatter_t *self) {
|
|||
return data;
|
||||
}
|
||||
|
||||
int taos_metric_formatter_load_metric(taos_metric_formatter_t *self, taos_metric_t *metric, char *ts) {
|
||||
int taos_metric_formatter_load_metric(taos_metric_formatter_t *self, taos_metric_t *metric, char *ts, char *format) {
|
||||
TAOS_ASSERT(self != NULL);
|
||||
if (self == NULL) return 1;
|
||||
|
||||
|
@ -225,14 +226,14 @@ int taos_metric_formatter_load_metric(taos_metric_formatter_t *self, taos_metric
|
|||
} else {
|
||||
taos_metric_sample_t *sample = (taos_metric_sample_t *)taos_map_get(metric->samples, key);
|
||||
if (sample == NULL) return 1;
|
||||
r = taos_metric_formatter_load_sample(self, sample, ts);
|
||||
r = taos_metric_formatter_load_sample(self, sample, ts, format);
|
||||
if (r) return r;
|
||||
}
|
||||
}
|
||||
return taos_string_builder_add_char(self->string_builder, '\n');
|
||||
}
|
||||
|
||||
int taos_metric_formatter_load_metrics(taos_metric_formatter_t *self, taos_map_t *collectors, char *ts) {
|
||||
int taos_metric_formatter_load_metrics(taos_metric_formatter_t *self, taos_map_t *collectors, char *ts, char *format) {
|
||||
TAOS_ASSERT(self != NULL);
|
||||
int r = 0;
|
||||
for (taos_linked_list_node_t *current_node = collectors->keys->head; current_node != NULL;
|
||||
|
@ -249,7 +250,7 @@ int taos_metric_formatter_load_metrics(taos_metric_formatter_t *self, taos_map_t
|
|||
const char *metric_name = (const char *)current_node->item;
|
||||
taos_metric_t *metric = (taos_metric_t *)taos_map_get(metrics, metric_name);
|
||||
if (metric == NULL) return 1;
|
||||
r = taos_metric_formatter_load_metric(self, metric, ts);
|
||||
r = taos_metric_formatter_load_metric(self, metric, ts, format);
|
||||
if (r) return r;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue