Skip to content

Commit 0aebd6e

Browse files
authored
Merge main into async changes (open-telemetry#1395)
1 parent 08a12b5 commit 0aebd6e

77 files changed

Lines changed: 1795 additions & 458 deletions

File tree

Some content is hidden

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

.github/.codecov.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,10 @@ comment:
3333
# to coverage report file paths.
3434
fixes:
3535
- "/home/runner/::"
36+
37+
ignore:
38+
- "docs/**/*"
39+
- "docker/**/*"
40+
- "examples/**/*"
41+
- "**/test/**/*"
42+
- "**.md"

.github/workflows/codeql-analysis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ jobs:
2323
sudo ./ci/setup_cmake.sh
2424
sudo ./ci/setup_ci_environment.sh
2525
- name: Initialize CodeQL
26-
uses: github/codeql-action/init@v1
26+
uses: github/codeql-action/init@v2
2727
with:
2828
languages: cpp
2929
- name: Autobuild
30-
uses: github/codeql-action/autobuild@v1
30+
uses: github/codeql-action/autobuild@v2
3131
- name: Perform CodeQL Analysis
32-
uses: github/codeql-action/analyze@v1
32+
uses: github/codeql-action/analyze@v2

.github/workflows/dependencies_image.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ jobs:
1414
uses: actions/checkout@v2
1515
-
1616
name: Set up QEMU
17-
uses: docker/setup-qemu-action@v1
17+
uses: docker/setup-qemu-action@v2
1818
-
1919
name: Set up Docker Buildx
2020
id: buildx
21-
uses: docker/setup-buildx-action@v1
21+
uses: docker/setup-buildx-action@v2
2222
-
2323
name: Build Image
24-
uses: docker/build-push-action@v2
24+
uses: docker/build-push-action@v3
2525
with:
2626
builder: ${{ steps.buildx.outputs.name }}
2727
context: ci/

CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,10 @@ if(WITH_PROMETHEUS)
275275
if(NOT prometheus-cpp_FOUND)
276276
message("Trying to use local prometheus-cpp from submodule")
277277
if(EXISTS ${PROJECT_SOURCE_DIR}/third_party/prometheus-cpp/.git)
278+
set(SAVED_ENABLE_TESTING ${ENABLE_TESTING})
279+
set(ENABLE_TESTING OFF)
278280
add_subdirectory(third_party/prometheus-cpp)
281+
set(ENABLE_TESTING ${SAVED_ENABLE_TESTING})
279282
else()
280283
message(
281284
FATAL_ERROR
@@ -362,7 +365,7 @@ if(BUILD_TESTING)
362365
${CMAKE_BINARY_DIR}/lib/libgmock.a)
363366
elseif(WIN32)
364367
# Make sure we are always bootsrapped with vcpkg on Windows
365-
find_package(GTest)
368+
find_package(GTest REQUIRED)
366369
if(NOT (GTEST_FOUND OR GTest_FOUND))
367370
install_windows_deps()
368371
find_package(GTest REQUIRED)

api/include/opentelemetry/baggage/baggage.h

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@ class Baggage
2525
static constexpr char kMembersSeparator = ',';
2626
static constexpr char kMetadataSeparator = ';';
2727

28-
Baggage() : kv_properties_(new opentelemetry::common::KeyValueProperties()) {}
29-
Baggage(size_t size) : kv_properties_(new opentelemetry::common::KeyValueProperties(size)){};
28+
Baggage() noexcept : kv_properties_(new opentelemetry::common::KeyValueProperties()) {}
29+
Baggage(size_t size) noexcept
30+
: kv_properties_(new opentelemetry::common::KeyValueProperties(size)){};
3031

3132
template <class T>
32-
Baggage(const T &keys_and_values)
33+
Baggage(const T &keys_and_values) noexcept
3334
: kv_properties_(new opentelemetry::common::KeyValueProperties(keys_and_values))
3435
{}
3536

@@ -42,15 +43,16 @@ class Baggage
4243
/* Get value for key in the baggage
4344
@returns true if key is found, false otherwise
4445
*/
45-
bool GetValue(nostd::string_view key, std::string &value) const
46+
bool GetValue(nostd::string_view key, std::string &value) const noexcept
4647
{
4748
return kv_properties_->GetValue(key, value);
4849
}
4950

5051
/* Returns shared_ptr of new baggage object which contains new key-value pair. If key or value is
5152
invalid, copy of current baggage is returned
5253
*/
53-
nostd::shared_ptr<Baggage> Set(const nostd::string_view &key, const nostd::string_view &value)
54+
nostd::shared_ptr<Baggage> Set(const nostd::string_view &key,
55+
const nostd::string_view &value) noexcept
5456
{
5557

5658
nostd::shared_ptr<Baggage> baggage(new Baggage(kv_properties_->Size() + 1));
@@ -89,7 +91,7 @@ class Baggage
8991
// if key does not exist, copy of current baggage is returned.
9092
// Validity of key is not checked as invalid keys should never be populated in baggage in the
9193
// first place.
92-
nostd::shared_ptr<Baggage> Delete(nostd::string_view key)
94+
nostd::shared_ptr<Baggage> Delete(nostd::string_view key) noexcept
9395
{
9496
// keeping size of baggage same as key might not be found in it
9597
nostd::shared_ptr<Baggage> baggage(new Baggage(kv_properties_->Size()));
@@ -103,7 +105,7 @@ class Baggage
103105
}
104106

105107
// Returns shared_ptr of baggage after extracting key-value pairs from header
106-
static nostd::shared_ptr<Baggage> FromHeader(nostd::string_view header)
108+
static nostd::shared_ptr<Baggage> FromHeader(nostd::string_view header) noexcept
107109
{
108110
if (header.size() > kMaxSize)
109111
{
@@ -158,7 +160,7 @@ class Baggage
158160
}
159161

160162
// Creates string from baggage object.
161-
std::string ToHeader() const
163+
std::string ToHeader() const noexcept
162164
{
163165
std::string header_s;
164166
bool first = true;
@@ -249,7 +251,9 @@ class Baggage
249251
};
250252

251253
auto from_hex = [](char c) -> char {
252-
return std::isdigit(c) ? c - '0' : std::toupper(c) - 'A' + 10;
254+
// c - '0' produces integer type which could trigger error/warning when casting to char,
255+
// but the cast is safe here.
256+
return static_cast<char>(std::isdigit(c) ? c - '0' : std::toupper(c) - 'A' + 10);
253257
};
254258

255259
std::string ret;

api/include/opentelemetry/baggage/baggage_context.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace baggage
1616
static const std::string kBaggageHeader = "baggage";
1717

1818
inline nostd::shared_ptr<opentelemetry::baggage::Baggage> GetBaggage(
19-
const opentelemetry::context::Context &context)
19+
const opentelemetry::context::Context &context) noexcept
2020
{
2121
context::ContextValue context_value = context.GetValue(kBaggageHeader);
2222
if (nostd::holds_alternative<nostd::shared_ptr<opentelemetry::baggage::Baggage>>(context_value))
@@ -28,8 +28,9 @@ inline nostd::shared_ptr<opentelemetry::baggage::Baggage> GetBaggage(
2828
return empty_baggage;
2929
}
3030

31-
inline context::Context SetBaggage(opentelemetry::context::Context &context,
32-
nostd::shared_ptr<opentelemetry::baggage::Baggage> baggage)
31+
inline context::Context SetBaggage(
32+
opentelemetry::context::Context &context,
33+
nostd::shared_ptr<opentelemetry::baggage::Baggage> baggage) noexcept
3334
{
3435
return context.SetValue(kBaggageHeader, baggage);
3536
}

api/include/opentelemetry/baggage/propagation/baggage_propagator.h

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,27 @@ class BaggagePropagator : public opentelemetry::context::propagation::TextMapPro
2121
const opentelemetry::context::Context &context) noexcept override
2222
{
2323
auto baggage = opentelemetry::baggage::GetBaggage(context);
24-
carrier.Set(kBaggageHeader, baggage->ToHeader());
24+
auto header = baggage->ToHeader();
25+
if (header.size())
26+
{
27+
carrier.Set(kBaggageHeader, header);
28+
}
2529
}
2630

2731
context::Context Extract(const opentelemetry::context::propagation::TextMapCarrier &carrier,
2832
opentelemetry::context::Context &context) noexcept override
2933
{
3034
nostd::string_view baggage_str = carrier.Get(opentelemetry::baggage::kBaggageHeader);
3135
auto baggage = opentelemetry::baggage::Baggage::FromHeader(baggage_str);
32-
return opentelemetry::baggage::SetBaggage(context, baggage);
36+
37+
if (baggage->ToHeader().size())
38+
{
39+
return opentelemetry::baggage::SetBaggage(context, baggage);
40+
}
41+
else
42+
{
43+
return context;
44+
}
3345
}
3446

3547
bool Fields(nostd::function_ref<bool(nostd::string_view)> callback) const noexcept override

api/include/opentelemetry/common/kv_properties.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class KeyValueStringTokenizer
3333
public:
3434
KeyValueStringTokenizer(
3535
nostd::string_view str,
36-
const KeyValueStringTokenizerOptions &opts = KeyValueStringTokenizerOptions())
36+
const KeyValueStringTokenizerOptions &opts = KeyValueStringTokenizerOptions()) noexcept
3737
: str_(str), opts_(opts), index_(0)
3838
{}
3939

@@ -48,7 +48,7 @@ class KeyValueStringTokenizer
4848
// @param key : key in kv pair
4949
// @param key : value in kv pair
5050
// @returns true if next kv pair was found, false otherwise.
51-
bool next(bool &valid_kv, nostd::string_view &key, nostd::string_view &value)
51+
bool next(bool &valid_kv, nostd::string_view &key, nostd::string_view &value) noexcept
5252
{
5353
valid_kv = true;
5454
while (index_ < str_.size())
@@ -170,13 +170,13 @@ class KeyValueProperties
170170
}
171171

172172
// Gets the key associated with this entry.
173-
nostd::string_view GetKey() const { return key_.get(); }
173+
nostd::string_view GetKey() const noexcept { return key_.get(); }
174174

175175
// Gets the value associated with this entry.
176-
nostd::string_view GetValue() const { return value_.get(); }
176+
nostd::string_view GetValue() const noexcept { return value_.get(); }
177177

178178
// Sets the value for this entry. This overrides the previous value.
179-
void SetValue(nostd::string_view value) { value_ = CopyStringToPointer(value); }
179+
void SetValue(nostd::string_view value) noexcept { value_ = CopyStringToPointer(value); }
180180

181181
private:
182182
// Store key and value as raw char pointers to avoid using std::string.
@@ -206,15 +206,15 @@ class KeyValueProperties
206206
public:
207207
// Create Key-value list of given size
208208
// @param size : Size of list.
209-
KeyValueProperties(size_t size)
209+
KeyValueProperties(size_t size) noexcept
210210
: num_entries_(0), max_num_entries_(size), entries_(new Entry[size])
211211
{}
212212

213213
// Create Empty Key-Value list
214-
KeyValueProperties() : num_entries_(0), max_num_entries_(0), entries_(nullptr) {}
214+
KeyValueProperties() noexcept : num_entries_(0), max_num_entries_(0), entries_(nullptr) {}
215215

216216
template <class T, class = typename std::enable_if<detail::is_key_value_iterable<T>::value>::type>
217-
KeyValueProperties(const T &keys_and_values)
217+
KeyValueProperties(const T &keys_and_values) noexcept
218218
: num_entries_(0),
219219
max_num_entries_(keys_and_values.size()),
220220
entries_(new Entry[max_num_entries_])
@@ -227,7 +227,7 @@ class KeyValueProperties
227227
}
228228

