Skip to content

Commit 623adf6

Browse files
committed
wl#16207: Update bundled OTel API headers
1 parent 1bd8d46 commit 623adf6

File tree

207 files changed

+7502
-400
lines changed

Some content is hidden

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

207 files changed

+7502
-400
lines changed

jdbc/CMakeLists.txt

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -149,16 +149,8 @@ endif()
149149

150150
find_dependency(MySQL)
151151

152-
add_library(otel_api INTERFACE)
153-
# Note: For now make it phony target on platforms other than Linux
154-
if(NOT (WIN32 OR APPLE OR CMAKE_SYSTEM_NAME MATCHES "SunOS"))
155-
message(STATUS "Adding OTel support")
156-
set(TELEMETRY ON)
157-
target_include_directories(otel_api INTERFACE
158-
"${PROJECT_SOURCE_DIR}/extra/otel/opentelemetry-cpp-1.8.3/api/include"
159-
)
160-
target_compile_definitions(otel_api INTERFACE TELEMETRY)
161-
endif()
152+
# otel_api interface target
153+
add_subdirectory(extra/otel)
162154

163155

164156
#-----------------

jdbc/extra/otel/CMakeLists.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
SET(OPENTELEMETRY_CPP_TAG "opentelemetry-cpp-1.10.0" CACHE INTERNAL "")
2+
3+
add_library(otel_api INTERFACE)
4+
5+
# Note: For now make it phony target on platforms other than Linux
6+
7+
if(NOT (WIN32 OR APPLE OR CMAKE_SYSTEM_NAME MATCHES "SunOS"))
8+
9+
message(STATUS "Adding OTel support")
10+
11+
set(TELEMETRY ON CACHE INTERNAL "Whether connector is built with OTel support")
12+
13+
target_include_directories(otel_api INTERFACE
14+
"${PROJECT_SOURCE_DIR}/extra/otel/${OPENTELEMETRY_CPP_TAG}/api/include"
15+
)
16+
17+
target_compile_definitions(otel_api INTERFACE TELEMETRY)
18+
19+
if(WIN32)
20+
# Note: warning C4996 is triggered by OTel headers (as of version 1.10.0)
21+
target_compile_definitions(otel_api INTERFACE _SILENCE_CXX17_RESULT_OF_DEPRECATION_WARNING)
22+
endif()
23+
24+
endif()
25+

jdbc/extra/otel/README.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
How to update the bundled version of opentelemetry-cpp
2+
======================================================
3+
4+
We use copy of opentelemetry-cpp sources that are bundled with the server
5+
(note that server potentially patches the original sources). When server
6+
starts to bundle new version X.Y.Z the following should be done to update
7+
our copy:
8+
9+
1. Delete the current opentelemtetry-cpp-* subfolder from this folder.
10+
11+
2. Copy folder opentelemetry-cpp-X.Y.Z from the server source tree to this
12+
folder.
13+
14+
3. Inside opentelemtry-cpp-X.Y.Z delete everything except api/ subfolder
15+
and LICENSE file.
16+
17+
4. Inside CMakeLists.txt in this folder update OPENTELEMETRY_CPP_TAG
18+
variable:
19+
20+
set(OPENTELEMETRY_CPP_TAG "opentelemetry-cpp-X.Y.Z" CACHE INTERNAL "")
21+
22+
3. Build and test connector on a platform on which we support OTel (Linux)
23+
to confirm that it works as before.

jdbc/extra/otel/opentelemetry-cpp-1.8.3/README.md renamed to jdbc/extra/otel/opentelemetry-cpp-1.10.0/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ of the current project.
5252
| Windows Server 2022 (Visual Studio Enterprise 2022) | CMake |
5353

