Merge pull request #24909 from taosdata/fix/TD-28872

coverage
This commit is contained in:
Hongze Cheng 2024-02-28 13:53:34 +08:00 committed by GitHub
commit f3e7bc130b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 14 additions and 10 deletions

View File

@ -216,7 +216,7 @@ int taos_collector_registry_validate_metric_name(taos_collector_registry_t *self
regfree(&r); regfree(&r);
return 0; return 0;
} }
/*
const char *taos_collector_registry_bridge(taos_collector_registry_t *self, char *ts, char *format) { 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_clear(self->metric_formatter);
taos_metric_formatter_load_metrics(self->metric_formatter, self->collectors, ts, format); taos_metric_formatter_load_metrics(self->metric_formatter, self->collectors, ts, format);
@ -229,7 +229,7 @@ const char *taos_collector_registry_bridge(taos_collector_registry_t *self, char
return taos_string_builder_str(self->string_builder_batch); return taos_string_builder_str(self->string_builder_batch);
} }
*/
int taos_collector_registry_clear_batch(taos_collector_registry_t *self){ int taos_collector_registry_clear_batch(taos_collector_registry_t *self){
return taos_string_builder_clear(self->string_builder_batch); return taos_string_builder_clear(self->string_builder_batch);
} }

View File

@ -38,7 +38,7 @@ int taos_gauge_destroy(taos_gauge_t *self) {
self = NULL; self = NULL;
return r; return r;
} }
/*
int taos_gauge_inc(taos_gauge_t *self, const char **label_values) { int taos_gauge_inc(taos_gauge_t *self, const char **label_values) {
TAOS_ASSERT(self != NULL); TAOS_ASSERT(self != NULL);
if (self == NULL) return 1; if (self == NULL) return 1;
@ -86,7 +86,7 @@ int taos_gauge_sub(taos_gauge_t *self, double r_value, const char **label_values
if (sample == NULL) return 1; if (sample == NULL) return 1;
return taos_metric_sample_sub(sample, r_value); return taos_metric_sample_sub(sample, r_value);
} }
*/
int taos_gauge_set(taos_gauge_t *self, double r_value, const char **label_values) { int taos_gauge_set(taos_gauge_t *self, double r_value, const char **label_values) {
TAOS_ASSERT(self != NULL); TAOS_ASSERT(self != NULL);
if (self == NULL) return 1; if (self == NULL) return 1;

View File

@ -63,7 +63,7 @@ int taos_metric_formatter_destroy(taos_metric_formatter_t *self) {
self = NULL; self = NULL;
return ret; return ret;
} }
/*
int taos_metric_formatter_load_help(taos_metric_formatter_t *self, const char *name, const char *help) { int taos_metric_formatter_load_help(taos_metric_formatter_t *self, const char *name, const char *help) {
TAOS_ASSERT(self != NULL); TAOS_ASSERT(self != NULL);
if (self == NULL) return 1; if (self == NULL) return 1;
@ -105,7 +105,7 @@ int taos_metric_formatter_load_type(taos_metric_formatter_t *self, const char *n
return taos_string_builder_add_char(self->string_builder, '\n'); return taos_string_builder_add_char(self->string_builder, '\n');
} }
*/
int taos_metric_formatter_load_l_value(taos_metric_formatter_t *self, const char *name, const char *suffix, int taos_metric_formatter_load_l_value(taos_metric_formatter_t *self, const char *name, const char *suffix,
size_t label_count, const char **label_keys, const char **label_values) { size_t label_count, const char **label_keys, const char **label_values) {
TAOS_ASSERT(self != NULL); TAOS_ASSERT(self != NULL);
@ -156,7 +156,7 @@ int taos_metric_formatter_load_l_value(taos_metric_formatter_t *self, const char
} }
return 0; return 0;
} }
/*
int taos_metric_formatter_load_sample(taos_metric_formatter_t *self, taos_metric_sample_t *sample, int taos_metric_formatter_load_sample(taos_metric_formatter_t *self, taos_metric_sample_t *sample,
char *ts, char *format) { char *ts, char *format) {
TAOS_ASSERT(self != NULL); TAOS_ASSERT(self != NULL);
@ -185,7 +185,7 @@ int taos_metric_formatter_load_sample(taos_metric_formatter_t *self, taos_metric
return taos_string_builder_add_char(self->string_builder, '\n'); return taos_string_builder_add_char(self->string_builder, '\n');
} }
*/
int taos_metric_formatter_clear(taos_metric_formatter_t *self) { int taos_metric_formatter_clear(taos_metric_formatter_t *self) {
TAOS_ASSERT(self != NULL); TAOS_ASSERT(self != NULL);
return taos_string_builder_clear(self->string_builder); return taos_string_builder_clear(self->string_builder);
@ -204,7 +204,7 @@ char *taos_metric_formatter_dump(taos_metric_formatter_t *self) {
} }
return data; return data;
} }
/*
int taos_metric_formatter_load_metric(taos_metric_formatter_t *self, taos_metric_t *metric, char *ts, char *format) { int taos_metric_formatter_load_metric(taos_metric_formatter_t *self, taos_metric_t *metric, char *ts, char *format) {
TAOS_ASSERT(self != NULL); TAOS_ASSERT(self != NULL);
if (self == NULL) return 1; if (self == NULL) return 1;
@ -255,3 +255,4 @@ int taos_metric_formatter_load_metrics(taos_metric_formatter_t *self, taos_map_t
} }
return r; return r;
} }
*/

View File

@ -91,6 +91,7 @@ int taos_metric_sample_add(taos_metric_sample_t *self, double r_value) {
return 0; 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) {
TAOS_ASSERT(self != NULL); TAOS_ASSERT(self != NULL);
if (self->type != TAOS_GAUGE) { if (self->type != TAOS_GAUGE) {
@ -99,7 +100,8 @@ int taos_metric_sample_sub(taos_metric_sample_t *self, double r_value) {
} }
#ifdef C11_ATOMIC #ifdef C11_ATOMIC
/*_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)) {
@ -116,6 +118,7 @@ int taos_metric_sample_sub(taos_metric_sample_t *self, double r_value) {
return 0; 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) {
if (self->type != TAOS_GAUGE && self->type != TAOS_COUNTER) { if (self->type != TAOS_GAUGE && self->type != TAOS_COUNTER) {