Skip to content

Commit 2bd4c95

Browse files
authored
Merge branch 'main' into cmake_vcpkg_otelcpp_port_fixes
2 parents ac57c9e + 3eec22c commit 2bd4c95

File tree

50 files changed

+1302
-111
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1302
-111
lines changed

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,9 @@ if(ZLIB_FOUND)
695695
message(STATUS "ZLIB: ${ZLIB_VERSION}")
696696
endif()
697697
if(USE_NLOHMANN_JSON)
698-
message(STATUS "nlohmann-json: ${nlohmann_json_VERSION}")
698+
message(
699+
STATUS "nlohmann-json: ${nlohmann_json_VERSION} (${nlohmann_json_PROVIDER})"
700+
)
699701
endif()
700702
if(prometheus-cpp_FOUND)
701703
message(STATUS "prometheus-cpp: ${prometheus-cpp_VERSION}")

cmake/nlohmann-json.cmake

Lines changed: 39 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,48 @@
11
# Copyright The OpenTelemetry Authors
22
# SPDX-License-Identifier: Apache-2.0
33

4-
#
5-
# The dependency on nlohmann_json can be provided different ways. By order of
6-
# decreasing priority, options are:
7-
#
8-
# 1 - Search for a nlohmann_json package
9-
#
10-
# Packages installed on the local machine are used if found.
11-
#
12-
# The nlohmann_json dependency is not installed, as it already is.
13-
#
14-
# 2 - Search for a nlohmann_json git submodule
15-
#
16-
# When git submodule is used, the nlohmann_json code is located in:
17-
# third_party/nlohmann-json
18-
#
19-
# The nlohmann_json dependency is installed, by building the sub directory with
20-
# JSON_Install=ON
21-
#
22-
# 3 - Download nlohmann_json from github
23-
#
24-
# Code from the development branch is used, unless a specific release tag is
25-
# provided in variable ${nlohmann-json}
26-
#
27-
# The nlohmann_json dependency is installed, by building the downloaded code
28-
# with JSON_Install=ON
29-
#
4+
# Import nlohmann_json target (nlohmann_json::nlohmann_json).
5+
# 1. Find an installed nlohmann-json package
6+
# 2. Use FetchContent to build nlohmann-json from a git submodule
7+
# 3. Use FetchContent to fetch and build nlohmann-json from GitHub
308

31-
# nlohmann_json package is required for most SDK build configurations
32-
find_package(nlohmann_json QUIET)
33-
set(nlohmann_json_clone FALSE)
34-
if(nlohmann_json_FOUND)
35-
message(STATUS "nlohmann::json dependency satisfied by: package")
36-
elseif(TARGET nlohmann_json)
37-
message(STATUS "nlohmann::json is already added as a CMake target!")
38-
elseif(EXISTS ${PROJECT_SOURCE_DIR}/.git
39-
AND EXISTS
40-
${PROJECT_SOURCE_DIR}/third_party/nlohmann-json/CMakeLists.txt)
41-
message(STATUS "nlohmann::json dependency satisfied by: git submodule")
42-
set(JSON_BuildTests
43-
OFF
44-
CACHE INTERNAL "")
45-
set(JSON_Install
46-
ON
47-
CACHE INTERNAL "")
48-
# This option allows to link nlohmann_json::nlohmann_json target
49-
add_subdirectory(${PROJECT_SOURCE_DIR}/third_party/nlohmann-json)
50-
# This option allows to add header to include directories
51-
include_directories(
52-
${PROJECT_SOURCE_DIR}/third_party/nlohmann-json/single_include)
53-
else()
54-
if("${nlohmann-json}" STREQUAL "")
55-
set(nlohmann-json "develop")
9+
find_package(nlohmann_json CONFIG QUIET)
10+
set(nlohmann_json_PROVIDER "find_package")
11+
12+
if(NOT nlohmann_json_FOUND)
13+
set(_NLOHMANN_JSON_SUBMODULE_DIR "${opentelemetry-cpp_SOURCE_DIR}/third_party/nlohmann-json")
14+
if(EXISTS "${_NLOHMANN_JSON_SUBMODULE_DIR}/.git")
15+
FetchContent_Declare(
16+
"nlohmann_json"
17+
SOURCE_DIR "${_NLOHMANN_JSON_SUBMODULE_DIR}"
18+
)
19+
set(nlohmann_json_PROVIDER "fetch_source")
20+
else()
21+
FetchContent_Declare(
22+
"nlohmann_json"
23+
GIT_REPOSITORY "https://github.com/nlohmann/json.git"
24+
GIT_TAG "${nlohmann-json_GIT_TAG}"
25+
)
26+
set(nlohmann_json_PROVIDER "fetch_repository")
5627
endif()
57-
message(STATUS "nlohmann::json dependency satisfied by: github download")
58-
set(nlohmann_json_clone TRUE)
59-
include(ExternalProject)
60-
ExternalProject_Add(
61-
nlohmann_json_download
62-
PREFIX third_party
63-
GIT_REPOSITORY https://github.com/nlohmann/json.git
64-
GIT_TAG "${nlohmann-json_GIT_TAG}"
65-
UPDATE_COMMAND ""
66-
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
67-
-DJSON_BuildTests=OFF -DJSON_Install=ON
68-
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
69-
TEST_AFTER_INSTALL 0
70-
DOWNLOAD_NO_PROGRESS 1
71-
LOG_CONFIGURE 1
72-
LOG_BUILD 1
73-
LOG_INSTALL 1)
7428

