Skip to content

Commit 4367e62

Browse files
committed
Change unique_ptr and shared_ptr from nostd:: to std::. Change the include order
1 parent 94260b3 commit 4367e62

22 files changed

+87
-79
lines changed

CMakeLists.txt

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ if(WITH_PROMETHEUS)
369369
endif()
370370
endif()
371371

372-
if(WITH_ABSEIL OR WITH_OTLP_GRPC)
372+
if(WITH_ABSEIL)
373373
if(NOT TARGET absl::strings)
374374
find_package(absl CONFIG REQUIRED)
375375
endif()
@@ -379,14 +379,8 @@ if(WITH_OTLP_GRPC
379379
OR WITH_OTLP_HTTP
380380
OR WITH_OTLP_FILE)
381381
find_package(Protobuf)
382-
if(Protobuf_VERSION AND Protobuf_VERSION VERSION_GREATER_EQUAL "3.22.0")
383-
if(NOT WITH_ABSEIL AND NOT WITH_OTLP_GRPC)
384-
message(
385-
FATAL_ERROR
386-
"Protobuf 3.22 or upper require abseil-cpp(Recommended version: 20230125 or upper)"
387-
)
388-
endif()
389-
endif()
382+
# Protobuf 3.22 or upper require abseil-cpp, we can find it in
383+
# opentelemetry-cpp-config.cmake
390384

391385
if(WITH_OTLP_GRPC)
392386
find_package(gRPC)

api/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ if(WITH_NO_DEPRECATED_CODE)
3535
INTERFACE OPENTELEMETRY_NO_DEPRECATED_CODE)
3636
endif()
3737

38-
if(WITH_ABSEIL OR WITH_OTLP_GRPC)
38+
if(WITH_ABSEIL)
3939
target_compile_definitions(opentelemetry_api INTERFACE HAVE_ABSEIL)
4040
target_link_libraries(
4141
opentelemetry_api INTERFACE absl::bad_variant_access absl::any absl::base

cmake/opentelemetry-cpp-config.cmake.in

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#
88
# Find the native opentelemetry-cpp includes and library.
99
#
10-
#
1110
# Result Variables
1211
# ^^^^^^^^^^^^^^^^
1312
#
@@ -72,6 +71,14 @@ set(OPENTELEMETRY_VERSION
7271

7372
find_package(Threads)
7473

74+
if(@WITH_ABSEIL@ OR @WITH_OTLP_GRPC@)
75+
find_package(absl CONFIG)
76+
elseif(OR @WITH_OTLP_HTTP@ OR @WITH_OTLP_FILE@)
77+
if("@Protobuf_VERSION@" VERSION_GREATER_EQUAL "3.22.0")
78+
find_package(absl CONFIG)
79+
endif()
80+
endif()
81+
7582
set_and_check(OPENTELEMETRY_CPP_INCLUDE_DIRS "@PACKAGE_INCLUDE_INSTALL_DIR@")
7683
set_and_check(OPENTELEMETRY_CPP_LIBRARY_DIRS "@PACKAGE_CMAKE_INSTALL_LIBDIR@")
7784

cmake/opentelemetry-proto.cmake

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -331,10 +331,20 @@ set_target_version(opentelemetry_proto)
331331
set_target_properties(opentelemetry_proto PROPERTIES CXX_INCLUDE_WHAT_YOU_USE
332332
"")
333333

334-
if(WITH_ABSEIL OR WITH_OTLP_GRPC)
334+
if(TARGET absl::bad_variant_access)
335335
target_link_libraries(opentelemetry_proto PUBLIC absl::bad_variant_access)
336336
endif()
337337

338+
if(NOT Protobuf_INCLUDE_DIRS AND TARGET protobuf::libprotobuf)
339+
get_target_property(Protobuf_INCLUDE_DIRS protobuf::libprotobuf
340+
INTERFACE_INCLUDE_DIRECTORIES)
341+
endif()
342+
if(Protobuf_INCLUDE_DIRS)
343+
target_include_directories(
344+
opentelemetry_proto BEFORE
345+
PUBLIC "$<BUILD_INTERFACE:${Protobuf_INCLUDE_DIRS}")
346+
endif()
347+
338348
if(WITH_OTLP_GRPC)
339349
add_library(
340350
opentelemetry_proto_grpc
@@ -356,7 +366,7 @@ if(WITH_OTLP_GRPC)
356366
INTERFACE_INCLUDE_DIRECTORIES)
357367
if(GRPC_INCLUDE_DIRECTORY)
358368
target_include_directories(
359-
opentelemetry_proto_grpc
369+
opentelemetry_proto_grpc BEFORE
360370
PUBLIC "$<BUILD_INTERFACE:${GRPC_INCLUDE_DIRECTORY}>")
361371
endif()
362372
endif()
@@ -385,8 +395,6 @@ endif()
385395
if(TARGET protobuf::libprotobuf)
386396
target_link_libraries(opentelemetry_proto PUBLIC protobuf::libprotobuf)
387397
else() # cmake 3.8 or lower
388-
target_include_directories(opentelemetry_proto
389-
PUBLIC ${Protobuf_INCLUDE_DIRS})
390398
target_link_libraries(opentelemetry_proto PUBLIC ${Protobuf_LIBRARIES})
391399
endif()
392400

exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_client_factory.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ class OPENTELEMETRY_EXPORT OtlpGrpcClientFactory
2626
/**
2727
* Create an OtlpGrpcClient using all default options.
2828
*/
29-
static nostd::shared_ptr<OtlpGrpcClient> Create(const OtlpGrpcClientOptions &options);
29+
static std::shared_ptr<OtlpGrpcClient> Create(const OtlpGrpcClientOptions &options);
3030

31-
static nostd::shared_ptr<OtlpGrpcClientReferenceGuard> CreateReferenceGuard();
31+
static std::shared_ptr<OtlpGrpcClientReferenceGuard> CreateReferenceGuard();
3232
};
3333

3434
} // namespace otlp

exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_exporter.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class OtlpGrpcExporter final : public opentelemetry::sdk::trace::SpanExporter
5050
* @param client the gRPC client to use
5151
*/
5252
OtlpGrpcExporter(const OtlpGrpcExporterOptions &options,
53-
nostd::shared_ptr<OtlpGrpcClient> client);
53+
const std::shared_ptr<OtlpGrpcClient> &client);
5454

5555
/**
5656
* Create an OtlpGrpcExporter using the given options.
@@ -94,21 +94,21 @@ class OtlpGrpcExporter final : public opentelemetry::sdk::trace::SpanExporter
9494
*
9595
* @return return binded gRPC client
9696
*/
97-
const nostd::shared_ptr<OtlpGrpcClient> &GetClient() const noexcept;
97+
const std::shared_ptr<OtlpGrpcClient> &GetClient() const noexcept;
9898

9999
private:
100100
// The configuration options associated with this exporter.
101101
const OtlpGrpcExporterOptions options_;
102102

103-
nostd::shared_ptr<OtlpGrpcClient> client_;
104-
nostd::shared_ptr<OtlpGrpcClientReferenceGuard> client_reference_guard_;
103+
std::shared_ptr<OtlpGrpcClient> client_;
104+
std::shared_ptr<OtlpGrpcClientReferenceGuard> client_reference_guard_;
105105

106106
// For testing
107107
friend class OtlpGrpcExporterTestPeer;
108108
friend class OtlpGrpcLogRecordExporterTestPeer;
109109

110110
// Store service stub internally. Useful for testing.
111-
nostd::shared_ptr<proto::collector::trace::v1::TraceService::StubInterface> trace_service_stub_;
111+
std::shared_ptr<proto::collector::trace::v1::TraceService::StubInterface> trace_service_stub_;
112112

113113
/**
114114
* Create an OtlpGrpcExporter using the specified service stub.
@@ -124,7 +124,7 @@ class OtlpGrpcExporter final : public opentelemetry::sdk::trace::SpanExporter
124124
* @param client the gRPC client to use
125125
*/
126126
OtlpGrpcExporter(std::unique_ptr<proto::collector::trace::v1::TraceService::StubInterface> stub,
127-
nostd::shared_ptr<OtlpGrpcClient> client);
127+
const std::shared_ptr<OtlpGrpcClient> &client);
128128

129129
std::atomic<bool> is_shutdown_{false};
130130
bool isShutdown() const noexcept;

exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_exporter_factory.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class OPENTELEMETRY_EXPORT OtlpGrpcExporterFactory
3939
*/
4040
static std::unique_ptr<opentelemetry::sdk::trace::SpanExporter> Create(
4141
const OtlpGrpcExporterOptions &options,
42-
nostd::shared_ptr<OtlpGrpcClient> client);
42+
const std::shared_ptr<OtlpGrpcClient> &client);
4343
};
4444

4545
} // namespace otlp

exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class OtlpGrpcLogRecordExporter : public opentelemetry::sdk::logs::LogRecordExpo
4848
* @param client the gRPC client to use
4949
*/
5050
OtlpGrpcLogRecordExporter(const OtlpGrpcLogRecordExporterOptions &options,
51-
nostd::shared_ptr<OtlpGrpcClient> client);
51+
const std::shared_ptr<OtlpGrpcClient> &client);
5252

5353
/**
5454
* Create an OtlpGrpcLogRecordExporter with user specified options.
@@ -93,20 +93,20 @@ class OtlpGrpcLogRecordExporter : public opentelemetry::sdk::logs::LogRecordExpo
9393
*
9494
* @return return binded gRPC client
9595
*/
96-
const nostd::shared_ptr<OtlpGrpcClient> &GetClient() const noexcept;
96+
const std::shared_ptr<OtlpGrpcClient> &GetClient() const noexcept;
9797

