]> git.ipfire.org Git - thirdparty/collectd.git/commitdiff
write_open_telemetry plugin: Set up the build system properly.
authorFlorian Forster <octo@collectd.org>
Mon, 4 Dec 2023 16:10:37 +0000 (17:10 +0100)
committerFlorian Forster <octo@collectd.org>
Wed, 3 Jan 2024 16:16:28 +0000 (17:16 +0100)
My initial thought was to treat the file generated from protocol buffers
like the code generated by flex/yacc. However, protocol buffer code needs
to be linked with the protobuf library, so packaging the generated code
with the distribution may cause compatibility issues in the future.

Makefile.am
build.sh
configure.ac

index 13455fcd2d6c04014f5d09d87483542c70695d83..442a5df2aee46017723887ee4f134ea63f031ed7 100644 (file)
@@ -132,7 +132,6 @@ noinst_LTLIBRARIES = \
        libcommon.la \
        libformat_graphite.la \
        libformat_influxdb.la \
-       libformat_open_telemetry.la \
        libheap.la \
        libignorelist.la \
        liblatency.la \
@@ -473,23 +472,23 @@ libformat_influxdb_la_SOURCES = \
        src/utils/format_influxdb/format_influxdb.c \
        src/utils/format_influxdb/format_influxdb.h
 
-BUILT_SOURCES += \
-       src/opentelemetry/proto/common/v1/common.pb.cc \
-       src/opentelemetry/proto/common/v1/common.pb.h \
-       src/opentelemetry/proto/metrics/v1/metrics.pb.cc \
-       src/opentelemetry/proto/metrics/v1/metrics.pb.h \
-       src/opentelemetry/proto/resource/v1/resource.pb.cc \
-       src/opentelemetry/proto/resource/v1/resource.pb.h
+if BUILD_PLUGIN_WRITE_OPEN_TELEMETRY
+noinst_LTLIBRARIES += libformat_open_telemetry.la
 libformat_open_telemetry_la_SOURCES = \
        src/utils/format_open_telemetry/format_open_telemetry.cc \
        src/utils/format_open_telemetry/format_open_telemetry.h \
-       src/opentelemetry/proto/common/v1/common.pb.cc \
-       src/opentelemetry/proto/common/v1/common.pb.h \
-       src/opentelemetry/proto/metrics/v1/metrics.pb.cc \
-       src/opentelemetry/proto/metrics/v1/metrics.pb.h \
-       src/opentelemetry/proto/resource/v1/resource.pb.cc \
-       src/opentelemetry/proto/resource/v1/resource.pb.h
-libformat_open_telemetry_la_CPPFLAGS = $(AM_CPPFLAGS)
+       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
+libformat_open_telemetry_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBPROTOBUF_CPPFLAGS)
+libformat_open_telemetry_la_LDFLAGS = $(AM_LDFLAGS) $(BUILD_WITH_LIBPROTOBUF_LDFLAGS)
+libformat_open_telemetry_la_LIBADD = $(BUILD_WITH_LIBPROTOBUF_LIBS)
+endif
 
 if BUILD_WITH_LIBYAJL
 noinst_LTLIBRARIES += libformat_json.la
@@ -2337,11 +2336,15 @@ write_mongodb_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBMONGOC_LDFLAGS)
 write_mongodb_la_LIBADD = $(BUILD_WITH_LIBMONGOC_LIBS)
 endif
 
-# TODO(octo): add configure guards
+if BUILD_PLUGIN_WRITE_OPEN_TELEMETRY
 pkglib_LTLIBRARIES += write_open_telemetry.la
-write_open_telemetry_la_SOURCES = src/write_open_telemetry.cc
-write_open_telemetry_la_LDFLAGS = $(PLUGIN_LDFLAGS)
-write_open_telemetry_la_LIBADD = libformat_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
@@ -2481,6 +2484,31 @@ collectd.pb.cc: $(srcdir)/proto/collectd.proto $(srcdir)/proto/types.proto
 types.pb.cc: $(srcdir)/proto/types.proto
        $(V_PROTOC)$(PROTOC) -I$(srcdir)/proto --cpp_out=$(builddir) \
        $(srcdir)/proto/types.proto
