Skip to content

Commit

Permalink
merged from upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
malkia committed Aug 26, 2024
2 parents 40b9475 + a920898 commit 8a59eeb
Show file tree
Hide file tree
Showing 61 changed files with 413 additions and 153 deletions.
3 changes: 3 additions & 0 deletions .iwyu.imp
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@

# Local opentelemetry-cpp

{ "include": ["<gtest/gtest-message.h>", "private", "<gtest/gtest.h>", "public"] },
{ "include": ["<gtest/gtest-test-part.h>", "private", "<gtest/gtest.h>", "public"] },
{ "include": ["<gtest/gtest_pred_impl.h>", "private", "<gtest/gtest.h>", "public"] },
]

Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@

#pragma once

#include <memory>
#include <string>

#include "opentelemetry/version.h"
#include "opentelemetry/baggage/baggage.h"
#include "opentelemetry/baggage/baggage_context.h"
#include "opentelemetry/context/context.h"
#include "opentelemetry/context/propagation/text_map_propagator.h"
#include "opentelemetry/nostd/function_ref.h"
#include "opentelemetry/nostd/string_view.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace baggage
Expand Down
5 changes: 5 additions & 0 deletions api/include/opentelemetry/common/key_value_iterable_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@

#pragma once

#include <stddef.h>
#include <initializer_list>
#include <iterator>
#include <type_traits>
#include <utility>
#include <vector>

#include "opentelemetry/version.h"
#include "opentelemetry/common/attribute_value.h"
#include "opentelemetry/common/key_value_iterable.h"
#include "opentelemetry/nostd/function_ref.h"
#include "opentelemetry/nostd/span.h"
Expand Down
2 changes: 2 additions & 0 deletions api/include/opentelemetry/context/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
#pragma once

#include <cstring>
#include <utility>

#include "opentelemetry/version.h"
#include "opentelemetry/context/context_value.h"
#include "opentelemetry/nostd/shared_ptr.h"
#include "opentelemetry/nostd/string_view.h"
#include "opentelemetry/nostd/variant.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace context
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 @@ -3,9 +3,13 @@

#pragma once

#include <stddef.h>
#include <algorithm>

#include "opentelemetry/version.h"
#include "opentelemetry/common/macros.h"
#include "opentelemetry/context/context.h"
#include "opentelemetry/context/context_value.h"
#include "opentelemetry/nostd/shared_ptr.h"
#include "opentelemetry/nostd/string_view.h"
#include "opentelemetry/nostd/unique_ptr.h"
Expand Down
6 changes: 4 additions & 2 deletions api/include/opentelemetry/nostd/function_ref.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@

#pragma once

#include <memory>
#include <iosfwd>
#include <memory> // IWYU pragma: keep
#include <type_traits>
#include <utility>