75-
ExternalProject_Get_Property(nlohmann_json_download INSTALL_DIR)
76-
set(NLOHMANN_JSON_INCLUDE_DIR
77-
${INSTALL_DIR}/src/nlohmann_json_download/single_include)
78-
add_library(nlohmann_json_ INTERFACE)
79-
target_include_directories(
80-
nlohmann_json_ INTERFACE "$<BUILD_INTERFACE:${NLOHMANN_JSON_INCLUDE_DIR}>"
81-
"$<INSTALL_INTERFACE:include>")
82-
add_dependencies(nlohmann_json_ nlohmann_json_download)
83-
add_library(nlohmann_json::nlohmann_json ALIAS nlohmann_json_)
29+
set(JSON_BuildTests OFF CACHE BOOL "" FORCE)
30+
set(JSON_Install ${OPENTELEMETRY_INSTALL} CACHE BOOL "" FORCE)
31+
set(JSON_MultipleHeaders OFF CACHE BOOL "" FORCE)
32+
33+
FetchContent_MakeAvailable(nlohmann_json)
34+
35+
# Set the nlohmann_json_VERSION variable from the git tag.
36+
string(REGEX REPLACE "^v([0-9]+\\.[0-9]+\\.[0-9]+)$" "\\1" nlohmann_json_VERSION "${nlohmann-json_GIT_TAG}")
8437

85-
if(OPENTELEMETRY_INSTALL)
86-
install(
87-
TARGETS nlohmann_json_
88-
EXPORT "${PROJECT_NAME}-third_party_nlohmann_json_target"
89-
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
90-
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
91-
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
92-
COMPONENT third_party_nlohmann_json)
38+
#Disable iwyu and clang-tidy
39+
if(TARGET nlohmann_json)
40+
set_target_properties(nlohmann_json PROPERTIES CXX_INCLUDE_WHAT_YOU_USE ""
41+
CXX_CLANG_TIDY "")
9342
endif()
9443
endif()
44+
45+
if(NOT TARGET nlohmann_json::nlohmann_json)
46+
message(FATAL_ERROR "A required nlohmann_json target (nlohmann_json::nlohmann_json) was not imported")
47+
endif()
48+

exporters/etw/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ target_link_libraries(
1515
opentelemetry_exporter_etw INTERFACE opentelemetry_api opentelemetry_trace
1616
nlohmann_json::nlohmann_json)
1717
target_link_libraries(opentelemetry_exporter_etw INTERFACE opentelemetry_logs)
18-
if(nlohmann_json_clone)
19-
add_dependencies(opentelemetry_exporter_etw nlohmann_json::nlohmann_json)
20-
endif()
2118

2219
otel_add_component(
2320
COMPONENT

exporters/otlp/CMakeLists.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,6 @@ if(WITH_OTLP_HTTP)
151151
"$<BUILD_INTERFACE:nlohmann_json::nlohmann_json>"
152152
"$<INSTALL_INTERFACE:opentelemetry_http_client_curl>")
153153

