Skip to content

Commit cc58164

Browse files
committed
Fixes IWYU issue
1 parent 0d3ab14 commit cc58164

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_client.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ class Arena;
3535
}
3636
} // namespace google
3737

38+
namespace grpc
39+
{
40+
class ChannelArguments;
41+
} // namespace grpc
42+
3843
namespace opentelemetry
3944
{
4045
namespace proto
@@ -256,8 +261,10 @@ class OtlpGrpcClient
256261
private:
257262
friend class OtlpGrpcClientTestPeer;
258263

259-
// Build gRPC channel arguments from exporter options. Shared by MakeChannel() and unit tests.
260-
static grpc::ChannelArguments BuildChannelArguments(const OtlpGrpcClientOptions &options);
264+
// Populate gRPC channel arguments from exporter options. Shared by MakeChannel() and unit
265+
// tests.
266+
static void PopulateChannelArguments(const OtlpGrpcClientOptions &options,
267+
grpc::ChannelArguments &grpc_arguments);
261268

262269
// Stores if this gRPC client had its Shutdown() method called
263270
std::atomic<bool> is_shutdown_;

exporters/otlp/src/otlp_grpc_client.cc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,8 @@ std::shared_ptr<grpc::Channel> OtlpGrpcClient::MakeChannel(const OtlpGrpcClientO
355355
return nullptr;
356356
}
357357

358-
grpc::ChannelArguments grpc_arguments = BuildChannelArguments(options);
358+
grpc::ChannelArguments grpc_arguments;
359+
PopulateChannelArguments(options, grpc_arguments);
359360

360361
if (options.use_ssl_credentials)
361362
{
@@ -394,9 +395,11 @@ std::shared_ptr<grpc::Channel> OtlpGrpcClient::MakeChannel(const OtlpGrpcClientO
394395
return channel;
395396
}
396397

397-
grpc::ChannelArguments OtlpGrpcClient::BuildChannelArguments(const OtlpGrpcClientOptions &options)
398+
void OtlpGrpcClient::PopulateChannelArguments(const OtlpGrpcClientOptions &options,
399+
grpc::ChannelArguments &grpc_arguments)
398400
{
399-
grpc::ChannelArguments grpc_arguments;
401+
grpc_arguments = grpc::ChannelArguments{};
402+
400403
if (options.channel_arguments != nullptr)
401404
{
402405
grpc_arguments = *options.channel_arguments;
@@ -455,8 +458,6 @@ grpc::ChannelArguments OtlpGrpcClient::BuildChannelArguments(const OtlpGrpcClien
455458
grpc_arguments.SetServiceConfigJSON(service_config);
456459
}
457460
#endif // ENABLE_OTLP_RETRY_PREVIEW
458-
459-
return grpc_arguments;
460461
}
461462

462463
std::unique_ptr<grpc::ClientContext> OtlpGrpcClient::MakeClientContext(

exporters/otlp/test/otlp_grpc_target_test.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
// Copyright The OpenTelemetry Authors
22
// SPDX-License-Identifier: Apache-2.0
33

4+
#include <grpc/grpc.h>
45
#include <grpcpp/support/channel_arguments.h>
56
#include <gtest/gtest.h>
67

78
#include <cstring>
9+
#include <string>
810

911
#include "opentelemetry/exporters/otlp/otlp_grpc_client.h"
1012
#include "opentelemetry/exporters/otlp/otlp_grpc_client_options.h"
@@ -40,7 +42,9 @@ class OtlpGrpcClientTestPeer : public ::testing::Test
4042
public:
4143
static grpc::ChannelArguments BuildChannelArguments(const OtlpGrpcClientOptions &options)
4244
{
43-
return OtlpGrpcClient::BuildChannelArguments(options);
45+
grpc::ChannelArguments grpc_arguments;
46+
OtlpGrpcClient::PopulateChannelArguments(options, grpc_arguments);
47+
return grpc_arguments;
4448
}
4549
};
4650

0 commit comments

Comments
 (0)