From 6a0edda12c3a7938a8b17a3b462cb1fc2e309237 Mon Sep 17 00:00:00 2001 From: Attila Szakacs Date: Mon, 24 Jun 2024 13:21:55 +0200 Subject: [PATCH] metrics: add metrics.{c,h} for global functions Signed-off-by: Attila Szakacs --- lib/apphook.c | 6 +++--- lib/metrics/CMakeLists.txt | 2 ++ lib/metrics/Makefile.am | 2 ++ lib/metrics/metrics.c | 38 ++++++++++++++++++++++++++++++++++++++ lib/metrics/metrics.h | 31 +++++++++++++++++++++++++++++++ tests/copyright/policy | 1 + 6 files changed, 77 insertions(+), 3 deletions(-) create mode 100644 lib/metrics/metrics.c create mode 100644 lib/metrics/metrics.h diff --git a/lib/apphook.c b/lib/apphook.c index 23f89613d6..20aa26bd55 100644 --- a/lib/apphook.c +++ b/lib/apphook.c @@ -28,7 +28,7 @@ #include "dnscache.h" #include "alarms.h" #include "stats/stats-registry.h" -#include "metrics/metrics-tls-cache.h" +#include "metrics/metrics.h" #include "healthcheck/healthcheck-stats.h" #include "logmsg/logmsg.h" #include "logsource.h" @@ -228,7 +228,7 @@ app_startup(void) alarm_init(); main_loop_thread_resource_init(); stats_init(); - metrics_tls_cache_global_init(); + metrics_global_init(); healthcheck_stats_global_init(); tzset(); log_msg_global_init(); @@ -283,7 +283,7 @@ app_shutdown(void) log_msg_global_deinit(); afinter_global_deinit(); - metrics_tls_cache_global_deinit(); + metrics_global_deinit(); stats_destroy(); child_manager_deinit(); g_list_foreach(application_hooks, (GFunc) g_free, NULL); diff --git a/lib/metrics/CMakeLists.txt b/lib/metrics/CMakeLists.txt index e09752bd2b..c36192f4e8 100644 --- a/lib/metrics/CMakeLists.txt +++ b/lib/metrics/CMakeLists.txt @@ -1,10 +1,12 @@ set(METRICS_HEADERS + metrics/metrics.h metrics/metrics-tls-cache.h metrics/metrics-template.h metrics/label-template.h PARENT_SCOPE) set(METRICS_SOURCES + metrics/metrics.c metrics/metrics-tls-cache.c metrics/metrics-template.c metrics/label-template.c diff --git a/lib/metrics/Makefile.am b/lib/metrics/Makefile.am index f3f334be9b..7fbe9d18d7 100644 --- a/lib/metrics/Makefile.am +++ b/lib/metrics/Makefile.am @@ -3,11 +3,13 @@ metricsincludedir = ${pkgincludedir}/metrics EXTRA_DIST += lib/metrics/CMakeLists.txt metricsinclude_HEADERS = \ + lib/metrics/metrics.h \ lib/metrics/metrics-tls-cache.h \ lib/metrics/metrics-template.h \ lib/metrics/label-template.h metrics_sources = \ + lib/metrics/metrics.c \ lib/metrics/metrics-tls-cache.c \ lib/metrics/metrics-template.c \ lib/metrics/label-template.c diff --git a/lib/metrics/metrics.c b/lib/metrics/metrics.c new file mode 100644 index 0000000000..8d2e21f357 --- /dev/null +++ b/lib/metrics/metrics.c @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 Axoflow + * Copyright (c) 2024 Attila Szakacs + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ + +#include "metrics.h" +#include "metrics-tls-cache.h" + +void +metrics_global_init(void) +{ + metrics_tls_cache_global_init(); +} + +void +metrics_global_deinit(void) +{ + metrics_tls_cache_global_deinit(); +} diff --git a/lib/metrics/metrics.h b/lib/metrics/metrics.h new file mode 100644 index 0000000000..06d80586a9 --- /dev/null +++ b/lib/metrics/metrics.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Axoflow + * Copyright (c) 2024 Attila Szakacs + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ + +#ifndef METRICS_H_INCLUDED +#define METRICS_H_INCLUDED + +void metrics_global_init(void); +void metrics_global_deinit(void); + +#endif diff --git a/tests/copyright/policy b/tests/copyright/policy index ca24641cf9..6e102fd41e 100644 --- a/tests/copyright/policy +++ b/tests/copyright/policy @@ -92,6 +92,7 @@ lib/metrics-pipe\.[ch] lib/metrics/label-template\.(c|h)$ lib/metrics/metrics-template\.(c|h)$ lib/metrics/metrics-tls-cache\.(c|h)$ +lib/metrics/metrics.(c|h)$ lib/rewrite/rewrite-set-facility\.h lib/rewrite/rewrite-set-matches\.[ch] lib/rewrite/rewrite-unset-matches\.[ch]