MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / prom_labels_param

Function prom_labels_param

modules/prometheus/prometheus.c:962–1007  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

960}
961
962static int prom_labels_param(modparam_t type, void* val)
963{
964 str module;
965 str regex;
966 struct prom_label *label;
967 init_str(&regex, val);
968
969 trim_leading(&regex);
970 module = regex;
971 while (regex.len > 0 && *regex.s != ':') {
972 regex.s++;
973 regex.len--;
974 }
975 module.len = regex.s - module.s;
976 if (module.len == 0) {
977 LM_ERR("no type regexined!\n");
978 return -1;
979 }
980 regex.s++;
981 regex.len--;
982 trim_leading(&regex);
983 if (regex.len <= 0) {
984 LM_ERR("no regex regexined!\n");
985 return -1;
986 }
987 label = pkg_malloc(sizeof(*label) + module.len);
988 if (!label) {
989 LM_ERR("oom for label!\n");
990 return -1;
991 }
992 memset(label, 0, sizeof *label);
993 label->module.s = label->_buf;
994 memcpy(label->module.s, module.s, module.len);
995 label->module.len = module.len;
996
997 label->subst = subst_parser(&regex);
998 if (!label->subst) {
999 pkg_free(label);
1000 LM_ERR("could not parse substitution [%.*s]\n",
1001 regex.len, regex.s);
1002 return -1;
1003 }
1004 list_add_tail(&label->list, &prom_labels);
1005
1006 return 0;
1007}
1008
1009static int w_prom_declare_stat(struct sip_msg *msg, str *name, str *type, str *help)
1010{

Callers

nothing calls this directly

Calls 4

init_strFunction · 0.85
trim_leadingFunction · 0.85
subst_parserFunction · 0.85
list_add_tailFunction · 0.85

Tested by

no test coverage detected