154-
if(nlohmann_json_clone)
155-
add_dependencies(opentelemetry_exporter_otlp_http_client
156-
nlohmann_json::nlohmann_json)
157-
endif()
158154
target_include_directories(
159155
opentelemetry_exporter_otlp_http_client
160156
PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"
@@ -228,10 +224,6 @@ if(WITH_OTLP_FILE)
228224
PUBLIC opentelemetry_sdk opentelemetry_common
229225
PRIVATE opentelemetry_proto $<BUILD_INTERFACE:nlohmann_json::nlohmann_json>)
230226

231-
if(nlohmann_json_clone)
232-
add_dependencies(opentelemetry_exporter_otlp_file_client
233-
nlohmann_json::nlohmann_json)
234-
endif()
235227
target_include_directories(
236228
opentelemetry_exporter_otlp_file_client
237229
PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"

ext/test/w3c_tracecontext_http_test_server/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,3 @@ target_link_libraries(
77
PRIVATE ${CMAKE_THREAD_LIBS_INIT} opentelemetry_trace
88
opentelemetry_http_client_curl opentelemetry_exporter_ostream_span
99
${CURL_LIBRARIES} nlohmann_json::nlohmann_json)
10-
if(nlohmann_json_clone)
11-
add_dependencies(w3c_tracecontext_http_test_server
12-
nlohmann_json::nlohmann_json)
13-
endif()
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright The OpenTelemetry Authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
#pragma once
5+
6+
#include "opentelemetry/version.h"
7+
8+
OPENTELEMETRY_BEGIN_NAMESPACE
9+
namespace sdk
10+
{
11+
namespace configuration
12+
{
13+
class AggregationConfigurationVisitor;
14+
15+
// YAML-SCHEMA: schema/meter_provider.json
16+
// YAML-NODE: aggregation
17+
class AggregationConfiguration
18+
{
19+
public:
20+
AggregationConfiguration() = default;
21+
AggregationConfiguration(AggregationConfiguration &&) = default;
22+
AggregationConfiguration(const AggregationConfiguration &) = default;
23+
AggregationConfiguration &operator=(AggregationConfiguration &&) = default;
24+
AggregationConfiguration &operator=(const AggregationConfiguration &other) = default;
25+
virtual ~AggregationConfiguration() = default;
26+
27+
virtual void Accept(AggregationConfigurationVisitor *visitor) const = 0;
28+
};
29+
30+
} // namespace configuration
31+
} // namespace sdk
32+
OPENTELEMETRY_END_NAMESPACE
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Copyright The OpenTelemetry Authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
#pragma once
5+
6+
#include "opentelemetry/version.h"
7+
8+
OPENTELEMETRY_BEGIN_NAMESPACE
9+
namespace sdk
10+
{
11+
namespace configuration
12+
{
13+
14+
class Base2ExponentialBucketHistogramAggregationConfiguration;
15+
class DefaultAggregationConfiguration;
16+
class DropAggregationConfiguration;
17+
class ExplicitBucketHistogramAggregationConfiguration;
18+
class LastValueAggregationConfiguration;
19+
class SumAggregationConfiguration;
20+
21+
class AggregationConfigurationVisitor
22+
{
23+
public:
24+
AggregationConfigurationVisitor() = default;
25+
AggregationConfigurationVisitor(AggregationConfigurationVisitor &&) = default;
26+
AggregationConfigurationVisitor(const AggregationConfigurationVisitor &) = default;
27+
AggregationConfigurationVisitor &operator=(AggregationConfigurationVisitor &&) = default;
28+
AggregationConfigurationVisitor &operator=(const AggregationConfigurationVisitor &other) =
29+
default;
30+
virtual ~AggregationConfigurationVisitor() = default;
31+
32+
virtual void VisitBase2ExponentialBucketHistogram(
33+
const Base2ExponentialBucketHistogramAggregationConfiguration *model) = 0;
34+
virtual void VisitDefault(const DefaultAggregationConfiguration *model) = 0;
35+
virtual void VisitDrop(const DropAggregationConfiguration *model) = 0;
36+
virtual void VisitExplicitBucketHistogram(
37+
const ExplicitBucketHistogramAggregationConfiguration *model) = 0;
38+
virtual void VisitLastValue(const LastValueAggregationConfiguration *model) = 0;
39+
virtual void VisitSum(const SumAggregationConfiguration *model) = 0;
40+
};
41+
42+
} // namespace configuration
43+
} // namespace sdk
44+
OPENTELEMETRY_END_NAMESPACE
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright The OpenTelemetry Authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
#pragma once
5+
6+
#include <cstddef>
7+
8+
#include "opentelemetry/version.h"
9+
10+
OPENTELEMETRY_BEGIN_NAMESPACE
11+
namespace sdk
12+
{
13+
namespace configuration
14+
{
15+
16+
// YAML-SCHEMA: schema/opentelemetry_configuration.json
17+
// YAML-NODE: AttributeLimits
18+
class AttributeLimitsConfiguration
19+
{
20+
public:
21+
std::size_t attribute_value_length_limit;
22+
std::size_t attribute_count_limit;
23+
};
24+
25+
} // namespace configuration
26+
} // namespace sdk
27+
OPENTELEMETRY_END_NAMESPACE
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright The OpenTelemetry Authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
#pragma once
5+
6+
#include "opentelemetry/version.h"
7+
8+
OPENTELEMETRY_BEGIN_NAMESPACE
9+
namespace sdk
10+
{
11+
namespace configuration
12+
{
13+
class AttributeValueConfigurationVisitor;
14+
15+
// YAML-SCHEMA: schema/resource.json
16+
// YAML-NODE: AttributeNameValue
17+
class AttributeValueConfiguration
18+
{
19+
public:
20+
AttributeValueConfiguration() = default;
21+
AttributeValueConfiguration(AttributeValueConfiguration &&) = default;
22+
AttributeValueConfiguration(const AttributeValueConfiguration &) = default;
23+
AttributeValueConfiguration &operator=(AttributeValueConfiguration &&) = default;
24+
AttributeValueConfiguration &operator=(const AttributeValueConfiguration &other) = default;
25+
virtual ~AttributeValueConfiguration() = default;
26+
27+
virtual void Accept(AttributeValueConfigurationVisitor *visitor) const = 0;
28+
};
29+
30+
} // namespace configuration
31+
} // namespace sdk
32+
OPENTELEMETRY_END_NAMESPACE
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Copyright The OpenTelemetry Authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
#pragma once
5+
6+
#include "opentelemetry/version.h"
7+
8+
OPENTELEMETRY_BEGIN_NAMESPACE
9+
namespace sdk
10+
{
11+
namespace configuration
12+
{
13+
14+
class StringAttributeValueConfiguration;
15+
class IntegerAttributeValueConfiguration;
16+
class DoubleAttributeValueConfiguration;
17+
class BooleanAttributeValueConfiguration;
18+
class StringArrayAttributeValueConfiguration;
19+
class IntegerArrayAttributeValueConfiguration;
20+
class DoubleArrayAttributeValueConfiguration;
21+
class BooleanArrayAttributeValueConfiguration;
22+
23+
class AttributeValueConfigurationVisitor
24+
{
25+
public:
26+
AttributeValueConfigurationVisitor() = default;
27+
AttributeValueConfigurationVisitor(AttributeValueConfigurationVisitor &&) = default;
28+
AttributeValueConfigurationVisitor(const AttributeValueConfigurationVisitor &) = default;
29+
AttributeValueConfigurationVisitor &operator=(AttributeValueConfigurationVisitor &&) = default;
30+
AttributeValueConfigurationVisitor &operator=(const AttributeValueConfigurationVisitor &other) =
31+
default;
32+
virtual ~AttributeValueConfigurationVisitor() = default;
33+
34+
virtual void VisitString(const StringAttributeValueConfiguration *model) = 0;
35+
virtual void VisitInteger(const IntegerAttributeValueConfiguration *model) = 0;
36+
virtual void VisitDouble(const DoubleAttributeValueConfiguration *model) = 0;
37+
virtual void VisitBoolean(const BooleanAttributeValueConfiguration *model) = 0;
38+
virtual void VisitStringArray(const StringArrayAttributeValueConfiguration *model) = 0;
39+
virtual void VisitIntegerArray(const IntegerArrayAttributeValueConfiguration *model) = 0;
40+
virtual void VisitDoubleArray(const DoubleArrayAttributeValueConfiguration *model) = 0;
41+
virtual void VisitBooleanArray(const BooleanArrayAttributeValueConfiguration *model) = 0;
42+
};
43+
44+
} // namespace configuration
45+
} // namespace sdk
46+
OPENTELEMETRY_END_NAMESPACE

0 commit comments

Comments
 (0)