@cryptotaxi247 / netdata-1 / commits / 48af9dc2e

do not propagate upstream internal label sources (#16295)

Costa Tsaousis committed Oct 28, 2023 at 17:40 UTC 48af9dc2e00b4cfdd6964503fa9d6902678447d4
6 files changed +21 -19
collectors/proc.plugin/proc_net_dev.c
+4 -4
@@ -521,7 +521,7 @@ static inline void netdev_rename_cgroup(struct netdev *d, struct netdev_rename *
521 d->chart_family = strdupz("net");
522
523 rrdlabels_copy(d->chart_labels, r->chart_labels);
524 - rrdlabels_add(d->chart_labels, "container_device", r->container_device, RRDLABEL_SRC_AUTO | RRDLABEL_FLAG_PERMANENT);
524 + rrdlabels_add(d->chart_labels, "container_device", r->container_device, RRDLABEL_SRC_AUTO);
525
526 d->priority = NETDATA_CHART_PRIO_CGROUP_NET_IFACE;
527 d->flipped = 1;
@@ -785,13 +785,13 @@ int do_proc_net_dev(int update_every, usec_t dt) {
785 snprintfz(buffer, FILENAME_MAX, path_to_sys_devices_virtual_net, d->name);
786 if (likely(access(buffer, R_OK) == 0)) {
787 d->virtual = 1;
788 - rrdlabels_add(d->chart_labels, "interface_type", "virtual", RRDLABEL_SRC_AUTO|RRDLABEL_FLAG_PERMANENT);
788 + rrdlabels_add(d->chart_labels, "interface_type", "virtual", RRDLABEL_SRC_AUTO);
789 }
790 else {
791 d->virtual = 0;
792 - rrdlabels_add(d->chart_labels, "interface_type", "real", RRDLABEL_SRC_AUTO|RRDLABEL_FLAG_PERMANENT);
792 + rrdlabels_add(d->chart_labels, "interface_type", "real", RRDLABEL_SRC_AUTO);
793 }
794 - rrdlabels_add(d->chart_labels, "device", name, RRDLABEL_SRC_AUTO|RRDLABEL_FLAG_PERMANENT);
794 + rrdlabels_add(d->chart_labels, "device", name, RRDLABEL_SRC_AUTO);
795
796 if(likely(!d->virtual)) {
797 // set the filename to get the interface speed
database/rrdlabels.c
+1 -1
@@ -937,7 +937,7 @@ static void rrdlabels_remove_all_unmarked_unsafe(RRDLABELS *labels)
937 bool first_then_next = true;
938
939 while ((PValue = JudyLFirstThenNext(labels->JudyL, &Index, &first_then_next))) {
940 - if (!((*((RRDLABEL_SRC *)PValue)) & (RRDLABEL_FLAG_OLD | RRDLABEL_FLAG_NEW | RRDLABEL_FLAG_PERMANENT))) {
940 + if (!((*((RRDLABEL_SRC *)PValue)) & (RRDLABEL_FLAG_INTERNAL))) {
941
942 size_t mem_before_judyl = JudyLMemUsed(labels->JudyL);
943 (void)JudyLDel(&labels->JudyL, Index, PJE0);
database/rrdlabels.h
+4 -4
@@ -13,12 +13,12 @@ typedef enum __attribute__ ((__packed__)) rrdlabel_source {
13
14 // more sources can be added here
15
16 - RRDLABEL_FLAG_PERMANENT = (1 << 29), // set when this label should never be removed (can be overwritten though)
17 - RRDLABEL_FLAG_OLD = (1 << 30), // marks for rrdlabels internal use - they are not exposed outside rrdlabels
18 - RRDLABEL_FLAG_NEW = (1 << 31) // marks for rrdlabels internal use - they are not exposed outside rrdlabels
16 + RRDLABEL_FLAG_DONT_DELETE = (1 << 29), // set when this label should never be removed (can be overwritten though)
17 + RRDLABEL_FLAG_OLD = (1 << 30), // marks for rrdlabels internal use - they are not exposed outside rrdlabels
18 + RRDLABEL_FLAG_NEW = (1 << 31) // marks for rrdlabels internal use - they are not exposed outside rrdlabels
19 } RRDLABEL_SRC;
20
21 -#define RRDLABEL_FLAG_INTERNAL (RRDLABEL_FLAG_OLD | RRDLABEL_FLAG_NEW | RRDLABEL_FLAG_PERMANENT)
21 +#define RRDLABEL_FLAG_INTERNAL (RRDLABEL_FLAG_OLD | RRDLABEL_FLAG_NEW | RRDLABEL_FLAG_DONT_DELETE)
22
23 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);
24
database/rrdset.c
+2 -2
@@ -156,8 +156,8 @@ static inline RRDSET *rrdset_index_find_name(RRDHOST *host, const char *name) {
156 static inline void rrdset_update_permanent_labels(RRDSET *st) {
157 if(!st->rrdlabels) return;
158
159 - rrdlabels_add(st->rrdlabels, "_collect_plugin", rrdset_plugin_name(st), RRDLABEL_SRC_AUTO| RRDLABEL_FLAG_PERMANENT);
160 - rrdlabels_add(st->rrdlabels, "_collect_module", rrdset_module_name(st), RRDLABEL_SRC_AUTO| RRDLABEL_FLAG_PERMANENT);
159 + rrdlabels_add(st->rrdlabels, "_collect_plugin", rrdset_plugin_name(st), RRDLABEL_SRC_AUTO | RRDLABEL_FLAG_DONT_DELETE);
160 + rrdlabels_add(st->rrdlabels, "_collect_module", rrdset_module_name(st), RRDLABEL_SRC_AUTO | RRDLABEL_FLAG_DONT_DELETE);
161 }
162
163 static STRING *rrdset_fix_name(RRDHOST *host, const char *chart_full_id, const char *type, const char *current_name, const char *name) {
streaming/rrdpush.c
+1 -1
@@ -208,7 +208,7 @@ int configured_as_parent() {
208 // chart labels
209 static int send_clabels_callback(const char *name, const char *value, RRDLABEL_SRC ls, void *data) {
210 BUFFER *wb = (BUFFER *)data;
211 - buffer_sprintf(wb, "CLABEL \"%s\" \"%s\" %d\n", name, value, ls);
211 + buffer_sprintf(wb, "CLABEL \"%s\" \"%s\" %d\n", name, value, ls & ~(RRDLABEL_FLAG_INTERNAL));
212 return 1;
213 }
214
streaming/sender.c
+9 -7
@@ -90,13 +90,15 @@ void sender_commit(struct sender_state *s, BUFFER *wb, STREAM_TRAFFIC_TYPE type)
90
91 sender_lock(s);
92
93 -// FILE *fp = fopen("/tmp/stream.txt", "a");
94 -// fprintf(fp,
95 -// "\n--- SEND BEGIN: %s ----\n"
96 -// "%s"
97 -// "--- SEND END ----------------------------------------\n"
98 -// , rrdhost_hostname(s->host), src);
99 -// fclose(fp);
93 +// if(s->host == localhost && type == STREAM_TRAFFIC_TYPE_METADATA) {
94 +// FILE *fp = fopen("/tmp/stream.txt", "a");
95 +// fprintf(fp, "\n--- SEND MESSAGE START: %s ----\n"
96 +// "%s"
97 +// "--- SEND MESSAGE END ----------------------------------------\n"
98 +// , rrdhost_hostname(s->host), src
99 +// );
100 +// fclose(fp);
101 +// }
102
103 if(unlikely(s->buffer->max_size < (src_len + 1) * SENDER_BUFFER_ADAPT_TO_TIMES_MAX_SIZE)) {
104 netdata_log_info("STREAM %s [send to %s]: max buffer size of %zu is too small for a data message of size %zu. Increasing the max buffer size to %d times the max data message size.",