summaryrefslogtreecommitdiffstats
path: root/libnetdata
diff options
context:
space:
mode:
authorCosta Tsaousis <costa@netdata.cloud>2022-05-25 01:24:36 +0300
committerGitHub <noreply@github.com>2022-05-25 01:24:36 +0300
commit38b38b80923f297246f83bbeac9d6c9e2772daff (patch)
tree81dbf853658eee097e5cc542a6568b26edd8b611 /libnetdata
parenta5c712209281d969c6aba1d456829d24672a566a (diff)
add dictionary support to statsd (#12980)
* add dictionary support to statsd * faster statsd sets and dictionaries; disabled events dimensions by default * properly detect tags, even without a sampling rate * statsd assumes a pipe between fields * missing param * allow names without values and support more unknown fields * more parser fixes * support multiple tags; remove the sum from the dimensions of histograms and timers, but keep it for synthetic charts * Parse statsd tags and support changing units of private charts * remove debug code * added support for naming dimensions too * updated docs * added support for family tags * updated docs
Diffstat (limited to 'libnetdata')
-rw-r--r--libnetdata/dictionary/dictionary.c5
-rw-r--r--libnetdata/dictionary/dictionary.h6
-rw-r--r--libnetdata/libnetdata.c2
3 files changed, 8 insertions, 5 deletions
diff --git a/libnetdata/dictionary/dictionary.c b/libnetdata/dictionary/dictionary.c
index b3dc3f371c..320d348163 100644
--- a/libnetdata/dictionary/dictionary.c
+++ b/libnetdata/dictionary/dictionary.c
@@ -170,7 +170,7 @@ void dictionary_destroy(DICTIONARY *dict) {
// ----------------------------------------------------------------------------
-void *dictionary_set(DICTIONARY *dict, const char *name, void *value, size_t value_len) {
+void *dictionary_set_with_name_ptr(DICTIONARY *dict, const char *name, void *value, size_t value_len, char **name_ptr) {
debug(D_DICTIONARY, "SET dictionary entry with name '%s'.", name);
uint32_t hash = simple_hash(name);
@@ -185,7 +185,7 @@ void *dictionary_set(DICTIONARY *dict, const char *name, void *value, size_t val
if(unlikely(!nv))
fatal("Cannot create name_value.");
}
- else {
+ else if(!(dict->flags & DICTIONARY_FLAG_DONT_OVERWRITE_VALUE)) {
debug(D_DICTIONARY, "Dictionary entry with name '%s' found. Changing its value.", name);
if(dict->flags & DICTIONARY_FLAG_VALUE_LINK_DONT_CLONE) {
@@ -210,6 +210,7 @@ void *dictionary_set(DICTIONARY *dict, const char *name, void *value, size_t val
dictionary_unlock(dict);
+ if(name_ptr) *name_ptr = nv->name;
return nv->value;
}
diff --git a/libnetdata/dictionary/dictionary.h b/libnetdata/dictionary/dictionary.h
index 76213887e6..b9f86a98c1 100644
--- a/libnetdata/dictionary/dictionary.h
+++ b/libnetdata/dictionary/dictionary.h
@@ -31,15 +31,17 @@ typedef struct dictionary {
netdata_rwlock_t *rwlock;
} DICTIONARY;
-#define DICTIONARY_FLAG_DEFAULT 0x00000000
+#define DICTIONARY_FLAG_NONE 0x00000000
#define DICTIONARY_FLAG_SINGLE_THREADED 0x00000001
#define DICTIONARY_FLAG_VALUE_LINK_DONT_CLONE 0x00000002
#define DICTIONARY_FLAG_NAME_LINK_DONT_CLONE 0x00000004
#define DICTIONARY_FLAG_WITH_STATISTICS 0x00000008
+#define DICTIONARY_FLAG_DONT_OVERWRITE_VALUE 0x00000010
extern DICTIONARY *dictionary_create(uint8_t flags);
extern void dictionary_destroy(DICTIONARY *dict);
-extern void *dictionary_set(DICTIONARY *dict, const char *name, void *value, size_t value_len) NEVERNULL;
+extern void *dictionary_set_with_name_ptr(DICTIONARY *dict, const char *name, void *value, size_t value_len, char **name_ptr) NEVERNULL;
+#define dictionary_set(dict, name, value, value_len) dictionary_set_with_name_ptr(dict, name, value, value_len, NULL)
extern void *dictionary_get(DICTIONARY *dict, const char *name);
extern int dictionary_del(DICTIONARY *dict, const char *name);
diff --git a/libnetdata/libnetdata.c b/libnetdata/libnetdata.c
index 5929d976f9..2997ce19e4 100644
--- a/libnetdata/libnetdata.c
+++ b/libnetdata/libnetdata.c
@@ -577,7 +577,7 @@ unsigned char netdata_map_chart_ids[256] = {
[89] = 'y', // Y
[90] = 'z', // Z
[91] = '_', // [
- [92] = '/', // backslash
+ [92] = '_', // backslash
[93] = '_', // ]
[94] = '_', // ^
[95] = '_', // _