From 3f17d3300510bd2791b655818bfea3b73fc9e2e1 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Tue, 20 Feb 2024 15:17:53 +0100 Subject: [PATCH] open_telemetry plugin: Move prototypes to a header file. --- Makefile.am | 2 +- src/open_telemetry.cc | 3 +-- src/open_telemetry.h | 42 ++++++++++++++++++++++++++++++++++ src/open_telemetry_exporter.cc | 3 ++- src/open_telemetry_receiver.cc | 5 ++-- 5 files changed, 48 insertions(+), 7 deletions(-) create mode 100644 src/open_telemetry.h diff --git a/Makefile.am b/Makefile.am index dbc9b1c0a7..3a13c3042d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1747,7 +1747,7 @@ endif if BUILD_PLUGIN_OPEN_TELEMETRY pkglib_LTLIBRARIES += open_telemetry.la open_telemetry_la_SOURCES = \ - src/open_telemetry.cc \ + src/open_telemetry.cc src/open_telemetry.h \ src/open_telemetry_exporter.cc \ src/open_telemetry_receiver.cc \ opentelemetry/proto/collector/metrics/v1/metrics_service.grpc.pb.cc \ diff --git a/src/open_telemetry.cc b/src/open_telemetry.cc index f87ea92030..10aa2510f1 100644 --- a/src/open_telemetry.cc +++ b/src/open_telemetry.cc @@ -31,8 +31,7 @@ extern "C" { #include "daemon/plugin.h" } -int exporter_config(oconfig_item_t *ci); -int receiver_config(oconfig_item_t *ci); +#include "open_telemetry.h" static int ot_config(oconfig_item_t *ci) { for (int i = 0; i < ci->children_num; i++) { diff --git a/src/open_telemetry.h b/src/open_telemetry.h new file mode 100644 index 0000000000..2b332d9d7b --- /dev/null +++ b/src/open_telemetry.h @@ -0,0 +1,42 @@ +/** + * collectd - src/open_telemetry.h + * Copyright (C) 2024 Florian octo Forster + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: + * Florian octo Forster + **/ + +#ifndef OPEN_TELEMETRY_H +#define OPEN_TELEMETRY_H 1 + +extern "C" { +#include "daemon/collectd.h" +#include "daemon/configfile.h" +} + +#include + +int exporter_config(oconfig_item_t *ci); +int receiver_config(oconfig_item_t *ci); + +int config_get_file(oconfig_item_t const *ci, grpc::string *out); + +#endif diff --git a/src/open_telemetry_exporter.cc b/src/open_telemetry_exporter.cc index 795bbd7ca5..443a65f1fb 100644 --- a/src/open_telemetry_exporter.cc +++ b/src/open_telemetry_exporter.cc @@ -38,12 +38,13 @@ extern "C" { } #include - #include #include "opentelemetry/proto/collector/metrics/v1/metrics_service.grpc.pb.h" #include "utils/format_open_telemetry/format_open_telemetry.h" +#include "open_telemetry.h" + #ifndef OT_DEFAULT_PORT #define OT_DEFAULT_PORT "4317" #endif diff --git a/src/open_telemetry_receiver.cc b/src/open_telemetry_receiver.cc index 921f26e0ac..c0dd114fdf 100644 --- a/src/open_telemetry_receiver.cc +++ b/src/open_telemetry_receiver.cc @@ -47,6 +47,8 @@ extern "C" { #include "opentelemetry/proto/metrics/v1/metrics.pb.h" #include "opentelemetry/proto/resource/v1/resource.pb.h" +#include "open_telemetry.h" + #ifndef OT_DEFAULT_PORT #define OT_DEFAULT_PORT "4317" #endif @@ -427,9 +429,6 @@ static void receiver_install_callbacks(void) { done = true; } -// config_get_file is implemented in src/open_telemetry_exporter.cc -int config_get_file(oconfig_item_t const *ci, grpc::string *out); - /* * collectd plugin interface */