#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace nostd
{
template <class Sig>
class function_ref;
class function_ref; // IWYU pragma: keep

/**
* Non-owning function reference that can be used as a more performant
Expand Down
6 changes: 4 additions & 2 deletions api/include/opentelemetry/nostd/string_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@

#if !defined(OPENTELEMETRY_HAVE_STD_STRING_VIEW)
# include <algorithm>
# include <cstddef>
# include <cstring>
# include <functional>
# include <ostream>
# include <stdexcept>
# include <string>
# include <type_traits>
# include <utility>

# include "opentelemetry/common/macros.h"
# include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace nostd
Expand Down
2 changes: 1 addition & 1 deletion api/include/opentelemetry/nostd/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ OPENTELEMETRY_END_NAMESPACE
# ifdef HAVE_ABSEIL
# include "absl/types/variant.h"
# else
# include "./internal/absl/types/variant.h"
# include "opentelemetry/nostd/internal/absl/types/variant.h"
# endif

# ifdef _MSC_VER
Expand Down
4 changes: 2 additions & 2 deletions api/include/opentelemetry/plugin/dynamic_load.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include <string>

#include "opentelemetry/version.h"
#include "opentelemetry/plugin/factory.h"

#ifdef _WIN32
# include "opentelemetry/plugin/detail/dynamic_load_windows.h" // IWYU pragma: export
#else
Expand All @@ -17,8 +19,6 @@ OPENTELEMETRY_BEGIN_NAMESPACE
namespace plugin
{

class Factory;

/**
* Load an OpenTelemetry implementation as a plugin.
* @param plugin the path to the plugin to load
Expand Down
10 changes: 8 additions & 2 deletions api/include/opentelemetry/trace/noop.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,22 @@
// This file is part of the internal implementation of OpenTelemetry. Nothing in this file should be
// used directly. Please refer to span.h and tracer.h for documentation on these interfaces.

#include <memory>
#include <stdint.h>
#include <utility>

#include "opentelemetry/version.h"
#include "opentelemetry/context/runtime_context.h"
#include "opentelemetry/common/attribute_value.h"
#include "opentelemetry/common/key_value_iterable.h"
#include "opentelemetry/common/timestamp.h"
#include "opentelemetry/context/context_value.h"
#include "opentelemetry/nostd/shared_ptr.h"
#include "opentelemetry/nostd/string_view.h"
#include "opentelemetry/nostd/unique_ptr.h"
#include "opentelemetry/trace/span.h"
#include "opentelemetry/trace/span_context.h"
#include "opentelemetry/trace/span_context_kv_iterable.h"
#include "opentelemetry/trace/span_metadata.h"
#include "opentelemetry/trace/span_startoptions.h"
#include "opentelemetry/trace/tracer.h"
#include "opentelemetry/trace/tracer_provider.h"

Expand Down
4 changes: 1 addition & 3 deletions api/include/opentelemetry/trace/provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,15 @@
#include <mutex>

#include "opentelemetry/version.h"
#include "opentelemetry/common/macros.h"
#include "opentelemetry/common/spin_lock_mutex.h"
#include "opentelemetry/nostd/shared_ptr.h"
#include "opentelemetry/trace/noop.h"
#include "opentelemetry/trace/tracer_provider.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace trace
{

class TracerProvider;

/**
* Stores the singleton global TracerProvider.
*/
Expand Down
4 changes: 2 additions & 2 deletions api/include/opentelemetry/trace/scope.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
#pragma once

#include "opentelemetry/version.h"
#include "opentelemetry/context/context.h"
#include "opentelemetry/context/runtime_context.h"
#include "opentelemetry/nostd/shared_ptr.h"
#include "opentelemetry/nostd/unique_ptr.h"
#include "opentelemetry/trace/span.h"
#include "opentelemetry/trace/span_metadata.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace trace
{

class Span;

/**
* Controls how long a span is active.
*
Expand Down
2 changes: 2 additions & 0 deletions api/include/opentelemetry/trace/span_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#pragma once

#include <stdint.h>

#include "opentelemetry/version.h"
#include "opentelemetry/nostd/shared_ptr.h"
#include "opentelemetry/trace/span_id.h"
Expand Down
5 changes: 3 additions & 2 deletions api/include/opentelemetry/trace/trace_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@

#pragma once

#include <cstdint>
#include <ctype.h>
#include <cstddef>
#include <string>
#include <vector>

#include "opentelemetry/version.h"
#include "opentelemetry/common/kv_properties.h"
#include "opentelemetry/nostd/function_ref.h"
#include "opentelemetry/nostd/shared_ptr.h"
#include "opentelemetry/nostd/span.h"
#include "opentelemetry/nostd/string_view.h"
#include "opentelemetry/nostd/unique_ptr.h"

Expand Down
9 changes: 6 additions & 3 deletions api/test/baggage/baggage_benchmark.cc
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#include <benchmark/benchmark.h>
#include <stddef.h>
#include <memory>
#include <string>

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

#include <benchmark/benchmark.h>
#include <cstdint>
#include "opentelemetry/nostd/utility.h"

using namespace opentelemetry::baggage;
namespace nostd = opentelemetry::nostd;
Expand Down
41 changes: 22 additions & 19 deletions api/test/baggage/baggage_test.cc
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#include "opentelemetry/nostd/string_view.h"

#include <assert.h>
#include <gtest/gtest.h>
#include <stddef.h>
#include <string>
#include <vector>

#include "opentelemetry/baggage/baggage.h"
#include "opentelemetry/common/kv_properties.h"
#include "opentelemetry/nostd/shared_ptr.h"
#include "opentelemetry/nostd/string_view.h"

using namespace opentelemetry;
using namespace opentelemetry::baggage;

std::string header_with_custom_entries(size_t num_entries)
Expand Down Expand Up @@ -82,7 +84,8 @@ TEST(BaggageTest, ValidateExtractHeader)
{
auto baggage = Baggage::FromHeader(testcase.input);
size_t index = 0;
baggage->GetAllEntries([&testcase, &index](nostd::string_view key, nostd::string_view value) {
baggage->GetAllEntries([&testcase, &index](opentelemetry::nostd::string_view key,
opentelemetry::nostd::string_view value) {
EXPECT_EQ(key, testcase.keys[index]);
EXPECT_EQ(value, testcase.values[index]);
index++;
Expand All @@ -97,7 +100,7 @@ TEST(BaggageTest, ValidateExtractHeader)
// Entries beyond threshold are dropped
auto baggage = Baggage::FromHeader(header_with_custom_entries(Baggage::kMaxKeyValuePairs + 1));
auto header = baggage->ToHeader();
common::KeyValueStringTokenizer kv_str_tokenizer(header);
opentelemetry::common::KeyValueStringTokenizer kv_str_tokenizer(header);
int expected_tokens = Baggage::kMaxKeyValuePairs;
EXPECT_EQ(kv_str_tokenizer.NumTokens(), expected_tokens);

Expand Down Expand Up @@ -126,7 +129,7 @@ TEST(BaggageTest, ValidateInjectHeader)

for (auto &testcase : testcases)
{
nostd::shared_ptr<Baggage> baggage(new Baggage{});
opentelemetry::nostd::shared_ptr<Baggage> baggage(new Baggage{});
for (size_t i = 0; i < testcase.keys.size(); i++)
{
baggage = baggage->Set(testcase.keys[i], testcase.values[i]);
Expand Down Expand Up @@ -202,17 +205,17 @@ TEST(BaggageTest, BaggageRemove)

TEST(BaggageTest, BaggageGetAll)
{
std::string baggage_header = "k1=v1,k2=v2,k3=v3";
auto baggage = Baggage::FromHeader(baggage_header);
const int kNumPairs = 3;
nostd::string_view keys[kNumPairs] = {"k1", "k2", "k3"};
nostd::string_view values[kNumPairs] = {"v1", "v2", "v3"};
size_t index = 0;
baggage->GetAllEntries(
[&keys, &values, &index](nostd::string_view key, nostd::string_view value) {
EXPECT_EQ(key, keys[index]);
EXPECT_EQ(value, values[index]);
index++;
return true;
});
std::string baggage_header = "k1=v1,k2=v2,k3=v3";
auto baggage = Baggage::FromHeader(baggage_header);
const int kNumPairs = 3;
opentelemetry::nostd::string_view keys[kNumPairs] = {"k1", "k2", "k3"};
opentelemetry::nostd::string_view values[kNumPairs] = {"v1", "v2", "v3"};
size_t index = 0;
baggage->GetAllEntries([&keys, &values, &index](opentelemetry::nostd::string_view key,
opentelemetry::nostd::string_view value) {
EXPECT_EQ(key, keys[index]);
EXPECT_EQ(value, values[index]);
index++;
return true;
});
}
11 changes: 10 additions & 1 deletion api/test/baggage/propagation/baggage_propagator_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,20 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#include "opentelemetry/baggage/propagation/baggage_propagator.h"
#include <gtest/gtest.h>
#include <map>
#include <memory>
#include <string>
#include <utility>
#include <vector>

#include "opentelemetry/baggage/baggage.h"
#include "opentelemetry/baggage/baggage_context.h"
#include "opentelemetry/baggage/propagation/baggage_propagator.h"
#include "opentelemetry/context/context.h"
#include "opentelemetry/context/propagation/text_map_propagator.h"
#include "opentelemetry/nostd/string_view.h"
#include "opentelemetry/nostd/utility.h"

using namespace opentelemetry;
using namespace opentelemetry::baggage::propagation;
Expand Down
7 changes: 5 additions & 2 deletions api/test/common/kv_properties_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
// SPDX-License-Identifier: Apache-2.0

#include <gtest/gtest.h>
#include <opentelemetry/common/kv_properties.h>

#include <stddef.h>
#include <string>
#include <utility>
#include <vector>

#include <opentelemetry/common/kv_properties.h>
#include "opentelemetry/nostd/string_view.h"
#include "opentelemetry/nostd/utility.h"

// ------------------------- Entry class tests ---------------------------------

using namespace opentelemetry;
Expand Down
17 changes: 14 additions & 3 deletions api/test/common/spinlock_benchmark.cc
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#include "opentelemetry/common/spin_lock_mutex.h"

#include <benchmark/benchmark.h>
#include <mutex>
#include <stdint.h>
#include <algorithm>
#include <atomic>
#include <thread>
#include <vector>

#if defined(__i386__) || defined(__x86_64__)
# if defined(__clang__) || defined(__INTEL_COMPILER)
# include <emmintrin.h> // for _mm_pause
# endif
#endif

#include "opentelemetry/common/macros.h"
#include "opentelemetry/common/spin_lock_mutex.h"

namespace
{
Expand Down
Loading

0 comments on commit 8a59eeb

Please sign in to comment.