Skip to content

Commit

Permalink
Merge pull request #4910 from MrAnno/fix-otel-config-revert
Browse files Browse the repository at this point in the history
Fix otel config revert
  • Loading branch information
MrAnno authored Apr 19, 2024
2 parents 41209bf + c1edd26 commit 45144fe
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
20 changes: 14 additions & 6 deletions modules/grpc/otel/otel-source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<TraceService::AsyncService>();
logs_service = std::make_unique<LogsService::AsyncService>();
metrics_service = std::make_unique<MetricsService::AsyncService>();

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());
Expand All @@ -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);
}

Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions modules/grpc/otel/otel-source.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<TraceService::AsyncService> trace_service;
std::unique_ptr<LogsService::AsyncService> logs_service;
std::unique_ptr<MetricsService::AsyncService> metrics_service;

private:
friend SourceWorker;
Expand Down
1 change: 1 addition & 0 deletions news/bugfix-4910.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`opentelemetry()`: fix crash when an invalid configuration needs to be reverted

0 comments on commit 45144fe

Please sign in to comment.