5454
[1]: Bazel build is disabled for GCC 4.8, as gRPC library 1.38 and above
55-
(required by OTLP expoter) don't build with this compiler. See gRPC [official
55+
(required by OTLP exporter) don't build with this compiler. See gRPC [official
5656
support](https://grpc.io/docs/#official-support) document. CMake build doesn't
5757
build OTLP exporter with GCC 4.8.
5858

@@ -98,14 +98,13 @@ For edit access, get in touch on
9898

9999
* [Ehsan Saei](https://github.com/esigo)
100100
* [Lalit Kumar Bhasin](https://github.com/lalitb), Microsoft
101+
* [Marc Alff](https://github.com/marcalff), Oracle
101102
* [Tom Tan](https://github.com/ThomsonTan), Microsoft
102103

103104
[Approvers](https://github.com/open-telemetry/community/blob/main/community-membership.md#approver)
104105
([@open-telemetry/cpp-approvers](https://github.com/orgs/open-telemetry/teams/cpp-approvers)):
105106

106107
* [Josh Suereth](https://github.com/jsuereth), Google
107-
* [Marc Alff](https://github.com/marcalff), Oracle
108-
* [Reiley Yang](https://github.com/reyang), Microsoft
109108
* [WenTao Ou](https://github.com/owent), Tencent
110109

111110
[Emeritus
@@ -116,6 +115,7 @@ Maintainer/Approver/Triager](https://github.com/open-telemetry/community/blob/ma
116115
* [Jodee Varney](https://github.com/jodeev)
117116
* [Johannes Tax](https://github.com/pyohannes)
118117
* [Max Golovanov](https://github.com/maxgolov)
118+
* [Reiley Yang](https://github.com/reyang)
119119
* [Ryan Burn](https://github.com/rnburn)
120120

121121
### Thanks to all the people who have contributed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Copyright The OpenTelemetry Authors
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
5+
6+
package(default_visibility = ["//visibility:public"])
7+
8+
bool_flag(
9+
name = "with_abseil",
10+
build_setting_default = False,
11+
)
12+
13+
cc_library(
14+
name = "api",
15+
hdrs = glob(["include/**/*.h"]),
16+
defines = select({
17+
":with_external_abseil": ["HAVE_ABSEIL"],
18+
"//conditions:default": [],
19+
}),
20+
strip_include_prefix = "include",
21+
tags = ["api"],
22+
deps = select({
23+
":with_external_abseil": [
24+
"@com_google_absl//absl/base",
25+
"@com_google_absl//absl/types:variant",
26+
],
27+
"//conditions:default": [],
28+
}),
29+
)
30+
31+
config_setting(
32+
name = "with_external_abseil",
33+
flag_values = {":with_abseil": "true"},
34+
)

jdbc/extra/otel/opentelemetry-cpp-1.8.3/api/CMakeLists.txt renamed to jdbc/extra/otel/opentelemetry-cpp-1.10.0/api/CMakeLists.txt

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,14 @@ if(WITH_NO_DEPRECATED_CODE)
4646
INTERFACE OPENTELEMETRY_NO_DEPRECATED_CODE)
4747
endif()
4848

49-
if(WITH_ABSEIL)
50-
51-
find_package(absl CONFIG REQUIRED)
49+
if(TELEMETRY_WITH_ABSEIL)
50+
IF(WITH_PROTOBUF STREQUAL "bundled")
51+
INCLUDE_DIRECTORIES(BEFORE SYSTEM
52+
"${BUNDLED_PROTO_SRCDIR}"
53+
"${BUNDLED_ABSEIL_SRCDIR}")
54+
ELSE()
55+
find_package(absl CONFIG REQUIRED)
56+
ENDIF()
5257

5358
target_compile_definitions(opentelemetry_api INTERFACE HAVE_ABSEIL)
5459
target_link_libraries(
@@ -58,10 +63,10 @@ if(WITH_ABSEIL)
5863
endif()
5964

6065
if(WITH_STL)
61-
message("Building with standard library types...")
66+
message(STATUS "Building with standard library types...")
6267
target_compile_definitions(opentelemetry_api INTERFACE HAVE_CPP_STDLIB)
6368
else()
64-
message("Building with nostd types...")
69+
message(STATUS "Building with nostd types...")
6570
endif()
6671

6772
if(WITH_GSL)
@@ -98,6 +103,31 @@ if(WITH_ASYNC_EXPORT_PREVIEW)
98103
target_compile_definitions(opentelemetry_api INTERFACE ENABLE_ASYNC_EXPORT)
99104
endif()
100105

106+
if(WITH_REMOVE_METER_PREVIEW)
107+
target_compile_definitions(opentelemetry_api
108+
INTERFACE ENABLE_REMOVE_METER_PREVIEW)
109+
endif()
110+
111+
# A better place should be in sdk, not api
112+
if(WITH_OTLP_HTTP_SSL_PREVIEW)
113+
target_compile_definitions(opentelemetry_api
114+
INTERFACE ENABLE_OTLP_HTTP_SSL_PREVIEW)
115+
target_compile_definitions(opentelemetry_api
116+
INTERFACE ENABLE_HTTP_SSL_PREVIEW)
117+
118+
if(WITH_OTLP_HTTP_SSL_TLS_PREVIEW)
119+
target_compile_definitions(opentelemetry_api
120+
INTERFACE ENABLE_OTLP_HTTP_SSL_TLS_PREVIEW)
121+
target_compile_definitions(opentelemetry_api
122+
INTERFACE ENABLE_HTTP_SSL_TLS_PREVIEW)
123+
endif()
124+
endif()
125+
126+
if(WITH_OTLP_GRPC_SSL_MTLS_PREVIEW)
127+
target_compile_definitions(opentelemetry_api
128+
INTERFACE ENABLE_OTLP_GRPC_SSL_MTLS_PREVIEW)
129+
endif()
130+
101131
if(WITH_METRICS_EXEMPLAR_PREVIEW)
102132
target_compile_definitions(opentelemetry_api
103133
INTERFACE ENABLE_METRICS_EXEMPLAR_PREVIEW)

jdbc/extra/otel/opentelemetry-cpp-1.8.3/api/include/opentelemetry/baggage/baggage.h renamed to jdbc/extra/otel/opentelemetry-cpp-1.10.0/api/include/opentelemetry/baggage/baggage.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,12 @@ class OPENTELEMETRY_EXPORT Baggage
2626
static constexpr char kMembersSeparator = ',';
2727
static constexpr char kMetadataSeparator = ';';
2828

29-
Baggage() noexcept : kv_properties_(new opentelemetry::common::KeyValueProperties()) {}
30-
Baggage(size_t size) noexcept
31-
: kv_properties_(new opentelemetry::common::KeyValueProperties(size))
32-
{}
29+
Baggage() noexcept : kv_properties_(new common::KeyValueProperties()) {}
30+
Baggage(size_t size) noexcept : kv_properties_(new common::KeyValueProperties(size)) {}
3331

3432
template <class T>
3533
Baggage(const T &keys_and_values) noexcept
36-
: kv_properties_(new opentelemetry::common::KeyValueProperties(keys_and_values))
34+
: kv_properties_(new common::KeyValueProperties(keys_and_values))
3735
{}
3836

3937
OPENTELEMETRY_API_SINGLETON static nostd::shared_ptr<Baggage> GetDefault()
@@ -293,7 +291,7 @@ class OPENTELEMETRY_EXPORT Baggage
293291

294292
private:
295293
// Store entries in a C-style array to avoid using std::array or std::vector.
296-
nostd::unique_ptr<opentelemetry::common::KeyValueProperties> kv_properties_;
294+
nostd::unique_ptr<common::KeyValueProperties> kv_properties_;
297295
};
298296

299297
} // namespace baggage
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Copyright The OpenTelemetry Authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
#pragma once
5+
6+
#include "opentelemetry/baggage/baggage.h"
7+
#include "opentelemetry/context/context.h"
8+
#include "opentelemetry/nostd/shared_ptr.h"
9+
#include "opentelemetry/version.h"
10+
11+
OPENTELEMETRY_BEGIN_NAMESPACE
12+
13+
namespace baggage
14+
{
15+
16+
static const std::string kBaggageHeader = "baggage";
17+
18+
inline nostd::shared_ptr<Baggage> GetBaggage(const context::Context &context) noexcept
19+
{
20+
context::ContextValue context_value = context.GetValue(kBaggageHeader);
21+
if (nostd::holds_alternative<nostd::shared_ptr<Baggage>>(context_value))
22+
{
23+
return nostd::get<nostd::shared_ptr<Baggage>>(context_value);
24+
}
25+
static nostd::shared_ptr<Baggage> empty_baggage{new Baggage()};
26+
return empty_baggage;
27+
}
28+
29+
inline context::Context SetBaggage(context::Context &context,
30+
nostd::shared_ptr<Baggage> baggage) noexcept
31+
{
32+
return context.SetValue(kBaggageHeader, baggage);
33+
}
34+
35+
} // namespace baggage
36+
OPENTELEMETRY_END_NAMESPACE
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,29 @@ namespace baggage
1414
namespace propagation
1515
{
1616

17-
class BaggagePropagator : public opentelemetry::context::propagation::TextMapPropagator
17+
class BaggagePropagator : public context::propagation::TextMapPropagator
1818
{
1919
public:
20-
void Inject(opentelemetry::context::propagation::TextMapCarrier &carrier,
21-
const opentelemetry::context::Context &context) noexcept override
20+
void Inject(context::propagation::TextMapCarrier &carrier,
21+
const context::Context &context) noexcept override
2222
{
23-
auto baggage = opentelemetry::baggage::GetBaggage(context);
23+
auto baggage = baggage::GetBaggage(context);
2424
auto header = baggage->ToHeader();
2525
if (header.size())
2626
{
2727
carrier.Set(kBaggageHeader, header);
2828
}
2929
}
3030

31-
context::Context Extract(const opentelemetry::context::propagation::TextMapCarrier &carrier,
32-
opentelemetry::context::Context &context) noexcept override
31+
context::Context Extract(const context::propagation::TextMapCarrier &carrier,
32+
context::Context &context) noexcept override
3333
{
34-
nostd::string_view baggage_str = carrier.Get(opentelemetry::baggage::kBaggageHeader);
35-
auto baggage = opentelemetry::baggage::Baggage::FromHeader(baggage_str);
34+
nostd::string_view baggage_str = carrier.Get(baggage::kBaggageHeader);
35+
auto baggage = baggage::Baggage::FromHeader(baggage_str);
3636

3737
if (baggage->ToHeader().size())
3838
{
39-
return opentelemetry::baggage::SetBaggage(context, baggage);
39+
return baggage::SetBaggage(context, baggage);
4040
}
4141
else
4242
{

jdbc/extra/otel/opentelemetry-cpp-1.8.3/api/include/opentelemetry/common/key_value_iterable.h renamed to jdbc/extra/otel/opentelemetry-cpp-1.10.0/api/include/opentelemetry/common/key_value_iterable.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#include "opentelemetry/common/attribute_value.h"
77
#include "opentelemetry/nostd/function_ref.h"
8+
#include "opentelemetry/nostd/string_view.h"
89
#include "opentelemetry/version.h"
910

1011
OPENTELEMETRY_BEGIN_NAMESPACE

jdbc/extra/otel/opentelemetry-cpp-1.8.3/api/include/opentelemetry/common/key_value_iterable_view.h renamed to jdbc/extra/otel/opentelemetry-cpp-1.10.0/api/include/opentelemetry/common/key_value_iterable_view.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
#pragma once
55

66
#include <iterator>
7-
#include <type_traits>
87
#include <utility>
98

109
#include "opentelemetry/common/key_value_iterable.h"
10+
#include "opentelemetry/nostd/function_ref.h"
1111
#include "opentelemetry/nostd/span.h"
1212
#include "opentelemetry/nostd/string_view.h"
1313
#include "opentelemetry/nostd/type_traits.h"

jdbc/extra/otel/opentelemetry-cpp-1.8.3/api/include/opentelemetry/common/kv_properties.h renamed to jdbc/extra/otel/opentelemetry-cpp-1.10.0/api/include/opentelemetry/common/kv_properties.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#include "opentelemetry/common/key_value_iterable_view.h"
77
#include "opentelemetry/common/string_util.h"
88
#include "opentelemetry/nostd/function_ref.h"
9-
#include "opentelemetry/nostd/shared_ptr.h"
109
#include "opentelemetry/nostd/string_view.h"
1110
#include "opentelemetry/nostd/unique_ptr.h"
1211
#include "opentelemetry/version.h"

jdbc/extra/otel/opentelemetry-cpp-1.8.3/api/include/opentelemetry/common/macros.h renamed to jdbc/extra/otel/opentelemetry-cpp-1.10.0/api/include/opentelemetry/common/macros.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
# define OPENTELEMETRY_LIKELY_IF(...) \
1111
if (__VA_ARGS__) \
1212
[[likely]]
13+
1314
# endif
1415
# endif
1516
#endif
@@ -176,6 +177,31 @@ point.
176177

177178
#endif
178179

180+
//
181+
// Atomic wrappers based on compiler intrinsics for memory read/write.
182+
// The tailing number is read/write length in bits.
183+
//
184+
// N.B. Compiler instrinsic is used because the usage of C++ standard library is restricted in the
185+
// OpenTelemetry C++ API.
186+
//
187+
#if defined(__GNUC__)
188+
189+
# define OPENTELEMETRY_ATOMIC_READ_8(ptr) __atomic_load_n(ptr, __ATOMIC_SEQ_CST)
190+
# define OPENTELEMETRY_ATOMIC_WRITE_8(ptr, value) __atomic_store_n(ptr, value, __ATOMIC_SEQ_CST)
191+
192+
#elif defined(_MSC_VER)
193+
194+
# include <intrin.h>
195+
196+
# define OPENTELEMETRY_ATOMIC_READ_8(ptr) \
197+
static_cast<uint8_t>(_InterlockedCompareExchange8(reinterpret_cast<char *>(ptr), 0, 0))
198+
# define OPENTELEMETRY_ATOMIC_WRITE_8(ptr, value) \
199+
_InterlockedExchange8(reinterpret_cast<char *>(ptr), static_cast<char>(value))
200+
201+
#else
202+
# error port atomics read/write for the current platform
203+
#endif
204+
179205
/* clang-format on */
180206
//
181207
// The if/elif order matters here. If both OPENTELEMETRY_BUILD_IMPORT_DLL and

jdbc/extra/otel/opentelemetry-cpp-1.8.3/api/include/opentelemetry/common/string_util.h renamed to jdbc/extra/otel/opentelemetry-cpp-1.10.0/api/include/opentelemetry/common/string_util.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#pragma once
55

66
#include "opentelemetry/nostd/string_view.h"
7+
#include "opentelemetry/version.h"
78

89
OPENTELEMETRY_BEGIN_NAMESPACE
910
namespace common
@@ -14,11 +15,11 @@ class StringUtil
1415
public:
1516
static nostd::string_view Trim(nostd::string_view str, size_t left, size_t right) noexcept
1617
{
17-
while (str[static_cast<std::size_t>(left)] == ' ' && left <= right)
18+
while (left <= right && str[static_cast<std::size_t>(left)] == ' ')
1819
{
1920
left++;
2021
}
21-
while (str[static_cast<std::size_t>(right)] == ' ' && left <= right)
22+
while (left <= right && str[static_cast<std::size_t>(right)] == ' ')
2223
{
2324
right--;
2425
}

0 commit comments

Comments
 (0)