From 35e839d3eab2820ac59063889fbe8c0ec4ff8c7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20V=C3=A1rady?= Date: Fri, 19 Apr 2024 15:29:05 +0200 Subject: [PATCH 1/2] otel: fix config revert crash MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Each service belongs to a single server. This patch fixes the following assert by recreating the service instances: "Can only register an asynchronous service against one server." Signed-off-by: László Várady --- modules/grpc/otel/otel-source.cpp | 20 ++++++++++++++------ modules/grpc/otel/otel-source.hpp | 6 +++--- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/modules/grpc/otel/otel-source.cpp b/modules/grpc/otel/otel-source.cpp index 5ffc3ca378..6dabc003c5 100644 --- a/modules/grpc/otel/otel-source.cpp +++ b/modules/grpc/otel/otel-source.cpp @@ -96,9 +96,13 @@ syslogng::grpc::otel::SourceDriver::init() for (auto nv : string_extra_channel_args) builder.AddChannelArgument(nv.first, nv.second); - builder.RegisterService(&trace_service); - builder.RegisterService(&logs_service); - builder.RegisterService(&metrics_service); + trace_service = std::make_unique(); + logs_service = std::make_unique(); + metrics_service = std::make_unique(); + + builder.RegisterService(trace_service.get()); + builder.RegisterService(logs_service.get()); + builder.RegisterService(metrics_service.get()); for (int i = 0; i < super->super.num_workers; i++) cqs.push_back(builder.AddCompletionQueue()); @@ -123,6 +127,10 @@ syslogng::grpc::otel::SourceDriver::init() gboolean syslogng::grpc::otel::SourceDriver::deinit() { + trace_service = nullptr; + logs_service = nullptr; + metrics_service = nullptr; + return log_threaded_source_driver_deinit_method(&super->super.super.super.super); } @@ -161,9 +169,9 @@ syslogng::grpc::otel::SourceWorker::run() */ for (int i = 0; i < driver.concurrent_requests - 1; i++) { - new TraceServiceCall(*this, &driver.trace_service, cq.get()); - new LogsServiceCall(*this, &driver.logs_service, cq.get()); - new MetricsServiceCall(*this, &driver.metrics_service, cq.get()); + new TraceServiceCall(*this, driver.trace_service.get(), cq.get()); + new LogsServiceCall(*this, driver.logs_service.get(), cq.get()); + new MetricsServiceCall(*this, driver.metrics_service.get(), cq.get()); } void *tag; diff --git a/modules/grpc/otel/otel-source.hpp b/modules/grpc/otel/otel-source.hpp index 0160f7ef6c..60331827b5 100644 --- a/modules/grpc/otel/otel-source.hpp +++ b/modules/grpc/otel/otel-source.hpp @@ -57,9 +57,9 @@ class SourceDriver void add_extra_channel_arg(std::string name, std::string value); GrpcServerCredentialsBuilderW *get_credentials_builder_wrapper(); - TraceService::AsyncService trace_service; - LogsService::AsyncService logs_service; - MetricsService::AsyncService metrics_service; + std::unique_ptr trace_service; + std::unique_ptr logs_service; + std::unique_ptr metrics_service; private: friend SourceWorker; From c1edd269799c61d098d1f894792597549c1353dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20V=C3=A1rady?= Date: Fri, 19 Apr 2024 15:33:33 +0200 Subject: [PATCH 2/2] news: add entry for #4910 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: László Várady --- news/bugfix-4910.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 news/bugfix-4910.md diff --git a/news/bugfix-4910.md b/news/bugfix-4910.md new file mode 100644 index 0000000000..7ec2452aca --- /dev/null +++ b/news/bugfix-4910.md @@ -0,0 +1 @@ +`opentelemetry()`: fix crash when an invalid configuration needs to be reverted