Skip to content

Commit

Permalink
Merge branch 'main' into fix/reader_data_race
Browse files Browse the repository at this point in the history
  • Loading branch information
arekay authored Mar 5, 2024
2 parents 41443bf + c82306f commit d80f3e2
Show file tree
Hide file tree
Showing 90 changed files with 892 additions and 188 deletions.
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,27 @@ Increment the:

## [Unreleased]

* [EXPORTER] Gzip compression support for OTLP/HTTP and OTLP/gRPC exporter
[#2530](https:/open-telemetry/opentelemetry-cpp/pull/2530)

Important changes:

* [EXPORTER] Gzip compression support for OTLP/HTTP and OTLP/gRPC exporter
[#2530](https:/open-telemetry/opentelemetry-cpp/pull/2530)
* In the `OtlpHttpExporterOptions` and `OtlpGrpcExporterOptions`, a new
field called compression has been introduced. This field can be set
to "gzip” to enable gzip compression.
* The CMake option `WITH_OTLP_HTTP_COMPRESSION` is introduced to enable
gzip compression support for the OTLP HTTP Exporter and includes a
dependency on zlib.
* [SDK] Change OTLP HTTP content_type default to binary
[#2558](https:/open-telemetry/opentelemetry-cpp/pull/2558)

## [1.14.2] 2024-02-27

* [SDK] Fix observable attributes drop
[#2557](https:/open-telemetry/opentelemetry-cpp/pull/2557)

## [1.14.1] 2024-02-23

* [SDK] Restore Recordable API compatibility with versions < 1.14.0
Expand Down
20 changes: 20 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,11 @@ option(WITH_OTLP_GRPC "Whether to include the OTLP gRPC exporter in the SDK"
option(WITH_OTLP_HTTP "Whether to include the OTLP http exporter in the SDK"
OFF)

option(
WITH_OTLP_HTTP_COMPRESSION
"Whether to include gzip compression for the OTLP http exporter in the SDK"
OFF)

option(WITH_ZIPKIN "Whether to include the Zipkin exporter in the SDK" OFF)

option(WITH_PROMETHEUS "Whether to include the Prometheus Client in the SDK"
Expand Down Expand Up @@ -448,6 +453,18 @@ if((NOT WITH_API_ONLY) AND WITH_HTTP_CLIENT_CURL)
message(STATUS "Found CURL: ${CURL_LIBRARIES}, version ${CURL_VERSION}")
endif()

#
# Do we need ZLIB ?
#

if((NOT WITH_API_ONLY)
AND WITH_HTTP_CLIENT_CURL
AND WITH_OTLP_HTTP_COMPRESSION)
# No specific version required.
find_package(ZLIB REQUIRED)
message(STATUS "Found ZLIB: ${ZLIB_LIBRARIES}, version ${ZLIB_VERSION}")
endif()

#
# Do we need NLOHMANN_JSON ?
#
Expand Down Expand Up @@ -488,6 +505,8 @@ if(OTELCPP_MAINTAINER_MODE)
$<$<STREQUAL:$<COMPILE_LANGUAGE>,CXX>:-Woverloaded-virtual>)
add_compile_options(
$<$<STREQUAL:$<COMPILE_LANGUAGE>,CXX>:-Wsuggest-override>)
add_compile_options(
$<$<STREQUAL:$<COMPILE_LANGUAGE>,CXX>:-Wold-style-cast>)

# C and C++
add_compile_options(-Wcast-qual)
Expand Down Expand Up @@ -527,6 +546,7 @@ if(OTELCPP_MAINTAINER_MODE)
add_compile_options(-Wundef)
add_compile_options(-Wundefined-reinterpret-cast)
add_compile_options(-Wvla)
add_compile_options(-Wold-style-cast)
endif()
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
message("Building with msvc in maintainer mode.")
Expand Down
5 changes: 5 additions & 0 deletions api/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ if(WITH_METRICS_EXEMPLAR_PREVIEW)
INTERFACE ENABLE_METRICS_EXEMPLAR_PREVIEW)
endif()

if(WITH_OTLP_HTTP_COMPRESSION)
target_compile_definitions(opentelemetry_api
INTERFACE ENABLE_OTLP_COMPRESSION_PREVIEW)
endif()

include(${PROJECT_SOURCE_DIR}/cmake/pkgconfig.cmake)

if(OPENTELEMETRY_INSTALL)
Expand Down
2 changes: 1 addition & 1 deletion api/include/opentelemetry/trace/span_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class SpanContext final
SpanContext(bool sampled_flag, bool is_remote) noexcept
: trace_id_(),
span_id_(),
trace_flags_(trace::TraceFlags((uint8_t)sampled_flag)),
trace_flags_(trace::TraceFlags(static_cast<uint8_t>(sampled_flag))),
is_remote_(is_remote),
trace_state_(TraceState::GetDefault())
{}
Expand Down
4 changes: 2 additions & 2 deletions api/include/opentelemetry/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
# define OPENTELEMETRY_ABI_VERSION_NO 1
#endif

#define OPENTELEMETRY_VERSION "1.14.1"
#define OPENTELEMETRY_VERSION "1.14.2"
#define OPENTELEMETRY_VERSION_MAJOR 1
#define OPENTELEMETRY_VERSION_MINOR 14
#define OPENTELEMETRY_VERSION_PATCH 1
#define OPENTELEMETRY_VERSION_PATCH 2

#define OPENTELEMETRY_ABI_VERSION OPENTELEMETRY_STRINGIFY(OPENTELEMETRY_ABI_VERSION_NO)

Expand Down
37 changes: 20 additions & 17 deletions api/test/context/context_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ using namespace opentelemetry;
// Tests that the context constructor accepts an std::map.
TEST(ContextTest, ContextIterableAcceptsMap)
{
std::map<std::string, context::ContextValue> map_test = {{"test_key", (int64_t)123}};
std::map<std::string, context::ContextValue> map_test = {{"test_key", static_cast<int64_t>(123)}};
context::Context test_context = context::Context(map_test);
}

// Tests that the GetValue method returns the expected value.
TEST(ContextTest, ContextGetValueReturnsExpectedValue)
{
std::map<std::string, context::ContextValue> map_test = {{"test_key", (int64_t)123},
{"foo_key", (int64_t)456}};
std::map<std::string, context::ContextValue> map_test = {{"test_key", static_cast<int64_t>(123)},
{"foo_key", static_cast<int64_t>(456)}};
const context::Context test_context = context::Context(map_test);
EXPECT_EQ(nostd::get<int64_t>(test_context.GetValue("test_key")), 123);
EXPECT_EQ(nostd::get<int64_t>(test_context.GetValue("foo_key")), 456);
Expand All @@ -29,8 +29,9 @@ TEST(ContextTest, ContextGetValueReturnsExpectedValue)
// Tests that the SetValues method accepts an std::map.
TEST(ContextTest, ContextSetValuesAcceptsMap)
{
std::map<std::string, context::ContextValue> map_test = {{"test_key", (int64_t)123}};
std::map<std::string, context::ContextValue> map_test_write = {{"foo_key", (int64_t)456}};
std::map<std::string, context::ContextValue> map_test = {{"test_key", static_cast<int64_t>(123)}};
std::map<std::string, context::ContextValue> map_test_write = {
{"foo_key", static_cast<int64_t>(456)}};

context::Context test_context = context::Context(map_test);
context::Context foo_context = test_context.SetValues(map_test_write);
Expand All @@ -44,7 +45,7 @@ TEST(ContextTest, ContextSetValuesAcceptsMap)
TEST(ContextTest, ContextSetValuesAcceptsStringViewContextValue)
{
nostd::string_view string_view_test = "string_view";
context::ContextValue context_value_test = (int64_t)123;
context::ContextValue context_value_test = static_cast<int64_t>(123);

context::Context test_context = context::Context(string_view_test, context_value_test);
context::Context foo_context = test_context.SetValue(string_view_test, context_value_test);
Expand All @@ -56,21 +57,21 @@ TEST(ContextTest, ContextSetValuesAcceptsStringViewContextValue)
// written to it.
TEST(ContextTest, ContextImmutability)
{
std::map<std::string, context::ContextValue> map_test = {{"test_key", (int64_t)123}};
std::map<std::string, context::ContextValue> map_test = {{"test_key", static_cast<int64_t>(123)}};

context::Context context_test = context::Context(map_test);
context::Context context_foo = context_test.SetValue("foo_key", (int64_t)456);
context::Context context_foo = context_test.SetValue("foo_key", static_cast<int64_t>(456));

EXPECT_FALSE(nostd::holds_alternative<int64_t>(context_test.GetValue("foo_key")));
}

// Tests that writing the same to a context overwrites the original value.
TEST(ContextTest, ContextKeyOverwrite)
{
std::map<std::string, context::ContextValue> map_test = {{"test_key", (int64_t)123}};
std::map<std::string, context::ContextValue> map_test = {{"test_key", static_cast<int64_t>(123)}};

context::Context context_test = context::Context(map_test);
context::Context context_foo = context_test.SetValue("test_key", (int64_t)456);
context::Context context_foo = context_test.SetValue("test_key", static_cast<int64_t>(456));

EXPECT_EQ(nostd::get<int64_t>(context_foo.GetValue("test_key")), 456);
}
Expand All @@ -81,8 +82,8 @@ TEST(ContextTest, ContextInheritance)
{
using M = std::map<std::string, context::ContextValue>;

M m1 = {{"test_key", (int64_t)123}, {"foo_key", (int64_t)321}};
M m2 = {{"other_key", (int64_t)789}, {"another_key", (int64_t)987}};
M m1 = {{"test_key", static_cast<int64_t>(123)}, {"foo_key", static_cast<int64_t>(321)}};
M m2 = {{"other_key", static_cast<int64_t>(789)}, {"another_key", static_cast<int64_t>(987)}};

context::Context test_context = context::Context(m1);
context::Context foo_context = test_context.SetValues(m2);
Expand All @@ -100,7 +101,9 @@ TEST(ContextTest, ContextInheritance)
TEST(ContextTest, ContextCopyOperator)
{
std::map<std::string, context::ContextValue> test_map = {
{"test_key", (int64_t)123}, {"foo_key", (int64_t)456}, {"other_key", (int64_t)789}};
{"test_key", static_cast<int64_t>(123)},
{"foo_key", static_cast<int64_t>(456)},
{"other_key", static_cast<int64_t>(789)}};

context::Context test_context = context::Context(test_map);
context::Context copied_context = test_context;
Expand All @@ -121,7 +124,7 @@ TEST(ContextTest, ContextEmptyMap)
// false if not.
TEST(ContextTest, ContextHasKey)
{
std::map<std::string, context::ContextValue> map_test = {{"test_key", (int64_t)123}};
std::map<std::string, context::ContextValue> map_test = {{"test_key", static_cast<int64_t>(123)}};
const context::Context context_test = context::Context(map_test);
EXPECT_TRUE(context_test.HasKey("test_key"));
EXPECT_FALSE(context_test.HasKey("foo_key"));
Expand All @@ -130,7 +133,7 @@ TEST(ContextTest, ContextHasKey)
// Tests that a copied context returns true when compared
TEST(ContextTest, ContextCopyCompare)
{
std::map<std::string, context::ContextValue> map_test = {{"test_key", (int64_t)123}};
std::map<std::string, context::ContextValue> map_test = {{"test_key", static_cast<int64_t>(123)}};
context::Context context_test = context::Context(map_test);
context::Context copied_test = context_test;
EXPECT_TRUE(context_test == copied_test);
Expand All @@ -139,8 +142,8 @@ TEST(ContextTest, ContextCopyCompare)
// Tests that two differently constructed contexts return false when compared
TEST(ContextTest, ContextDiffCompare)
{
std::map<std::string, context::ContextValue> map_test = {{"test_key", (int64_t)123}};
std::map<std::string, context::ContextValue> map_foo = {{"foo_key", (int64_t)123}};
std::map<std::string, context::ContextValue> map_test = {{"test_key", static_cast<int64_t>(123)}};
std::map<std::string, context::ContextValue> map_foo = {{"foo_key", static_cast<int64_t>(123)}};
context::Context context_test = context::Context(map_test);
context::Context foo_test = context::Context(map_foo);
EXPECT_FALSE(context_test == foo_test);
Expand Down
25 changes: 13 additions & 12 deletions api/test/context/runtime_context_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ using namespace opentelemetry;
// Tests that GetCurrent returns the current context
TEST(RuntimeContextTest, GetCurrent)
{
std::map<std::string, context::ContextValue> map_test = {{"test_key", (int64_t)123}};
std::map<std::string, context::ContextValue> map_test = {{"test_key", static_cast<int64_t>(123)}};
context::Context test_context = context::Context(map_test);
auto old_context = context::RuntimeContext::Attach(test_context);
EXPECT_EQ(context::RuntimeContext::GetCurrent(), test_context);
Expand All @@ -23,7 +23,7 @@ TEST(RuntimeContextTest, GetCurrent)
// Tests that detach resets the context to the previous context
TEST(RuntimeContextTest, Detach)
{
std::map<std::string, context::ContextValue> map_test = {{"test_key", (int64_t)123}};
std::map<std::string, context::ContextValue> map_test = {{"test_key", static_cast<int64_t>(123)}};
context::Context test_context = context::Context(map_test);
context::Context foo_context = context::Context(map_test);

Expand All @@ -38,7 +38,7 @@ TEST(RuntimeContextTest, Detach)
// Tests that detach returns false when the wrong context is provided
TEST(RuntimeContextTest, DetachWrongContext)
{
std::map<std::string, context::ContextValue> map_test = {{"test_key", (int64_t)123}};
std::map<std::string, context::ContextValue> map_test = {{"test_key", static_cast<int64_t>(123)}};
context::Context test_context = context::Context(map_test);
auto test_context_token = context::RuntimeContext::Attach(test_context);
EXPECT_TRUE(context::RuntimeContext::Detach(*test_context_token));
Expand All @@ -48,7 +48,7 @@ TEST(RuntimeContextTest, DetachWrongContext)
// Tests that the ThreadLocalContext can handle three attached contexts
TEST(RuntimeContextTest, ThreeAttachDetach)
{
std::map<std::string, context::ContextValue> map_test = {{"test_key", (int64_t)123}};
std::map<std::string, context::ContextValue> map_test = {{"test_key", static_cast<int64_t>(123)}};
context::Context test_context = context::Context(map_test);
context::Context foo_context = context::Context(map_test);
context::Context other_context = context::Context(map_test);
Expand All @@ -66,9 +66,10 @@ TEST(RuntimeContextTest, ThreeAttachDetach)
// RuntimeContext::SetValue method.
TEST(RuntimeContextTest, SetValueRuntimeContext)
{
context::Context foo_context = context::Context("foo_key", (int64_t)596);
auto old_context_token = context::RuntimeContext::Attach(foo_context);
context::Context test_context = context::RuntimeContext::SetValue("test_key", (int64_t)123);
context::Context foo_context = context::Context("foo_key", static_cast<int64_t>(596));
auto old_context_token = context::RuntimeContext::Attach(foo_context);
context::Context test_context =
context::RuntimeContext::SetValue("test_key", static_cast<int64_t>(123));
EXPECT_EQ(nostd::get<int64_t>(test_context.GetValue("test_key")), 123);
EXPECT_EQ(nostd::get<int64_t>(test_context.GetValue("foo_key")), 596);
}
Expand All @@ -78,9 +79,9 @@ TEST(RuntimeContextTest, SetValueRuntimeContext)
// RuntimeContext::SetValue method.
TEST(RuntimeContextTest, SetValueOtherContext)
{
context::Context foo_context = context::Context("foo_key", (int64_t)596);
context::Context foo_context = context::Context("foo_key", static_cast<int64_t>(596));
context::Context test_context =
context::RuntimeContext::SetValue("test_key", (int64_t)123, &foo_context);
context::RuntimeContext::SetValue("test_key", static_cast<int64_t>(123), &foo_context);
EXPECT_EQ(nostd::get<int64_t>(test_context.GetValue("test_key")), 123);
EXPECT_EQ(nostd::get<int64_t>(test_context.GetValue("foo_key")), 596);
}
Expand All @@ -89,7 +90,7 @@ TEST(RuntimeContextTest, SetValueOtherContext)
// passed in string and the current Runtime Context
TEST(RuntimeContextTest, GetValueRuntimeContext)
{
context::Context foo_context = context::Context("foo_key", (int64_t)596);
context::Context foo_context = context::Context("foo_key", static_cast<int64_t>(596));
auto old_context_token = context::RuntimeContext::Attach(foo_context);
EXPECT_EQ(nostd::get<int64_t>(context::RuntimeContext::GetValue("foo_key")), 596);
}
Expand All @@ -98,7 +99,7 @@ TEST(RuntimeContextTest, GetValueRuntimeContext)
// passed in string and the passed in context
TEST(RuntimeContextTest, GetValueOtherContext)
{
context::Context foo_context = context::Context("foo_key", (int64_t)596);
context::Context foo_context = context::Context("foo_key", static_cast<int64_t>(596));
EXPECT_EQ(nostd::get<int64_t>(context::RuntimeContext::GetValue("foo_key", &foo_context)), 596);
}

Expand All @@ -114,7 +115,7 @@ TEST(RuntimeContextTest, DetachOutOfOrder)
std::vector<context::Context> contexts;
for (auto i : indices)
{
contexts.push_back(context::Context("index", (int64_t)i));
contexts.push_back(context::Context("index", static_cast<int64_t>(i)));
}

do
Expand Down
4 changes: 2 additions & 2 deletions api/test/nostd/span_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,10 @@ TEST(SpanTest, Iteration)
std::array<int, 3> array = {1, 2, 3};

span<int> s1{array.data(), array.size()};
EXPECT_EQ(std::distance(s1.begin(), s1.end()), (ptrdiff_t)array.size());
EXPECT_EQ(std::distance(s1.begin(), s1.end()), static_cast<ptrdiff_t>(array.size()));
EXPECT_TRUE(std::equal(s1.begin(), s1.end(), array.begin()));

span<int, 3> s2{array.data(), array.size()};
EXPECT_EQ(std::distance(s2.begin(), s2.end()), (ptrdiff_t)array.size());
EXPECT_EQ(std::distance(s2.begin(), s2.end()), static_cast<ptrdiff_t>(array.size()));
EXPECT_TRUE(std::equal(s2.begin(), s2.end(), array.begin()));
}
4 changes: 2 additions & 2 deletions api/test/singleton/singleton_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void do_something()
void *component_g = dlopen("libcomponent_g.so", RTLD_NOW);
EXPECT_NE(component_g, nullptr);

auto *func_g = (void (*)())dlsym(component_g, "do_something_in_g");
auto *func_g = reinterpret_cast<void (*)()>(dlsym(component_g, "do_something_in_g"));
EXPECT_NE(func_g, nullptr);

(*func_g)();
Expand All @@ -67,7 +67,7 @@ void do_something()
void *component_h = dlopen("libcomponent_h.so", RTLD_NOW);
EXPECT_NE(component_h, nullptr);

auto *func_h = (void (*)())dlsym(component_h, "do_something_in_h");
auto *func_h = reinterpret_cast<void (*)()>(dlsym(component_h, "do_something_in_h"));
EXPECT_NE(func_h, nullptr);

(*func_h)();
Expand Down
13 changes: 13 additions & 0 deletions bazel/repository.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,16 @@ def opentelemetry_cpp_deps():
"https:/opentracing/opentracing-cpp/archive/refs/tags/v1.6.0.tar.gz",
],
)

# Zlib (optional)
maybe(
http_archive,
name = "zlib",
build_file = "@io_opentelemetry_cpp//bazel:zlib.BUILD",
sha256 = "d14c38e313afc35a9a8760dadf26042f51ea0f5d154b0630a31da0540107fb98",
strip_prefix = "zlib-1.2.13",
urls = [
"https:/madler/zlib/releases/download/v1.2.13/zlib-1.2.13.tar.xz",
"https://zlib.net/zlib-1.2.13.tar.xz",
],
)
Loading

0 comments on commit d80f3e2

Please sign in to comment.