9898
private:
9999
// Configuration options for the exporter
100100
const OtlpGrpcLogRecordExporterOptions options_;
101101

102-
nostd::shared_ptr<OtlpGrpcClient> client_;
103-
nostd::shared_ptr<OtlpGrpcClientReferenceGuard> client_reference_guard_;
102+
std::shared_ptr<OtlpGrpcClient> client_;
103+
std::shared_ptr<OtlpGrpcClientReferenceGuard> client_reference_guard_;
104104

105105
// For testing
106106
friend class OtlpGrpcLogRecordExporterTestPeer;
107107

108108
// Store service stub internally. Useful for testing.
109-
nostd::shared_ptr<proto::collector::logs::v1::LogsService::StubInterface> log_service_stub_;
109+
std::shared_ptr<proto::collector::logs::v1::LogsService::StubInterface> log_service_stub_;
110110

111111
/**
112112
* Create an OtlpGrpcLogRecordExporter using the specified service stub.
@@ -124,7 +124,7 @@ class OtlpGrpcLogRecordExporter : public opentelemetry::sdk::logs::LogRecordExpo
124124
*/
125125
OtlpGrpcLogRecordExporter(
126126
std::unique_ptr<proto::collector::logs::v1::LogsService::StubInterface> stub,
127-
nostd::shared_ptr<OtlpGrpcClient> client);
127+
const std::shared_ptr<OtlpGrpcClient> &client);
128128

129129
std::atomic<bool> is_shutdown_{false};
130130
bool isShutdown() const noexcept;

exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter_factory.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class OPENTELEMETRY_EXPORT OtlpGrpcLogRecordExporterFactory
3737
*/
3838
static std::unique_ptr<opentelemetry::sdk::logs::LogRecordExporter> Create(
3939
const OtlpGrpcLogRecordExporterOptions &options,
40-
nostd::shared_ptr<OtlpGrpcClient> client);
40+
const std::shared_ptr<OtlpGrpcClient> &client);
4141
};
4242

4343
} // namespace otlp

exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_metric_exporter.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class OtlpGrpcMetricExporter : public opentelemetry::sdk::metrics::PushMetricExp
4747
* @param client the gRPC client to use
4848
*/
4949
OtlpGrpcMetricExporter(const OtlpGrpcMetricExporterOptions &options,
50-
nostd::shared_ptr<OtlpGrpcClient> client);
50+
const std::shared_ptr<OtlpGrpcClient> &client);
5151

5252
/**
5353
* Create an OtlpGrpcMetricExporter using the given options.
@@ -78,14 +78,14 @@ class OtlpGrpcMetricExporter : public opentelemetry::sdk::metrics::PushMetricExp
7878
*
7979
* @return return binded gRPC client
8080
*/
81-
const nostd::shared_ptr<OtlpGrpcClient> &GetClient() const noexcept;
81+
const std::shared_ptr<OtlpGrpcClient> &GetClient() const noexcept;
8282

8383
private:
8484
// The configuration options associated with this exporter.
8585
const OtlpGrpcMetricExporterOptions options_;
8686

87-
nostd::shared_ptr<OtlpGrpcClient> client_;
88-
nostd::shared_ptr<OtlpGrpcClientReferenceGuard> client_reference_guard_;
87+
std::shared_ptr<OtlpGrpcClient> client_;
88+
std::shared_ptr<OtlpGrpcClientReferenceGuard> client_reference_guard_;
8989

9090
// Aggregation Temporality selector
9191
const sdk::metrics::AggregationTemporalitySelector aggregation_temporality_selector_;
@@ -94,7 +94,7 @@ class OtlpGrpcMetricExporter : public opentelemetry::sdk::metrics::PushMetricExp
9494
friend class OtlpGrpcMetricExporterTestPeer;
9595

9696
// Store service stub internally. Useful for testing.
97-
nostd::shared_ptr<proto::collector::metrics::v1::MetricsService::StubInterface>
97+
std::shared_ptr<proto::collector::metrics::v1::MetricsService::StubInterface>
9898
metrics_service_stub_;
9999

100100
/**
@@ -113,7 +113,7 @@ class OtlpGrpcMetricExporter : public opentelemetry::sdk::metrics::PushMetricExp
113113
*/
114114
OtlpGrpcMetricExporter(
115115
std::unique_ptr<proto::collector::metrics::v1::MetricsService::StubInterface> stub,
116-
nostd::shared_ptr<OtlpGrpcClient> client);
116+
const std::shared_ptr<OtlpGrpcClient> &client);
117117

118118
std::atomic<bool> is_shutdown_{false};
119119
bool isShutdown() const noexcept;

0 commit comments

Comments
 (0)