This commit is contained in:
dmchen 2023-10-24 09:52:34 +00:00
parent ff46bdb17a
commit 4c401c39fb
5 changed files with 21 additions and 9 deletions

View File

@ -99,12 +99,12 @@ void dmSendMonitorReport() {
if (!tsEnableMonitor || tsMonitorFqdn[0] == 0 || tsMonitorPort == 0) return; if (!tsEnableMonitor || tsMonitorFqdn[0] == 0 || tsMonitorPort == 0) return;
dTrace("send monitor report to %s:%u", tsMonitorFqdn, tsMonitorPort); dTrace("send monitor report to %s:%u", tsMonitorFqdn, tsMonitorPort);
SDnode *pDnode = dmInstance(); //SDnode *pDnode = dmInstance();
dmGetDmMonitorInfo(pDnode); //dmGetDmMonitorInfo(pDnode);
dmGetMmMonitorInfo(pDnode); //dmGetMmMonitorInfo(pDnode);
dmGetVmMonitorInfo(pDnode); //dmGetVmMonitorInfo(pDnode);
dmGetQmMonitorInfo(pDnode); //dmGetQmMonitorInfo(pDnode);
dmGetSmMonitorInfo(pDnode); //dmGetSmMonitorInfo(pDnode);
//monSendReport(); //monSendReport();
monSendPromReport(); monSendPromReport();

View File

@ -22,7 +22,7 @@
struct taos_metric_sample { struct taos_metric_sample {
taos_metric_type_t type; /**< type is the metric type for the sample */ taos_metric_type_t type; /**< type is the metric type for the sample */
char *l_value; /**< l_value is the full metric name and label set represeted as a string */ char *l_value; /**< l_value is the full metric name and label set represeted as a string */
_Atomic double r_value; /**< r_value is the value of the metric sample */ /*_Atomic*/ int64_t r_value; /**< r_value is the value of the metric sample */
}; };
#endif // TAOS_METRIC_SAMPLE_T_H #endif // TAOS_METRIC_SAMPLE_T_H

View File

@ -14,7 +14,6 @@
*/ */
#include <stdio.h> #include <stdio.h>
#include <unistd.h>
// Public // Public
#include "taos_alloc.h" #include "taos_alloc.h"

View File

@ -171,7 +171,7 @@ int taos_metric_formatter_load_sample(taos_metric_formatter_t *self, taos_metric
if (r) return r; if (r) return r;
char buffer[50]; char buffer[50];
sprintf(buffer, "%.17g", sample->r_value); sprintf(buffer, "%ld", sample->r_value);
r = taos_string_builder_add_str(self->string_builder, buffer); r = taos_string_builder_add_str(self->string_builder, buffer);
if (r) return r; if (r) return r;

View File

@ -24,6 +24,7 @@
#include "taos_log.h" #include "taos_log.h"
#include "taos_metric_sample_i.h" #include "taos_metric_sample_i.h"
#include "taos_metric_sample_t.h" #include "taos_metric_sample_t.h"
#include "osAtomic.h"
taos_metric_sample_t *taos_metric_sample_new(taos_metric_type_t type, const char *l_value, double r_value) { taos_metric_sample_t *taos_metric_sample_new(taos_metric_type_t type, const char *l_value, double r_value) {
taos_metric_sample_t *self = (taos_metric_sample_t *)taos_malloc(sizeof(taos_metric_sample_t)); taos_metric_sample_t *self = (taos_metric_sample_t *)taos_malloc(sizeof(taos_metric_sample_t));
@ -62,13 +63,18 @@ int taos_metric_sample_add(taos_metric_sample_t *self, double r_value) {
if (r_value < 0) { if (r_value < 0) {
return 1; return 1;
} }
/*
_Atomic double old = atomic_load(&self->r_value); _Atomic double old = atomic_load(&self->r_value);
for (;;) { for (;;) {
_Atomic double new = ATOMIC_VAR_INIT(old + r_value); _Atomic double new = ATOMIC_VAR_INIT(old + r_value);
if (atomic_compare_exchange_weak(&self->r_value, &old, new)) { if (atomic_compare_exchange_weak(&self->r_value, &old, new)) {
return 0; return 0;
} }
} }
*/
atomic_fetch_add_64(&self->r_value, r_value);
return 0;
} }
int taos_metric_sample_sub(taos_metric_sample_t *self, double r_value) { int taos_metric_sample_sub(taos_metric_sample_t *self, double r_value) {
@ -77,6 +83,7 @@ int taos_metric_sample_sub(taos_metric_sample_t *self, double r_value) {
TAOS_LOG(TAOS_METRIC_INCORRECT_TYPE); TAOS_LOG(TAOS_METRIC_INCORRECT_TYPE);
return 1; return 1;
} }
/*
_Atomic double old = atomic_load(&self->r_value); _Atomic double old = atomic_load(&self->r_value);
for (;;) { for (;;) {
_Atomic double new = ATOMIC_VAR_INIT(old - r_value); _Atomic double new = ATOMIC_VAR_INIT(old - r_value);
@ -84,6 +91,9 @@ int taos_metric_sample_sub(taos_metric_sample_t *self, double r_value) {
return 0; return 0;
} }
} }
*/
atomic_fetch_sub_64(&self->r_value, r_value);
return 0;
} }
int taos_metric_sample_set(taos_metric_sample_t *self, double r_value) { int taos_metric_sample_set(taos_metric_sample_t *self, double r_value) {
@ -91,6 +101,9 @@ int taos_metric_sample_set(taos_metric_sample_t *self, double r_value) {
TAOS_LOG(TAOS_METRIC_INCORRECT_TYPE); TAOS_LOG(TAOS_METRIC_INCORRECT_TYPE);
return 1; return 1;
} }
/*
atomic_store(&self->r_value, r_value); atomic_store(&self->r_value, r_value);
*/
atomic_store_64(&self->r_value, r_value);
return 0; return 0;
} }