+
+BUILT_SOURCES += \
+       opentelemetry/proto/collector/metrics/v1/metrics_service.grpc.pb.cc \
+       opentelemetry/proto/collector/metrics/v1/metrics_service.pb.cc \
+       opentelemetry/proto/common/v1/common.pb.cc \
+       opentelemetry/proto/metrics/v1/metrics.pb.cc \
+       opentelemetry/proto/resource/v1/resource.pb.cc
+
+
+opentelemetry/proto/collector/metrics/v1/metrics_service.grpc.pb.cc: $(srcdir)/opentelemetry-proto/opentelemetry/proto/collector/metrics/v1/metrics_service.proto
+       $(V_PROTOC)$(PROTOC) -I$(srcdir)/opentelemetry-proto --grpc_out=$(builddir) \
+               --plugin="protoc-gen-grpc=$(GRPC_CPP_PLUGIN)" $<
+
+opentelemetry/proto/collector/metrics/v1/metrics_service.pb.cc: $(srcdir)/opentelemetry-proto/opentelemetry/proto/collector/metrics/v1/metrics_service.proto
+       $(V_PROTOC)$(PROTOC) -I$(srcdir)/opentelemetry-proto --cpp_out=$(builddir) $<
+
+opentelemetry/proto/common/v1/common.pb.cc: $(srcdir)/opentelemetry-proto/opentelemetry/proto/metrics/v1/metrics.proto
+       $(V_PROTOC)$(PROTOC) -I$(srcdir)/opentelemetry-proto --cpp_out=$(builddir) $<
+
+opentelemetry/proto/metrics/v1/metrics.pb.cc: $(srcdir)/opentelemetry-proto/opentelemetry/proto/resource/v1/resource.proto
+       $(V_PROTOC)$(PROTOC) -I$(srcdir)/opentelemetry-proto --cpp_out=$(builddir) $<
+
+opentelemetry/proto/resource/v1/resource.pb.cc: $(srcdir)/opentelemetry-proto/opentelemetry/proto/common/v1/common.proto
+       $(V_PROTOC)$(PROTOC) -I$(srcdir)/opentelemetry-proto --cpp_out=$(builddir) $<
+
 endif
 endif
 
index 4c36775c0a214bbc5627b6190b82bfe7eb797e6f..c0ccce3a5919dbdde3888c9bd8244bcc41040693 100755 (executable)
--- a/build.sh
+++ b/build.sh
@@ -55,11 +55,6 @@ build()
     && $libtoolize --copy --force \
     && automake --add-missing --copy \
     && autoconf
-
-    for f in common/v1/common.proto metrics/v1/metrics.proto resource/v1/resource.proto collector/metrics/v1/metrics_service.proto; do
-      protoc -Iopentelemetry-proto --cpp_out src/ "opentelemetry-proto/opentelemetry/proto/${f}"
-    done
-    protoc -Iopentelemetry-proto --grpc_out src/ --plugin="protoc-gen-grpc=$(which grpc_cpp_plugin)" "opentelemetry-proto/opentelemetry/proto/collector/metrics/v1/metrics_service.proto"
 }
 
 build_cygwin()
index 01b5c2316dae03f3214edcd3bf56f8e174ce5801..a6a4ab6a2412392ee1dd1ed2f30c046c023761da 100644 (file)
@@ -6860,6 +6860,7 @@ plugin_write_influxdb_udp="yes"
 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="$with_libhiredis"
 plugin_write_riemann="$with_libriemann_client"
@@ -7116,15 +7117,19 @@ fi
 
 if test "x$GRPC_CPP_PLUGIN" = "x"; then
   plugin_grpc="no (grpc_cpp_plugin not found)"
+  plugin_write_open_telemetry="no (grpc_cpp_plugin not found)"
 fi
 if test "x$have_protoc3" != "xyes"; then
   plugin_grpc="no (protoc3 not found)"
+  plugin_write_open_telemetry="no (protoc3 not found)"
 fi
 if test "x$with_libprotobuf" != "xyes"; then
   plugin_grpc="no (libprotobuf not found)"
+  plugin_write_open_telemetry="no (libprotobuf not found)"
 fi
 if test "x$with_libgrpcpp" != "xyes"; then
   plugin_grpc="no (libgrpc++ not found)"
+  plugin_write_open_telemetry="no (libgrpc++ not found)"
 fi
 
 if test "x$have_getifaddrs" = "xyes"; then
@@ -7457,6 +7462,7 @@ AC_PLUGIN([write_influxdb_udp],  [$plugin_write_influxdb_udp],[Influxdb udp outp
 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])
@@ -7903,6 +7909,7 @@ AC_MSG_RESULT([    write_influxdb_udp. . $enable_write_influxdb_udp])
 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])