src/utils/format_influxdb/format_influxdb.c \
src/utils/format_influxdb/format_influxdb.h
-if BUILD_PLUGIN_WRITE_OPEN_TELEMETRY
+if BUILD_PLUGIN_OPEN_TELEMETRY
noinst_LTLIBRARIES += libformat_open_telemetry.la
libformat_open_telemetry_la_SOURCES = \
src/utils/format_open_telemetry/format_open_telemetry.cc \
openvpn_la_LDFLAGS = $(PLUGIN_LDFLAGS)
endif
-if BUILD_PLUGIN_OPEN_TELEMETRY_COLLECTOR
-pkglib_LTLIBRARIES += open_telemetry_collector.la
-open_telemetry_collector_la_SOURCES = src/open_telemetry_collector.cc \
- opentelemetry/proto/collector/metrics/v1/metrics_service.grpc.pb.cc \
- opentelemetry/proto/collector/metrics/v1/metrics_service.grpc.pb.h \
- opentelemetry/proto/collector/metrics/v1/metrics_service.pb.cc \
- opentelemetry/proto/collector/metrics/v1/metrics_service.pb.h \
- opentelemetry/proto/common/v1/common.pb.cc \
- opentelemetry/proto/common/v1/common.pb.h \
- opentelemetry/proto/metrics/v1/metrics.pb.cc \
- opentelemetry/proto/metrics/v1/metrics.pb.h \
- opentelemetry/proto/resource/v1/resource.pb.cc \
- opentelemetry/proto/resource/v1/resource.pb.h
-open_telemetry_collector_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBGRPCPP_CPPFLAGS) $(BUILD_WITH_LIBPROTOBUF_CPPFLAGS)
-open_telemetry_collector_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBGRPCPP_LDFLAGS) $(BUILD_WITH_LIBPROTOBUF_LDFLAGS)
-open_telemetry_collector_la_LIBADD = $(BUILD_WITH_LIBGRPCPP_LIBS) $(BUILD_WITH_LIBPROTOBUF_LIBS)
+if BUILD_PLUGIN_OPEN_TELEMETRY
+pkglib_LTLIBRARIES += open_telemetry.la
+open_telemetry_la_SOURCES = \
+ src/open_telemetry.cc \
+ src/open_telemetry_exporter.cc \
+ src/open_telemetry_receiver.cc \
+ opentelemetry/proto/collector/metrics/v1/metrics_service.grpc.pb.cc \
+ opentelemetry/proto/collector/metrics/v1/metrics_service.grpc.pb.h
+open_telemetry_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBGRPCPP_CPPFLAGS) $(BUILD_WITH_LIBPROTOBUF_CPPFLAGS)
+open_telemetry_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBGRPCPP_LDFLAGS) $(BUILD_WITH_LIBPROTOBUF_LDFLAGS)
+open_telemetry_la_LIBADD = $(BUILD_WITH_LIBGRPCPP_LIBS) $(BUILD_WITH_LIBPROTOBUF_LIBS) libformat_open_telemetry.la
endif
if BUILD_PLUGIN_ORACLE
write_mongodb_la_LIBADD = $(BUILD_WITH_LIBMONGOC_LIBS)
endif
-if BUILD_PLUGIN_WRITE_OPEN_TELEMETRY
-pkglib_LTLIBRARIES += write_open_telemetry.la
-write_open_telemetry_la_SOURCES = src/write_open_telemetry.cc \
- opentelemetry/proto/collector/metrics/v1/metrics_service.grpc.pb.cc \
- opentelemetry/proto/collector/metrics/v1/metrics_service.grpc.pb.h
-write_open_telemetry_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBGRPCPP_CPPFLAGS)
-write_open_telemetry_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBGRPCPP_LDFLAGS)
-write_open_telemetry_la_LIBADD = $(BUILD_WITH_LIBGRPCPP_LIBS) libformat_open_telemetry.la
-endif
-
if BUILD_PLUGIN_WRITE_PROMETHEUS
pkglib_LTLIBRARIES += write_prometheus.la
write_prometheus_la_SOURCES = src/write_prometheus.c
endif
endif
-if BUILD_PLUGIN_WRITE_OPEN_TELEMETRY
+if BUILD_PLUGIN_OPEN_TELEMETRY
BUILT_SOURCES += \
opentelemetry/proto/collector/metrics/v1/metrics_service.grpc.pb.cc \
opentelemetry/proto/collector/metrics/v1/metrics_service.grpc.pb.h \
plugin_olsrd="yes"
plugin_onewire="$with_libowcapi"
plugin_openldap="$with_libldap"
-plugin_open_telemetry_collector="yes"
+plugin_open_telemetry="yes"
plugin_openvpn="yes"
plugin_oracle="$with_oracle"
plugin_ovs_events="no"
plugin_write_kafka="$with_librdkafka"
plugin_write_log="no"
plugin_write_mongodb="$with_libmongoc"
-plugin_write_open_telemetry="yes"
plugin_write_prometheus="no"
plugin_write_redis="yes"
plugin_write_riemann="$with_libriemann_client"
if test "x$GRPC_CPP_PLUGIN" = "x"; then
plugin_grpc="no (grpc_cpp_plugin not found)"
- plugin_open_telemetry_collector="no (grpc_cpp_plugin not found)"
- plugin_write_open_telemetry="no (grpc_cpp_plugin not found)"
+ plugin_open_telemetry="no (grpc_cpp_plugin not found)"
fi
if test "x$have_protoc3" != "xyes"; then
plugin_grpc="no (protoc3 not found)"
- plugin_open_telemetry_collector="no (protoc3 not found)"
- plugin_write_open_telemetry="no (protoc3 not found)"
+ plugin_open_telemetry="no (protoc3 not found)"
fi
if test "x$with_libprotobuf" != "xyes"; then
plugin_grpc="no (libprotobuf not found)"
- plugin_open_telemetry_collector="no (libprotobuf not found)"
- plugin_write_open_telemetry="no (libprotobuf not found)"
+ plugin_open_telemetry="no (libprotobuf not found)"
fi
if test "x$with_libgrpcpp" != "xyes"; then
plugin_grpc="no (libgrpc++ not found)"
- plugin_open_telemetry_collector="no (libgrpc++ not found)"
- plugin_write_open_telemetry="no (libgrpc++ not found)"
+ plugin_open_telemetry="no (libgrpc++ not found)"
fi
if test "x$protoc3_optional" = "xno"; then
- plugin_write_open_telemetry="no (protoc does not support optional fields)"
+ plugin_open_telemetry="no (protoc does not support optional fields)"
fi
if test "x$have_getifaddrs" = "xyes"; then
AC_PLUGIN([onewire], [$plugin_onewire], [OneWire sensor statistics])
AC_PLUGIN([openldap], [$plugin_openldap], [OpenLDAP statistics])
AC_PLUGIN([openvpn], [$plugin_openvpn], [OpenVPN client statistics])
-AC_PLUGIN([open_telemetry_collector], [$plugin_open_telemetry_collector], [OpenTelemetry Collector])
+AC_PLUGIN([open_telemetry], [$plugin_open_telemetry], [OpenTelemetry exporter/receiver])
AC_PLUGIN([oracle], [$plugin_oracle], [Oracle plugin])
AC_PLUGIN([ovs_events], [$plugin_ovs_events], [OVS events plugin])
AC_PLUGIN([ovs_stats], [$plugin_ovs_stats], [OVS statistics plugin])
AC_PLUGIN([write_kafka], [$plugin_write_kafka], [Kafka output plugin])
AC_PLUGIN([write_log], [$plugin_write_log], [Log output plugin])
AC_PLUGIN([write_mongodb], [$plugin_write_mongodb], [MongoDB output plugin])
-AC_PLUGIN([write_open_telemetry],[$plugin_write_open_telemetry],[Write OpenTelemetry plugin])
AC_PLUGIN([write_prometheus], [$plugin_write_prometheus], [Prometheus write plugin])
AC_PLUGIN([write_redis], [$plugin_write_redis], [Redis output plugin])
AC_PLUGIN([write_riemann], [$plugin_write_riemann], [Riemann output plugin])
AC_MSG_RESULT([ olsrd . . . . . . . . $enable_olsrd])
AC_MSG_RESULT([ onewire . . . . . . . $enable_onewire])
AC_MSG_RESULT([ openldap . . . . . . $enable_openldap])
+AC_MSG_RESULT([ open_telemetry . . . $enable_open_telemetry])
AC_MSG_RESULT([ openvpn . . . . . . . $enable_openvpn])
AC_MSG_RESULT([ oracle . . . . . . . $enable_oracle])
AC_MSG_RESULT([ ovs_events . . . . . $enable_ovs_events])
AC_MSG_RESULT([ write_kafka . . . . . $enable_write_kafka])
AC_MSG_RESULT([ write_log . . . . . . $enable_write_log])
AC_MSG_RESULT([ write_mongodb . . . . $enable_write_mongodb])
-AC_MSG_RESULT([ write_open_telemetry $enable_write_open_telemetry])
AC_MSG_RESULT([ write_prometheus. . . $enable_write_prometheus])
AC_MSG_RESULT([ write_redis . . . . . $enable_write_redis])
AC_MSG_RESULT([ write_riemann . . . . $enable_write_riemann])
#@BUILD_PLUGIN_OLSRD_TRUE@LoadPlugin olsrd
#@BUILD_PLUGIN_ONEWIRE_TRUE@LoadPlugin onewire
#@BUILD_PLUGIN_OPENLDAP_TRUE@LoadPlugin openldap
+#@BUILD_PLUGIN_OPEN_TELEMETRY_TRUE@LoadPlugin open_telemetry
#@BUILD_PLUGIN_OPENVPN_TRUE@LoadPlugin openvpn
#@BUILD_PLUGIN_ORACLE_TRUE@LoadPlugin oracle
#@BUILD_PLUGIN_OVS_EVENTS_TRUE@LoadPlugin ovs_events
#@BUILD_PLUGIN_WRITE_KAFKA_TRUE@LoadPlugin write_kafka
#@BUILD_PLUGIN_WRITE_LOG_TRUE@LoadPlugin write_log
#@BUILD_PLUGIN_WRITE_MONGODB_TRUE@LoadPlugin write_mongodb
-#@BUILD_PLUGIN_WRITE_OPEN_TELEMETRY_TRUE@LoadPlugin write_open_telemetry
#@BUILD_PLUGIN_WRITE_PROMETHEUS_TRUE@LoadPlugin write_prometheus
#@BUILD_PLUGIN_WRITE_REDIS_TRUE@LoadPlugin write_redis
#@BUILD_PLUGIN_WRITE_RIEMANN_TRUE@LoadPlugin write_riemann
# CollectUserCount false
#</Plugin>
-#<Plugin open_telemetry_collector>
-# <Listen "0.0.0.0" "4317">
+#<Plugin open_telemetry>
+# <Receiver "0.0.0.0" "4317">
# EnableSSL false
# SSLCACertificateFile "/path/to/root.pem"
# SSLCertificateFile "/path/to/client.pem"
# SSLCertificateKeyFile "/path/to/client.key"
# VerifyPeer false
-# </Listen>
+# </Receiver>
+# <Exporter "example">
+# Host "localhost"
+# Port "4317"
+# </Exporter>
#</Plugin>
#<Plugin oracle>
# </Node>
#</Plugin>
-#<Plugin write_open_telemetry>
-# <Node "example">
-# Host "localhost"
-# Port "4317"
-# </Node>
-#</Plugin>
-
#<Plugin write_prometheus>
# Port "9103"
#</Plugin>
=head2 Plugin C<open_telemetry_collector>
-The I<open_telemetry_collector plugin> implements an OpenTelemetry Collector.
-Specifically, it implements a gRPC C<MetricsService>.
+The I<open_telemetry plugin> implements an OpenTelemetry exporter and receiver
+using OTLP. Specifically, it implements a gRPC C<MetricsService> client and
+server.
+
+B<Synopsis:>
+
+ <Plugin open_telemetry>
+ <Receiver "0.0.0.0" "4317">
+ EnableSSL false
+ SSLCACertificateFile "/path/to/root.pem"
+ SSLCertificateFile "/path/to/client.pem"
+ SSLCertificateKeyFile "/path/to/client.key"
+ VerifyPeer false
+ </Receiver>
+ <Exporter "example">
+ Host "localhost"
+ Port "4317"
+ </Exporter>
+ </Plugin>
=over 4
-=item B<Listen> I<Host> I<Port>
+=item B<Receiver> I<Host> I<Port>
-The B<Listen> statement sets the network address and port to which to bind.
-Multiple B<Listen> blocks can be specified to listen on multiple
-interfaces/ports. When no B<Listen> blocks are specified, it defaults to
-B<0.0.0.0:4317>.
+The B<Receiver> statement sets the network address and port to which to bind.
+Multiple B<Receiver> blocks can be specified to listen on multiple
+interfaces/ports. When no B<Receiver> blocks are specified, the plugin will not
+receive any metrics.
The argument I<Host> may be a hostname, an IPv4 address, or an IPv6 address.
-Optionally, B<Listen> blocks support the following options:
+Optionally, B<Receiver> blocks support the following options:
=over 4
=back
+=item B<Exporter> I<Name>
+
+The plugin can export metrics to multiple collectors by specifying multiple
+B<Exporter> blocks. Within the B<Exporter> blocks, the following options are
+available:
+
+=over 4
+
+=item B<Host> I<Address>
+
+Hostname or address to connect to. Defaults to C<localhost>.
+
+=item B<Port> I<Service>
+
+Service name or port number to connect to. Defaults to C<4317>.
+
+=back
+
=back
=head2 Plugin C<oracle>
=back
-=head2 Plugin C<write_open_telemetry>
-
-The I<write_open_telemetry plugin> will export metrics to an I<OpenTelemetry
-collector> using the gRPC based OTLP protocol.
-
-B<Synopsis:>
-
- <Plugin "write_open_telemetry">
- <Node "default">
- Host "localhost"
- Port "4317"
- </Node>
- </Plugin>
-
-The plugin can export metrics to multiple collectors by specifying multiple
-B<Node> blocks. Within the B<Node> blocks, the following options are available:
-
-=over 4
-
-=item B<Host> I<Address>
-
-Hostname or address to connect to. Defaults to C<localhost>.
-
-=item B<Port> I<Service>
-
-Service name or port number to connect to. Defaults to C<4317>.
-
-=back
-
=head2 Plugin C<write_prometheus>
The I<write_prometheus plugin> implements a tiny webserver that can be scraped
--- /dev/null
+/**
+ * collectd - src/open_telemetry.cc
+ * 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 <octo at collectd.org>
+ **/
+
+extern "C" {
+#include "collectd.h"
+
+#include "daemon/configfile.h"
+#include "daemon/plugin.h"
+}
+
+int exporter_config(oconfig_item_t *ci);
+int receiver_config(oconfig_item_t *ci);
+
+static int ot_config(oconfig_item_t *ci) {
+ for (int i = 0; i < ci->children_num; i++) {
+ oconfig_item_t *child = ci->children + i;
+
+ if (strcasecmp("Exporter", child->key) == 0) {
+ int err = exporter_config(child);
+ if (err) {
+ ERROR("open_telemetry plugin: Configuring exporter failed "
+ "with status %d",
+ err);
+ return err;
+ }
+ } else if (strcasecmp("Receiver", child->key) == 0) {
+ int err = receiver_config(child);
+ if (err) {
+ ERROR("open_telemetry plugin: Configuring receiver failed "
+ "with status %d",
+ err);
+ return err;
+ }
+ } else {
+ ERROR("open_telemetry plugin: invalid config option: \"%s\"", child->key);
+ return EINVAL;
+ }
+ }
+
+ return 0;
+}
+
+extern "C" {
+void module_register(void) {
+ plugin_register_complex_config("open_telemetry", ot_config);
+}
+}
/**
- * collectd - src/write_open_telemetry.cc
- * Copyright (C) 2023 Florian octo Forster
+ * collectd - src/open_telemetry_exporter.cc
+ * Copyright (C) 2023-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"),
extern "C" {
#include "collectd.h"
-#include "plugin.h"
+#include "daemon/plugin.h"
#include "utils/common/common.h"
#include "utils/resource_metrics/resource_metrics.h"
return 0;
}
-static int ot_config_node(oconfig_item_t *ci) {
+int exporter_config(oconfig_item_t *ci) {
ot_callback_t *cb = (ot_callback_t *)calloc(1, sizeof(*cb));
if (cb == NULL) {
ERROR("write_open_telemetry plugin: calloc failed.");
STRBUF_DESTROY(callback_name);
return 0;
}
-
-static int ot_config(oconfig_item_t *ci) {
- for (int i = 0; i < ci->children_num; i++) {
- oconfig_item_t *child = ci->children + i;
-
- if (strcasecmp("Node", child->key) == 0)
- ot_config_node(child);
- else {
- ERROR("write_open_telemetry plugin: Invalid configuration "
- "option: %s.",
- child->key);
- }
- }
-
- return 0;
-}
-
-void module_register(void) {
- plugin_register_complex_config("write_open_telemetry", ot_config);
-}
/**
- * collectd - src/grpc.cc
+ * collectd - src/open_telemetry_receiver.cc
* Copyright (C) 2015-2016 Sebastian Harl
* Copyright (C) 2016-2024 Florian octo Forster
*
static CollectorServer *server = nullptr;
+static int receiver_init(void) {
+ if (server) {
+ return 0;
+ }
+
+ server = new CollectorServer();
+ if (!server) {
+ ERROR("open_telemetry_collector: Failed to create server");
+ return -1;
+ }
+
+ server->Start();
+ return 0;
+} /* receiver_init() */
+
+static int receiver_shutdown(void) {
+ if (!server)
+ return 0;
+
+ server->Shutdown();
+
+ delete server;
+ server = nullptr;
+
+ return 0;
+} /* receiver_shutdown() */
+
+static void receiver_install_callbacks(void) {
+ static bool done;
+
+ if (done) {
+ return;
+ }
+
+ plugin_register_init("open_telemetry_collector", receiver_init);
+ plugin_register_shutdown("open_telemetry_collector", receiver_shutdown);
+
+ done = true;
+}
+
/*
* collectd plugin interface
*/
-extern "C" {
-static int otelcol_config_listen(oconfig_item_t *ci) {
+int receiver_config(oconfig_item_t *ci) {
if ((ci->values_num != 2) || (ci->values[0].type != OCONFIG_TYPE_STRING) ||
(ci->values[1].type != OCONFIG_TYPE_STRING)) {
ERROR("open_telemetry_collector: The `%s` config option needs exactly "
}
listeners.push_back(listener);
+ receiver_install_callbacks();
return 0;
-} /* otelcol_config_listen() */
-
-static int otelcol_config(oconfig_item_t *ci) {
- for (int i = 0; i < ci->children_num; i++) {
- oconfig_item_t *child = ci->children + i;
-
- if (!strcasecmp("Listen", child->key)) {
- if (otelcol_config_listen(child)) {
- return -1;
- }
- }
-
- else {
- WARNING("open_telemetry_collector: Option `%s` not allowed here.",
- child->key);
- }
- }
-
- return 0;
-} /* otelcol_config() */
-
-static int otelcol_init(void) {
- if (server) {
- return 0;
- }
-
- server = new CollectorServer();
- if (!server) {
- ERROR("open_telemetry_collector: Failed to create server");
- return -1;
- }
-
- server->Start();
- return 0;
-} /* otelcol_init() */
-
-static int otelcol_shutdown(void) {
- if (!server)
- return 0;
-
- server->Shutdown();
-
- delete server;
- server = nullptr;
-
- return 0;
-} /* otelcol_shutdown() */
-
-void module_register(void) {
- plugin_register_complex_config("open_telemetry_collector", otelcol_config);
- plugin_register_init("open_telemetry_collector", otelcol_init);
- plugin_register_shutdown("open_telemetry_collector", otelcol_shutdown);
-} /* module_register() */
-} /* extern "C" */
+} /* receiver_config() */