diff options
author | Stelios Fragkakis <52996999+stelfrag@users.noreply.github.com> | 2023-09-01 15:37:55 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-01 15:37:55 +0300 |
commit | 24006ed5c19cf7c398cf8a76e7bdce1f60c7e5a4 (patch) | |
tree | b7ef3ec6b5d999d3884b9af40c2b7a53eca8f027 | |
parent | beba227adf489a30e826c3922e4cb3635fb0b154 (diff) |
Reduce label memory (#15255)
34 files changed, 588 insertions, 392 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 38cca3c318..6029ea3080 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -741,6 +741,7 @@ set(RRD_PLUGIN_FILES database/rrdfunctions.h database/rrdhost.c database/rrdlabels.c + database/rrdlabels.h database/rrd.c database/rrd.h database/rrdset.c diff --git a/Makefile.am b/Makefile.am index d0840d0314..e10ce0e8ae 100644 --- a/Makefile.am +++ b/Makefile.am @@ -473,6 +473,7 @@ RRD_PLUGIN_FILES = \ database/rrdfamily.c \ database/rrdhost.c \ database/rrdlabels.c \ + database/rrdlabels.h \ database/rrd.c \ database/rrd.h \ database/rrdset.c \ diff --git a/aclk/aclk.c b/aclk/aclk.c index 312db076ff..854408ce6e 100644 --- a/aclk/aclk.c +++ b/aclk/aclk.c @@ -1292,7 +1292,7 @@ char *aclk_state_json(void) } void add_aclk_host_labels(void) { - DICTIONARY *labels = localhost->rrdlabels; + RRDLABELS *labels = localhost->rrdlabels; #ifdef ENABLE_ACLK rrdlabels_add(labels, "_aclk_available", "true", RRDLABEL_SRC_AUTO|RRDLABEL_SRC_ACLK); diff --git a/aclk/schema-wrappers/node_info.h b/aclk/schema-wrappers/node_info.h index de4ade78aa..4f57601dff 100644 --- a/aclk/schema-wrappers/node_info.h +++ b/aclk/schema-wrappers/node_info.h @@ -39,7 +39,7 @@ struct aclk_node_info { const char *custom_info; const char *machine_guid; - DICTIONARY *host_labels_ptr; + RRDLABELS *host_labels_ptr; struct machine_learning_info ml_info; }; diff --git a/aclk/schema-wrappers/schema_wrapper_utils.cc b/aclk/schema-wrappers/schema_wrapper_utils.cc index 6573e62997..96a4b9bf13 100644 --- a/aclk/schema-wrappers/schema_wrapper_utils.cc +++ b/aclk/schema-wrappers/schema_wrapper_utils.cc @@ -14,8 +14,8 @@ void set_timeval_from_google_timestamp(const google::protobuf::Timestamp &ts, st tv->tv_usec = ts.nanos()/1000; } -int label_add_to_map_callback(const char *name, const char *value, RRDLABEL_SRC ls, void *data) { - (void)ls; +int label_add_to_map_callback(const char *name, const char *value, RRDLABEL_SRC ls __maybe_unused, void *data) +{ auto map = (google::protobuf::Map<std::string, std::string> *)data; map->insert({name, value}); return 1; diff --git a/collectors/cgroups.plugin/sys_fs_cgroup.c b/collectors/cgroups.plugin/sys_fs_cgroup.c index 9c7488c827..893a9445d9 100644 --- a/collectors/cgroups.plugin/sys_fs_cgroup.c +++ b/collectors/cgroups.plugin/sys_fs_cgroup.c @@ -806,7 +806,7 @@ struct cgroup { char *chart_title; - DICTIONARY *chart_labels; + RRDLABELS *chart_labels; int container_orchestrator; @@ -1781,14 +1781,14 @@ static inline void substitute_dots_in_id(char *s) { // ---------------------------------------------------------------------------- // parse k8s labels -char *cgroup_parse_resolved_name_and_labels(DICTIONARY *labels, char *data) { +char *cgroup_parse_resolved_name_and_labels(RRDLABELS *labels, char *data) { // the first word, up to the first space is the name char *name = strsep_skip_consecutive_separators(&data, " "); // the rest are key=value pairs separated by comma while(data) { char *pair = strsep_skip_consecutive_separators(&data, ","); - rrdlabels_add_pair(labels, pair, RRDLABEL_SRC_AUTO| RRDLABEL_SRC_K8S); + rrdlabels_add_pair(labels, pair, RRDLABEL_SRC_AUTO | RRDLABEL_SRC_K8S); } return name; @@ -2745,9 +2745,8 @@ static inline void discovery_process_cgroup(struct cgroup *cg) { if (!k8s_is_kubepod(cg)) { rrdlabels_add(cg->chart_labels, "cgroup_name", cg->chart_id, RRDLABEL_SRC_AUTO); - if (!dictionary_get(cg->chart_labels, "image")) { + if (!rrdlabels_exist(cg->chart_labels, "image")) rrdlabels_add(cg->chart_labels, "image", "", RRDLABEL_SRC_AUTO); - } } worker_is_busy(WORKER_DISCOVERY_PROCESS_NETWORK); diff --git a/collectors/cgroups.plugin/sys_fs_cgroup.h b/collectors/cgroups.plugin/sys_fs_cgroup.h index dc800ba912..625be755da 100644 --- a/collectors/cgroups.plugin/sys_fs_cgroup.h +++ b/collectors/cgroups.plugin/sys_fs_cgroup.h @@ -39,6 +39,6 @@ typedef struct netdata_ebpf_cgroup_shm { #include "../proc.plugin/plugin_proc.h" -char *cgroup_parse_resolved_name_and_labels(DICTIONARY *labels, char *data); +char *cgroup_parse_resolved_name_and_labels(RRDLABELS *labels, char *data); #endif //NETDATA_SYS_FS_CGROUP_H diff --git a/collectors/cgroups.plugin/tests/test_cgroups_plugin.c b/collectors/cgroups.plugin/tests/test_cgroups_plugin.c index a0f9153090..bb1fb39885 100644 --- a/collectors/cgroups.plugin/tests/test_cgroups_plugin.c +++ b/collectors/cgroups.plugin/tests/test_cgroups_plugin.c @@ -20,13 +20,12 @@ struct k8s_test_data { int i; }; -static int read_label_callback(const char *name, const char *value, RRDLABEL_SRC ls, void *data) +static int read_label_callback(const char *name, const char *value, void *data) { struct k8s_test_data *test_data = (struct k8s_test_data *)data; test_data->result_key[test_data->i] = name; test_data->result_value[test_data->i] = value; - test_data->result_ls[test_data->i] = ls; test_data->i++; @@ -37,7 +36,7 @@ static void test_cgroup_parse_resolved_name(void **state) { UNUSED(state); - DICTIONARY *labels = rrdlabels_create(); + RRDLABELS *labels = rrdlabels_create(); struct k8s_test_data test_data[] = { // One label diff --git a/collectors/diskspace.plugin/plugin_diskspace.c b/collectors/diskspace.plugin/plugin_diskspace.c index 2153494d9a..43c9105dc7 100644 --- a/collectors/diskspace.plugin/plugin_diskspace.c +++ b/collectors/diskspace.plugin/plugin_diskspace.c @@ -42,7 +42,7 @@ struct mount_point_metadata { int updated; int slow; - DICTIONARY *chart_labels; + RRDLABELS *chart_labels; size_t collected; // the number of times this has been collected diff --git a/collectors/plugins.d/pluginsd_parser.c b/collectors/plugins.d/pluginsd_parser.c index f8750694b3..9e702bc221 100644 --- a/collectors/plugins.d/pluginsd_parser.c +++ b/collectors/plugins.d/pluginsd_parser.c @@ -353,7 +353,7 @@ static inline PARSER_RC pluginsd_end(char **words, size_t num_words, PARSER *par static void pluginsd_host_define_cleanup(PARSER *parser) { string_freez(parser->user.host_define.hostname); - dictionary_destroy(parser->user.host_define.rrdlabels); + rrdlabels_destroy(parser->user.host_define.rrdlabels); parser->user.host_define.hostname = NULL; parser->user.host_define.rrdlabels = NULL; @@ -390,17 +390,17 @@ static inline PARSER_RC pluginsd_host_define(char **words, size_t num_words, PAR return PARSER_RC_OK; } -static inline PARSER_RC pluginsd_host_dictionary(char **words, size_t num_words, PARSER *parser, DICTIONARY *dict, const char *keyword) { +static inline PARSER_RC pluginsd_host_dictionary(char **words, size_t num_words, PARSER *parser, RRDLABELS *labels, const char *keyword) { char *name = get_word(words, num_words, 1); char *value = get_word(words, num_words, 2); if(!name || !*name || !value) return PLUGINSD_DISABLE_PLUGIN(parser, keyword, "missing parameters"); - if(!parser->user.host_define.parsing_host || !dict) + if(!parser->user.host_define.parsing_host || !labels) return PLUGINSD_DISABLE_PLUGIN(parser, keyword, "host is not defined, send " PLUGINSD_KEYWORD_HOST_DEFINE " before this"); - rrdlabels_add(dict, name, value, RRDLABEL_SRC_CONFIG); + rrdlabels_add(labels, name, value, RRDLABEL_SRC_CONFIG); return PARSER_RC_OK; } @@ -776,7 +776,7 @@ static void inflight_functions_insert_callback(const DICTIONARY_ITEM *item, void if (!pf->payload) return; - + // send the payload to the plugin ret = send_to_plugin(pf->payload, parser); @@ -2097,7 +2097,7 @@ static inline PARSER_RC pluginsd_register_module(char **words __maybe_unused, si struct configurable_plugin *plug_cfg = parser->user.cd->configuration; if (unlikely(plug_cfg == NULL)) return PLUGINSD_DISABLE_PLUGIN(parser, PLUGINSD_KEYWORD_DYNCFG_REGISTER_MODULE, "you have to enable dynamic configuration first using " PLUGINSD_KEYWORD_DYNCFG_ENABLE); - + if (unlikely(num_words != 3)) return PLUGINSD_DISABLE_PLUGIN(parser, PLUGINSD_KEYWORD_DYNCFG_REGISTER_MODULE, "expected 2 parameters module_name followed by module_type"); @@ -2452,7 +2452,7 @@ PARSER_RC parser_execute(PARSER *parser, PARSER_KEYWORD *keyword, char **words, case 101: return pluginsd_register_plugin(words, num_words, parser); - + case 102: return pluginsd_register_module(words, num_words, parser); diff --git a/collectors/plugins.d/pluginsd_parser.h b/collectors/plugins.d/pluginsd_parser.h index 5e1ea12424..8635059d92 100644 --- a/collectors/plugins.d/pluginsd_parser.h +++ b/collectors/plugins.d/pluginsd_parser.h @@ -43,8 +43,8 @@ typedef struct parser_user_object { void *opaque; struct plugind *cd; int trust_durations; - DICTIONARY *new_host_labels; - DICTIONARY *chart_rrdlabels_linked_temporarily; + RRDLABELS *new_host_labels; + RRDLABELS *chart_rrdlabels_linked_temporarily; size_t data_collections_count; int enabled; @@ -55,7 +55,7 @@ typedef struct parser_user_object { uuid_t machine_guid; char machine_guid_str[UUID_STR_LEN]; STRING *hostname; - DICTIONARY *rrdlabels; + RRDLABELS *rrdlabels; } host_define; struct parser_user_object_replay { diff --git a/collectors/proc.plugin/plugin_proc.h b/collectors/proc.plugin/plugin_proc.h index a90f4838e9..a0ddd76c48 100644 --- a/collectors/proc.plugin/plugin_proc.h +++ b/collectors/proc.plugin/plugin_proc.h @@ -58,7 +58,7 @@ void netdev_rename_device_add( const char *host_device, const char *container_device, const char *container_name, - DICTIONARY *labels, + RRDLABELS *labels, const char *ctx_prefix); void netdev_rename_device_del(const char *host_device); diff --git a/collectors/proc.plugin/proc_net_dev.c b/collectors/proc.plugin/proc_net_dev.c index 16881d1709..eb2d0e0c02 100644 --- a/collectors/proc.plugin/proc_net_dev.c +++ b/collectors/proc.plugin/proc_net_dev.c @@ -123,7 +123,7 @@ static struct netdev { const char *chart_family; - DICTIONARY *chart_labels; + RRDLABELS *chart_labels; int flipped; unsigned long priority; @@ -348,7 +348,7 @@ static struct netdev_rename { const char *container_name; const char *ctx_prefix; - DICTIONARY *chart_labels; + RRDLABELS *chart_labels; int processed; @@ -373,7 +373,7 @@ void netdev_rename_device_add( const char *host_device, const char *container_device, const char *container_name, - DICTIONARY *labels, + RRDLABELS *labels, const char *ctx_prefix) { netdata_mutex_lock(&netdev_rename_mutex); diff --git a/collectors/proc.plugin/sys_devices_system_edac_mc.c b/collectors/proc.plugin/sys_devices_system_edac_mc.c index 0947f61f09..fdaa22cb70 100644 --- a/collectors/proc.plugin/sys_devices_system_edac_mc.c +++ b/collectors/proc.plugin/sys_devices_system_edac_mc.c @@ -265,22 +265,22 @@ int do_proc_sys_devices_system_edac_mc(int update_every, usec_t dt __maybe_unuse char buffer[1024 + 1]; - if(read_edac_mc_rank_file(m->name, d->name, "dimm_dev_type", buffer, 1024)) + if (read_edac_mc_rank_file(m->name, d->name, "dimm_dev_type", buffer, 1024)) rrdlabels_add(d->st->rrdlabels, "dimm_dev_type", buffer, RRDLABEL_SRC_AUTO); - if(read_edac_mc_rank_file(m->name, d->name, "dimm_edac_mode", buffer, 1024)) + if (read_edac_mc_rank_file(m->name, d->name, "dimm_edac_mode", buffer, 1024)) rrdlabels_add(d->st->rrdlabels, "dimm_edac_mode", buffer, RRDLABEL_SRC_AUTO); - if(read_edac_mc_rank_file(m->name, d->name, "dimm_label", buffer, 1024)) + if (read_edac_mc_rank_file(m->name, d->name, "dimm_label", buffer, 1024)) rrdlabels_add(d->st->rrdlabels, "dimm_label", buffer, RRDLABEL_SRC_AUTO); - if(read_edac_mc_rank_file(m->name, d->name, "dimm_location", buffer, 1024)) + if (read_edac_mc_rank_file(m->name, d->name, "dimm_location", buffer, 1024)) rrdlabels_add(d->st->rrdlabels, "dimm_location", buffer, RRDLABEL_SRC_AUTO); - if(read_edac_mc_rank_file(m->name, d->name, "dimm_mem_type", buffer, 1024)) + if (read_edac_mc_rank_file(m->name, d->name, "dimm_mem_type", buffer, 1024)) rrdlabels_add(d->st->rrdlabels, "dimm_mem_type", buffer, RRDLABEL_SRC_AUTO); - if(read_edac_mc_rank_file(m->name, d->name, "size", buffer, 1024)) + if (read_edac_mc_rank_file(m->name, d->name, "size", buffer, 1024)) rrdlabels_add(d->st->rrdlabels, "size", buffer, RRDLABEL_SRC_AUTO); d->ce.rd = rrddim_add(d->st, "correctable", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); diff --git a/database/contexts/api_v1.c b/database/contexts/api_v1.c index bc7fee496d..d8446d8490 100644 --- a/database/contexts/api_v1.c +++ b/database/contexts/api_v1.c @@ -213,7 +213,7 @@ static inline int rrdinstance_to_json_callback(const DICTIONARY_ITEM *item, void buffer_json_array_close(wb); } - if(options & RRDCONTEXT_OPTION_SHOW_LABELS && ri->rrdlabels && dictionary_entries(ri->rrdlabels)) { + if(options & RRDCONTEXT_OPTION_SHOW_LABELS && ri->rrdlabels && rrdlabels_entries(ri->rrdlabels)) { buffer_json_member_add_object(wb, "labels"); rrdlabels_to_buffer_json_members(ri->rrdlabels, wb); buffer_json_object_close(wb); diff --git a/database/contexts/api_v2.c b/database/contexts/api_v2.c index ae03228cbd..ff977f7384 100644 --- a/database/contexts/api_v2.c +++ b/database/contexts/api_v2.c @@ -418,7 +418,7 @@ static FTS_MATCH rrdcontext_to_json_v2_full_text_search(struct rrdcontext_to_jso dfe_done(rm); size_t label_searches = 0; - if(unlikely(ri->rrdlabels && dictionary_entries(ri->rrdlabels) && + if(unlikely(ri->rrdlabels && rrdlabels_entries(ri->rrdlabels) && rrdlabels_match_simple_pattern_parsed(ri->rrdlabels, q, ':', &label_searches))) { ctl->q.fts.searches += label_searches; ctl->q.fts.char_searches += label_searches; diff --git a/database/contexts/instance.c b/database/contexts/instance.c index 7e572fb80a..0c1dbf4c49 100644 --- a/database/contexts/instance.c +++ b/database/contexts/instance.c @@ -35,7 +35,7 @@ inline STRING *rrdinstance_acquired_units_dup(RRDINSTANCE_ACQUIRED *ria) { return string_dup(ri->units); } -inline DICTIONARY *rrdinstance_acquired_labels(RRDINSTANCE_ACQUIRED *ria) { +inline RRDLABELS *rrdinstance_acquired_labels(RRDINSTANCE_ACQUIRED *ria) { RRDINSTANCE *ri = rrdinstance_acquired_value(ria); return ri->rrdlabels; } @@ -68,7 +68,7 @@ inline time_t rrdinstance_acquired_update_every(RRDINSTANCE_ACQUIRED *ria) { static void rrdinstance_free(RRDINSTANCE *ri) { if(rrd_flag_check(ri, RRD_FLAG_OWN_LABELS)) - dictionary_destroy(ri->rrdlabels); + rrdlabels_destroy(ri->rrdlabels); rrdmetrics_destroy_from_rrdinstance(ri); string_freez(ri->id); @@ -211,7 +211,7 @@ static bool rrdinstance_conflict_callback(const DICTIONARY_ITEM *item __maybe_un ri->rrdset = ri_new->rrdset; if(ri->rrdset && rrd_flag_check(ri, RRD_FLAG_OWN_LABELS)) { - DICTIONARY *old = ri->rrdlabels; + RRDLABELS *old = ri->rrdlabels; ri->rrdlabels = ri->rrdset->rrdlabels; rrd_flag_clear(ri, RRD_FLAG_OWN_LABELS); rrdlabels_destroy(old); diff --git a/database/contexts/internal.h b/database/contexts/internal.h index 04ad0883a3..293659fdd0 100644 --- a/database/contexts/internal.h +++ b/database/contexts/internal.h @@ -230,7 +230,7 @@ typedef struct rrdinstance { time_t update_every_s; // data collection frequency RRDSET *rrdset; // pointer to RRDSET when collected, or NULL - DICTIONARY *rrdlabels; // linked to RRDSET->chart_labels or own version + RRDLABELS *rrdlabels; // linked to RRDSET->chart_labels or own version struct rrdcontext *rc; DICTIONARY *rrdmetrics; diff --git a/database/contexts/rrdcontext.h b/database/contexts/rrdcontext.h index 0bcdb68ded..ffc42e79a2 100644 --- a/database/contexts/rrdcontext.h +++ b/database/contexts/rrdcontext.h @@ -40,7 +40,7 @@ const char *rrdinstance_acquired_name(RRDINSTANCE_ACQUIRED *ria); bool rrdinstance_acquired_has_name(RRDINSTANCE_ACQUIRED *ria); const char *rrdinstance_acquired_units(RRDINSTANCE_ACQUIRED *ria); STRING *rrdinstance_acquired_units_dup(RRDINSTANCE_ACQUIRED *ria); -DICTIONARY *rrdinstance_acquired_labels(RRDINSTANCE_ACQUIRED *ria); +RRDLABELS *rrdinstance_acquired_labels(RRDINSTANCE_ACQUIRED *ria); DICTIONARY *rrdinstance_acquired_functions(RRDINSTANCE_ACQUIRED *ria); RRDHOST *rrdinstance_acquired_rrdhost(RRDINSTANCE_ACQUIRED *ria); RRDSET *rrdinstance_acquired_rrdset(RRDINSTANCE_ACQUIRED *ria); diff --git a/database/rrd.h b/database/rrd.h index c5a00aceac..baa3f4ab79 100644 --- a/database/rrd.h +++ b/database/rrd.h @@ -23,6 +23,8 @@ typedef struct rrdcalc RRDCALC; typedef struct rrdcalctemplate RRDCALCTEMPLATE; typedef struct alarm_entry ALARM_ENTRY; +typedef struct rrdlabels RRDLABELS; + typedef struct rrdfamily_acquired RRDFAMILY_ACQUIRED; typedef struct rrdvar_acquired RRDVAR_ACQUIRED; typedef struct rrdsetvar_acquired RRDSETVAR_ACQUIRED; @@ -113,6 +115,7 @@ struct ml_metrics_statistics { #include "rrddimvar.h" #include "rrdcalc.h" #include "rrdcalctemplate.h" +#include "rrdlabels.h" #include "streaming/rrdpush.h" #include "aclk/aclk_rrdhost_state.h" #include "sqlite/sqlite_health.h" @@ -265,60 +268,6 @@ typedef enum __attribute__ ((__packed__)) rrddim_flags { #define rrddim_flag_set(rd, flag) __atomic_or_fetch(&((rd)->flags), (flag), __ATOMIC_SEQ_CST) #define rrddim_flag_clear(rd, flag) __atomic_and_fetch(&((rd)->flags), ~(flag), __ATOMIC_SEQ_CST) -typedef enum __attribute__ ((__packed__)) rrdlabel_source { - RRDLABEL_SRC_AUTO = (1 << 0), // set when Netdata found the label by some automation - RRDLABEL_SRC_CONFIG = (1 << 1), // set when the user configured the label - RRDLABEL_SRC_K8S = (1 << 2), // set when this label is found from k8s (RRDLABEL_SRC_AUTO should also be set) - RRDLABEL_SRC_ACLK = (1 << 3), // set when this label is found from ACLK (RRDLABEL_SRC_AUTO should also be set) - - // more sources can be added here - - RRDLABEL_FLAG_PERMANENT = (1 << 29), // set when this label should never be removed (can be overwritten though) - RRDLABEL_FLAG_OLD = (1 << 30), // marks for rrdlabels internal use - they are not exposed outside rrdlabels - RRDLABEL_FLAG_NEW = (1 << 31) // marks for rrdlabels internal use - they are not exposed outside rrdlabels -} RRDLABEL_SRC; - -#define RRDLABEL_FLAG_INTERNAL (RRDLABEL_FLAG_OLD | RRDLABEL_FLAG_NEW | RRDLABEL_FLAG_PERMANENT) - -size_t text_sanitize(unsigned char *dst, const unsigned char *src, size_t dst_size, unsigned char *char_map, bool utf, const char *empty, size_t *multibyte_length); - -DICTIONARY *rrdlabels_create(void); -void rrdlabels_destroy(DICTIONARY *labels_dict); -void rrdlabels_add(DICTIONARY *dict, const char *name, const char *value, RRDLABEL_SRC ls); -void rrdlabels_add_pair(DICTIONARY *dict, const char *string, RRDLABEL_SRC ls); -void rrdlabels_get_value_to_buffer_or_null(DICTIONARY *labels, BUFFER *wb, const char *key, const char *quote, const char *null); -void rrdlabels_value_to_buffer_array_item_or_null(DICTIONARY *labels, BUFFER *wb, const char *key); -void rrdlabels_get_value_strdup_or_null(DICTIONARY *labels, char **value, const char *key); -void rrdlabels_get_value_strcpyz(DICTIONARY *labels, char *dst, size_t dst_len, const char *key); -STRING *rrdlabels_get_value_string_dup(DICTIONARY *labels, const char *key); -STRING *rrdlabels_get_value_to_buffer_or_unset(DICTIONARY *labels, BUFFER *wb, const char *key, const char *unset); -void rrdlabels_flush(DICTIONARY *labels_dict); - -void rrdlabels_unmark_all(DICTIONARY *labels); -void rrdlabels_remove_all_unmarked(DICTIONARY *labels); - -int rrdlabels_walkthrough_read(DICTIONARY *labels, int (*callback)(const char *name, const char *value, RRDLABEL_SRC ls, void *data), void *data); -int rrdlabels_sorted_walkthrough_read(DICTIONARY *labels, int (*callback)(const char *name, const char *value, RRDLABEL_SRC ls, void *data), void *data); - -void rrdlabels_log_to_buffer(DICTIONARY *labels, BUFFER *wb); -bool rrdlabels_match_simple_pattern(DICTIONARY *labels, const char *simple_pattern_txt); - -bool rrdlabels_match_simple_pattern_parsed(DICTIONARY *labels, SIMPLE_PATTERN *pattern, char equal, size_t *searches); -int rrdlabels_to_buffer(DICTIONARY *labels, BUFFER *wb, const char *before_each, const char *equal, const char *quote, const char *between_them, bool (*filter_callback)(const char *name, const char *value, RRDLABEL_SRC ls, void *data), void *filter_data, void (*name_sanitizer)(char *dst, const char *src, size_t dst_size), void (*value_sanitizer)(char *dst, const char *src, size_t dst_size)); -void rrdlabels_to_buffer_json_members(DICTIONARY *labels, BUFFER *wb); - -void rrdlabels_migrate_to_these(DICTIONARY *dst, DICTIONARY *src); -void rrdlabels_copy(DICTIONARY *dst, DICTIONARY *src); - -void reload_host_labels(void); -void rrdset_update_rrdlabels(RRDSET *st, DICTIONARY *new_rrdlabels); -void rrdset_save_rrdlabels_to_sql(RRDSET *st); -void rrdhost_set_is_parent_label(void); -int rrdlabels_unittest(void); - -// unfortunately this break when defined in exporting_engine.h -bool exporting_labels_filter_callback(const char *name, const char *value, RRDLABEL_SRC ls, void *data); - // ---------------------------------------------------------------------------- // engine-specific iterator state for dimension data collection typedef struct storage_collect_handle { @@ -795,7 +744,7 @@ struct rrdset { int32_t priority; // the sorting priority of this chart int32_t update_every; // data collection frequency - DICTIONARY *rrdlabels; // chart labels + RRDLABELS *rrdlabels; // chart labels DICTIONARY *rrdsetvar_root_index; // chart variables DICTIONARY *rrddimvar_root_index; // dimension variables // we use this dictionary to manage their allocation @@ -1156,7 +1105,7 @@ struct rrdhost_system_info { int mc_version; }; -struct rrdhost_system_info *rrdhost_labels_to_system_info(DICTIONARY *labels); +struct rrdhost_system_info *rrdhost_labels_to_system_info(RRDLABELS *labels); struct rrdhost { char machine_guid[GUID_LEN + 1]; // the unique ID of this host @@ -1263,7 +1212,7 @@ struct rrdhost { // ------------------------------------------------------------------------ // Support for host-level labels - DICTIONARY *rrdlabels; + RRDLABELS *rrdlabels; // ------------------------------------------------------------------------ // Support for functions @@ -1509,6 +1458,8 @@ time_t rrdset_last_entry_s_of_tier(RRDSET *st, size_t tier); void rrdset_get_retention_of_tier_for_collected_chart(RRDSET *st, time_t *first_time_s, time_t *last_time_s, time_t now_s, size_t tier); +void rrdset_update_rrdlabels(RRDSET *st, RRDLABELS *new_rrdlabels); + // ---------------------------------------------------------------------------- // RRD DIMENSION functions @@ -1563,6 +1514,8 @@ void rrddim_store_metric(RRDDIM *rd, usec_t point_end_time_ut, NETDATA_DOUBLE n, // Miscellaneous functions char *rrdset_strncpyz_name(char *to, const char *from, size_t length); +void reload_host_labels(void); +void rrdhost_set_is_parent_label(void); // ---------------------------------------------------------------------------- // RRD internal functions diff --git a/database/rrdcalc.c b/database/rrdcalc.c index 8e41df8d65..9278aaf348 100644 --- a/database/rrdcalc.c +++ b/database/rrdcalc.c @@ -155,7 +155,7 @@ static STRING *rrdcalc_replace_variables_with_rrdset_labels(const char *line, RR void rrdcalc_update_info_using_rrdset_labels(RRDCALC *rc) { if(!rc->rrdset || !rc->original_info || !rc->rrdset->rrdlabels) return; - size_t labels_version = dictionary_version(rc->rrdset->rrdlabels); + size_t labels_version = rrdlabels_version(rc->rrdset->rrdlabels); if(rc->labels_version != labels_version) { STRING *old = rc->info; diff --git a/database/rrdhost.c b/database/rrdhost.c index b24047f401..2a5778bf15 100644 --- a/database/rrdhost.c +++ b/database/rrdhost.c @@ -1317,7 +1317,7 @@ void rrdhost_save_charts(RRDHOST *host) { rrdset_foreach_done(st); } -struct rrdhost_system_info *rrdhost_labels_to_system_info(DICTIONARY *labels) { +struct rrdhost_system_info *rrdhost_labels_to_system_info(RRDLABELS *labels) { struct rrdhost_syste |