Skip to content

Commit

Permalink
Merge branch 'main' into fix-include-for-f38
Browse files Browse the repository at this point in the history
  • Loading branch information
marcalff authored May 20, 2023
2 parents 81c722c + 23dfc20 commit 1d068ff
Show file tree
Hide file tree
Showing 133 changed files with 1,847 additions and 402 deletions.
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.2.0
5.4.1
16 changes: 16 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,22 @@ jobs:
sudo ./ci/setup_grpc.sh
./ci/do_ci.sh cmake.do_not_install.test
cmake_otprotocol_shared_libs_with_static_grpc_test:
name: CMake test (build shared libraries with otlp-exporter and static gRPC)
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: setup
run: |
sudo ./ci/setup_cmake.sh
sudo ./ci/setup_ci_environment.sh
- name: run otlp exporter tests
run: |
sudo ./ci/setup_grpc.sh -T
./ci/do_ci.sh cmake.exporter.otprotocol.shared_libs.with_static_grpc.test
plugin_test:
name: Plugin -> CMake
runs-on: ubuntu-latest
Expand Down
22 changes: 21 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,26 @@ Increment the:

## [Unreleased]

* [SDK] SDK support for the new OTel log
[#2123](https:/open-telemetry/opentelemetry-cpp/pull/2123)
* [BUILD] Build break with old curl, macro CURL_VERSION_BITS unknown
[#2102](https:/open-telemetry/opentelemetry-cpp/pull/2102)
* [BUILD] Add opentelemetry_proto_grpc and allow build shared opentelemetry_proto
and opentelemetry_proto_grpc on non-Windows platform.
[#2097](https:/open-telemetry/opentelemetry-cpp/pull/2097)
* [API] Add user facing Logging API and Benchmarks
[#2094](https:/open-telemetry/opentelemetry-cpp/pull/2094)

Breaking changes:

* Add opentelemetry_proto_grpc and move gRPC sources into it.
[#2097](https:/open-telemetry/opentelemetry-cpp/pull/2097)
* There will be no breaking changes for users who only use OTLP exporters and
do not directly use opentelemetry-cpp::proto. However, it is important to
note that `opentelemetry-cpp::proto` no longer contains generated gRPC codes
, and all components that depend on these gRPC codes should also link to
`opentelemetry-cpp::proto_grpc`.

Deprecations:

* The Jaeger Exporter is deprecated, see [DEPRECATED](./DEPRECATED.md) for details.
Expand Down Expand Up @@ -462,7 +482,7 @@ update the semantic convention in instrumentation library is needed.
* [BUILD] Don't require applications using jaeger exporter to know about libcurl
[#1518](https:/open-telemetry/opentelemetry-cpp/pull/1518)
* [EXPORTER] Inline print_value() in ostream exporter [#1512](https:/open-telemetry/opentelemetry-cpp/pull/1512)
* [SDK] fix: urlPaser will incorrect parsing url like "http://abc.com/xxx@xxx/a/b"
* [SDK] fix: urlPaser will incorrect parsing url like `http://abc.com/xxx@xxx/a/b`
[#1511](https:/open-telemetry/opentelemetry-cpp/pull/1511)
* [SDK] Rename `InstrumentationLibrary` to `InstrumentationScope` [#1507](https:/open-telemetry/opentelemetry-cpp/pull/1507)
* [BUILD] Try to build nlohmann-json only it's depended. [#1505](https:/open-telemetry/opentelemetry-cpp/pull/1505)
Expand Down
22 changes: 22 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,13 @@ endif()

option(WITH_OTLP "Whether to include the OpenTelemetry Protocol in the SDK" OFF)

if(WITH_OTLP)
message(
WARNING
"WITH_OTLP is deprecated and will be removed in future. Please set either WITH_OTLP_GRPC or WITH_OTLP_HTTP, or even both."
)
endif()

option(WITH_OTLP_HTTP "Whether to include the OTLP http exporter in the SDK"
OFF)

Expand Down Expand Up @@ -188,6 +195,13 @@ option(OTELCPP_MAINTAINER_MODE "Build in maintainer mode (-Wall -Werror)" OFF)

option(WITH_OPENTRACING "Whether to include the Opentracing shim" OFF)

option(OTELCPP_VERSIONED_LIBS "Whether to generate the versioned shared libs"
OFF)

if(OTELCPP_VERSIONED_LIBS AND NOT BUILD_SHARED_LIBS)
message(FATAL_ERROR "OTELCPP_VERSIONED_LIBS=ON requires BUILD_SHARED_LIBS=ON")
endif()

set(OTELCPP_PROTO_PATH
""
CACHE PATH "Path to opentelemetry-proto")
Expand Down Expand Up @@ -267,6 +281,14 @@ function(install_windows_deps)
PARENT_SCOPE)
endfunction()

function(set_target_version target_name)
if(OTELCPP_VERSIONED_LIBS)
set_target_properties(
${target_name} PROPERTIES VERSION ${OPENTELEMETRY_VERSION}
SOVERSION ${OPENTELEMETRY_ABI_VERSION_NO})
endif()
endfunction()

if(WITH_JAEGER)
if(WITH_NO_DEPRECATED_CODE)
message(FATAL_ERROR "Jaeger is DEPRECATED.")
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,13 @@ For edit access, get in touch on

* [Ehsan Saei](https:/esigo)
* [Lalit Kumar Bhasin](https:/lalitb), Microsoft
* [Marc Alff](https:/marcalff), Oracle
* [Tom Tan](https:/ThomsonTan), Microsoft

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

* [Josh Suereth](https:/jsuereth), Google
* [Marc Alff](https:/marcalff), Oracle
* [Reiley Yang](https:/reyang), Microsoft
* [WenTao Ou](https:/owent), Tencent

Expand Down
10 changes: 4 additions & 6 deletions api/include/opentelemetry/baggage/baggage.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,12 @@ class OPENTELEMETRY_EXPORT Baggage
static constexpr char kMembersSeparator = ',';
static constexpr char kMetadataSeparator = ';';

Baggage() noexcept : kv_properties_(new opentelemetry::common::KeyValueProperties()) {}
Baggage(size_t size) noexcept
: kv_properties_(new opentelemetry::common::KeyValueProperties(size))
{}
Baggage() noexcept : kv_properties_(new common::KeyValueProperties()) {}
Baggage(size_t size) noexcept : kv_properties_(new common::KeyValueProperties(size)) {}

template <class T>
Baggage(const T &keys_and_values) noexcept
: kv_properties_(new opentelemetry::common::KeyValueProperties(keys_and_values))
: kv_properties_(new common::KeyValueProperties(keys_and_values))
{}

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

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

} // namespace baggage
Expand Down
15 changes: 6 additions & 9 deletions api/include/opentelemetry/baggage/baggage_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,19 @@ namespace baggage

static const std::string kBaggageHeader = "baggage";

inline nostd::shared_ptr<opentelemetry::baggage::Baggage> GetBaggage(
const opentelemetry::context::Context &context) noexcept
inline nostd::shared_ptr<Baggage> GetBaggage(const context::Context &context) noexcept
{
context::ContextValue context_value = context.GetValue(kBaggageHeader);
if (nostd::holds_alternative<nostd::shared_ptr<opentelemetry::baggage::Baggage>>(context_value))
if (nostd::holds_alternative<nostd::shared_ptr<Baggage>>(context_value))
{
return nostd::get<nostd::shared_ptr<opentelemetry::baggage::Baggage>>(context_value);
return nostd::get<nostd::shared_ptr<Baggage>>(context_value);
}
static nostd::shared_ptr<opentelemetry::baggage::Baggage> empty_baggage{
new opentelemetry::baggage::Baggage()};
static nostd::shared_ptr<Baggage> empty_baggage{new Baggage()};
return empty_baggage;
}

inline context::Context SetBaggage(
opentelemetry::context::Context &context,
nostd::shared_ptr<opentelemetry::baggage::Baggage> baggage) noexcept
inline context::Context SetBaggage(context::Context &context,
nostd::shared_ptr<Baggage> baggage) noexcept
{
return context.SetValue(kBaggageHeader, baggage);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,29 @@ namespace baggage
namespace propagation
{

class BaggagePropagator : public opentelemetry::context::propagation::TextMapPropagator
class BaggagePropagator : public context::propagation::TextMapPropagator
{
public:
void Inject(opentelemetry::context::propagation::TextMapCarrier &carrier,
const opentelemetry::context::Context &context) noexcept override
void Inject(context::propagation::TextMapCarrier &carrier,
const context::Context &context) noexcept override
{
auto baggage = opentelemetry::baggage::GetBaggage(context);
auto baggage = baggage::GetBaggage(context);
auto header = baggage->ToHeader();
if (header.size())
{
carrier.Set(kBaggageHeader, header);
}
}

context::Context Extract(const opentelemetry::context::propagation::TextMapCarrier &carrier,
opentelemetry::context::Context &context) noexcept override
context::Context Extract(const context::propagation::TextMapCarrier &carrier,
context::Context &context) noexcept override
{
nostd::string_view baggage_str = carrier.Get(opentelemetry::baggage::kBaggageHeader);
auto baggage = opentelemetry::baggage::Baggage::FromHeader(baggage_str);
nostd::string_view baggage_str = carrier.Get(baggage::kBaggageHeader);
auto baggage = baggage::Baggage::FromHeader(baggage_str);

if (baggage->ToHeader().size())
{
return opentelemetry::baggage::SetBaggage(context, baggage);
return baggage::SetBaggage(context, baggage);
}
else
{
Expand Down
1 change: 1 addition & 0 deletions api/include/opentelemetry/common/key_value_iterable.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include "opentelemetry/common/attribute_value.h"
#include "opentelemetry/nostd/function_ref.h"
#include "opentelemetry/nostd/string_view.h"
#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
Expand Down
2 changes: 1 addition & 1 deletion api/include/opentelemetry/common/key_value_iterable_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
#pragma once

#include <iterator>
#include <type_traits>
#include <utility>

#include "opentelemetry/common/key_value_iterable.h"
#include "opentelemetry/nostd/function_ref.h"
#include "opentelemetry/nostd/span.h"
#include "opentelemetry/nostd/string_view.h"
#include "opentelemetry/nostd/type_traits.h"
Expand Down
1 change: 0 additions & 1 deletion api/include/opentelemetry/common/kv_properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "opentelemetry/common/key_value_iterable_view.h"
#include "opentelemetry/common/string_util.h"
#include "opentelemetry/nostd/function_ref.h"
#include "opentelemetry/nostd/shared_ptr.h"
#include "opentelemetry/nostd/string_view.h"
#include "opentelemetry/nostd/unique_ptr.h"
#include "opentelemetry/version.h"
Expand Down
26 changes: 26 additions & 0 deletions api/include/opentelemetry/common/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# define OPENTELEMETRY_LIKELY_IF(...) \
if (__VA_ARGS__) \
[[likely]]

# endif
# endif
#endif
Expand Down Expand Up @@ -176,6 +177,31 @@ point.

#endif

//
// Atomic wrappers based on compiler intrinsics for memory read/write.
// The tailing number is read/write length in bits.
//
// N.B. Compiler instrinsic is used because the usage of C++ standard library is restricted in the
// OpenTelemetry C++ API.
//
#if defined(__GNUC__)

# define OPENTELEMETRY_ATOMIC_READ_8(ptr) __atomic_load_n(ptr, __ATOMIC_SEQ_CST)
# define OPENTELEMETRY_ATOMIC_WRITE_8(ptr, value) __atomic_store_n(ptr, value, __ATOMIC_SEQ_CST)

#elif defined(_MSC_VER)

# include <intrin.h>

# define OPENTELEMETRY_ATOMIC_READ_8(ptr) \
static_cast<uint8_t>(_InterlockedCompareExchange8(reinterpret_cast<char *>(ptr), 0, 0))
# define OPENTELEMETRY_ATOMIC_WRITE_8(ptr, value) \
_InterlockedExchange8(reinterpret_cast<char *>(ptr), static_cast<char>(value))

#else
# error port atomics read/write for the current platform
#endif

/* clang-format on */
//
// The if/elif order matters here. If both OPENTELEMETRY_BUILD_IMPORT_DLL and
Expand Down
1 change: 1 addition & 0 deletions api/include/opentelemetry/common/string_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#pragma once

#include "opentelemetry/nostd/string_view.h"
#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace common
Expand Down
1 change: 0 additions & 1 deletion api/include/opentelemetry/common/timestamp.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

#pragma once

#include <algorithm>
#include <chrono>
#include <cstdint>

Expand Down
1 change: 1 addition & 0 deletions api/include/opentelemetry/context/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "opentelemetry/context/context_value.h"
#include "opentelemetry/nostd/shared_ptr.h"
#include "opentelemetry/nostd/string_view.h"
#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace context
Expand Down
16 changes: 11 additions & 5 deletions api/include/opentelemetry/context/context_value.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,22 @@

#include <cstdint>

#include "opentelemetry/baggage/baggage.h"
#include "opentelemetry/nostd/shared_ptr.h"
#include "opentelemetry/nostd/span.h"
#include "opentelemetry/nostd/unique_ptr.h"
#include "opentelemetry/nostd/variant.h"
#include "opentelemetry/trace/span.h"
#include "opentelemetry/trace/span_context.h"
#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace baggage
{
class Baggage;
} // namespace baggage

namespace trace
{
class Span;
class SpanContext;
} // namespace trace

namespace context
{
using ContextValue = nostd::variant<nostd::monostate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@

#pragma once

#include <initializer_list>
#include <memory>
#include <vector>

#include "opentelemetry/context/propagation/text_map_propagator.h"
#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include <mutex>

#include "opentelemetry/context/propagation/noop_propagator.h"
#include "opentelemetry/context/propagation/text_map_propagator.h"

#include "opentelemetry/common/macros.h"
#include "opentelemetry/common/spin_lock_mutex.h"
Expand All @@ -20,6 +19,8 @@ namespace context
namespace propagation
{

class TextMapPropagator;

/* Stores the singleton TextMapPropagator */

class OPENTELEMETRY_EXPORT GlobalTextMapPropagator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

#pragma once

#include <cstdint>
#include "opentelemetry/context/context.h"
#include "opentelemetry/nostd/function_ref.h"
#include "opentelemetry/nostd/string_view.h"
#include "opentelemetry/version.h"

Expand Down
4 changes: 4 additions & 0 deletions api/include/opentelemetry/context/runtime_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@

#include "opentelemetry/common/macros.h"
#include "opentelemetry/context/context.h"
#include "opentelemetry/nostd/shared_ptr.h"
#include "opentelemetry/nostd/string_view.h"
#include "opentelemetry/nostd/unique_ptr.h"
#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace context
Expand Down
Loading

0 comments on commit 1d068ff

Please sign in to comment.