229229
// Adds new kv pair into kv properties
230-
void AddEntry(nostd::string_view key, nostd::string_view value)
230+
void AddEntry(nostd::string_view key, nostd::string_view value) noexcept
231231
{
232232
if (num_entries_ < max_num_entries_)
233233
{
@@ -238,7 +238,7 @@ class KeyValueProperties
238238

239239
// Returns all kv pair entries
240240
bool GetAllEntries(
241-
nostd::function_ref<bool(nostd::string_view, nostd::string_view)> callback) const
241+
nostd::function_ref<bool(nostd::string_view, nostd::string_view)> callback) const noexcept
242242
{
243243
for (size_t i = 0; i < num_entries_; i++)
244244
{
@@ -252,7 +252,7 @@ class KeyValueProperties
252252
}
253253

254254
// Return value for key if exists, return false otherwise
255-
bool GetValue(nostd::string_view key, std::string &value) const
255+
bool GetValue(nostd::string_view key, std::string &value) const noexcept
256256
{
257257
for (size_t i = 0; i < num_entries_; i++)
258258
{

api/include/opentelemetry/common/string_util.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace common
2626
class StringUtil
2727
{
2828
public:
29-
static nostd::string_view Trim(nostd::string_view str, size_t left, size_t right)
29+
static nostd::string_view Trim(nostd::string_view str, size_t left, size_t right) noexcept
3030
{
3131
while (str[static_cast<std::size_t>(left)] == ' ' && left <= right)
3232
{
@@ -39,7 +39,7 @@ class StringUtil
3939
return str.substr(left, 1 + right - left);
4040
}
4141

42-
static nostd::string_view Trim(nostd::string_view str)
42+
static nostd::string_view Trim(nostd::string_view str) noexcept
4343
{
4444
if (str.empty())
4545
{

api/include/opentelemetry/context/context.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ class Context
2424
// Creates a context object from a map of keys and identifiers, this will
2525
// hold a shared_ptr to the head of the DataList linked list
2626
template <class T>
27-
Context(const T &keys_and_values)
27+
Context(const T &keys_and_values) noexcept
2828
{
2929
head_ = nostd::shared_ptr<DataList>{new DataList(keys_and_values)};
3030
}
3131

3232
// Creates a context object from a key and value, this will
3333
// hold a shared_ptr to the head of the DataList linked list
34-
Context(nostd::string_view key, ContextValue value)
34+
Context(nostd::string_view key, ContextValue value) noexcept
3535
{
3636
head_ = nostd::shared_ptr<DataList>{new DataList(key, value)};
3737
}

0 commit comments

Comments
 (0)