Skip to content

Commit f23e84e

Browse files
authored
Merge branch 'open-telemetry:main' into feature/update_maintaining_doc
2 parents 70323a4 + 762b73d commit f23e84e

File tree

60 files changed

+354
-220
lines changed

Some content is hidden

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

60 files changed

+354
-220
lines changed

.github/workflows/cppcheck.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,14 @@ jobs:
5656
- name: Count warnings
5757
run: |
5858
set +e
59-
COUNT=`grep -c -E "\[.+\]" cppcheck.log`
60-
echo "cppcheck reported ${COUNT} warning(s)"
61-
# TODO: uncomment to enforce failing the build
62-
# if [ $COUNT -ne 0 ] ; then exit 1 ; fi
59+
readonly WARNING_COUNT=`grep -c -E "\[.+\]" cppcheck.log`
60+
echo "cppcheck reported ${WARNING_COUNT} warning(s)"
61+
# Acceptable limit, to decrease over time down to 0
62+
readonly WARNING_LIMIT=10
63+
# FAIL the build if WARNING_COUNT > WARNING_LIMIT
64+
if [ $WARNING_COUNT -gt $WARNING_LIMIT ] ; then
65+
exit 1
66+
# WARN in annotations if WARNING_COUNT > 0
67+
elif [ $WARNING_COUNT -gt 0 ] ; then
68+
echo "::warning::cppcheck reported ${WARNING_COUNT} warning(s)"
69+
fi

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ Increment the:
149149
* [bazel] Update opentelemetry-proto in MODULE.bazel
150150
[#3163](https://github.com/open-telemetry/opentelemetry-cpp/pull/3163)
151151

152+
* [EXPORTER] Fix scope attributes missing from otlp traces metrics
153+
[#3185](https://github.com/open-telemetry/opentelemetry-cpp/pull/3185)
154+
152155
Important changes:
153156

154157
* [API] Jaeger Propagator should not be deprecated

CMakeLists.txt

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -428,12 +428,16 @@ if(WITH_OTLP_GRPC
428428
endif()
429429
# Latest Protobuf imported targets and without legacy module support
430430
if(TARGET protobuf::protoc)
431-
project_build_tools_get_imported_location(PROTOBUF_PROTOC_EXECUTABLE
432-
protobuf::protoc)
433-
# If protobuf::protoc is not a imported target, then we use the target
434-
# directly for fallback
435-
if(NOT PROTOBUF_PROTOC_EXECUTABLE)
436-
set(PROTOBUF_PROTOC_EXECUTABLE protobuf::protoc)
431+
if(CMAKE_CROSSCOMPILING AND Protobuf_PROTOC_EXECUTABLE)
432+
set(PROTOBUF_PROTOC_EXECUTABLE ${Protobuf_PROTOC_EXECUTABLE})
433+
else()
434+
project_build_tools_get_imported_location(PROTOBUF_PROTOC_EXECUTABLE
435+
protobuf::protoc)
436+
# If protobuf::protoc is not a imported target, then we use the target
437+
# directly for fallback
438+
if(NOT PROTOBUF_PROTOC_EXECUTABLE)
439+
set(PROTOBUF_PROTOC_EXECUTABLE protobuf::protoc)
440+
endif()
437441
endif()
438442
elseif(Protobuf_PROTOC_EXECUTABLE)
439443
# Some versions of FindProtobuf.cmake uses mixed case instead of uppercase

api/include/opentelemetry/baggage/baggage_context.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ inline nostd::shared_ptr<Baggage> GetBaggage(const context::Context &context) no
2727
}
2828

2929
inline context::Context SetBaggage(context::Context &context,
30-
nostd::shared_ptr<Baggage> baggage) noexcept
30+
const nostd::shared_ptr<Baggage> &baggage) noexcept
3131
{
3232
return context.SetValue(kBaggageHeader, baggage);
3333
}

api/include/opentelemetry/context/context.h

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,14 @@ class Context
2929
// hold a shared_ptr to the head of the DataList linked list
3030
template <class T>
3131
Context(const T &keys_and_values) noexcept
32-
{
33-
head_ = nostd::shared_ptr<DataList>{new DataList(keys_and_values)};
34-
}
32+
: head_{nostd::shared_ptr<DataList>{new DataList(keys_and_values)}}
33+
{}
3534

3635
// Creates a context object from a key and value, this will
3736
// hold a shared_ptr to the head of the DataList linked list
3837
Context(nostd::string_view key, ContextValue value) noexcept
39-
{
40-
head_ = nostd::shared_ptr<DataList>{new DataList(key, value)};
41-
}
38+
: head_{nostd::shared_ptr<DataList>{new DataList(key, value)}}
39+
{}
4240

4341
// Accepts a new iterable and then returns a new context that
4442
// contains the new key and value data. It attaches the
@@ -92,22 +90,21 @@ class Context
9290

9391
private:
9492
// A linked list to contain the keys and values of this context node
95-
class DataList
93+
struct DataList
9694
{
97-
public:
98-
char *key_;
95+
char *key_ = nullptr;
9996

100-
nostd::shared_ptr<DataList> next_;
97+
nostd::shared_ptr<DataList> next_{nullptr};
10198

102-
size_t key_length_;
99+
size_t key_length_ = 0UL;
103100

104101
ContextValue value_;
105102

106-
DataList() { next_ = nullptr; }
103+
DataList() = default;
107104

108105
// Builds a data list off of a key and value iterable and returns the head
109106
template <class T>
110-
DataList(const T &keys_and_vals) : key_{nullptr}, next_(nostd::shared_ptr<DataList>{nullptr})
107+
DataList(const T &keys_and_vals)
111108
{
112109
bool first = true;
113110
auto *node = this;
@@ -132,9 +129,18 @@ class Context
132129
{
133130
key_ = new char[key.size()];
134131
key_length_ = key.size();
135-
memcpy(key_, key.data(), key.size() * sizeof(char));
136-
value_ = value;
132+
std::memcpy(key_, key.data(), key.size() * sizeof(char));
137133
next_ = nostd::shared_ptr<DataList>{nullptr};
134+
value_ = value;
135+
}
136+
137+
DataList(const DataList &other)
138+
: key_(new char[other.key_length_]),
139+
next_(other.next_),
140+
key_length_(other.key_length_),
141+
value_(other.value_)
142+
{
143+
std::memcpy(key_, other.key_, other.key_length_ * sizeof(char));
138144
}
139145

140146
DataList &operator=(DataList &&other) noexcept

api/include/opentelemetry/context/propagation/global_propagator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class OPENTELEMETRY_EXPORT GlobalTextMapPropagator
3232
return nostd::shared_ptr<TextMapPropagator>(GetPropagator());
3333
}
3434

35-
static void SetGlobalPropagator(nostd::shared_ptr<TextMapPropagator> prop) noexcept
35+
static void SetGlobalPropagator(const nostd::shared_ptr<TextMapPropagator> &prop) noexcept
3636
{
3737
std::lock_guard<common::SpinLockMutex> guard(GetLock());
3838
GetPropagator() = prop;

api/include/opentelemetry/context/runtime_context.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ class OPENTELEMETRY_EXPORT RuntimeContext
152152
*
153153
* @param storage a custom runtime context storage
154154
*/
155-
static void SetRuntimeContextStorage(nostd::shared_ptr<RuntimeContextStorage> storage) noexcept
155+
static void SetRuntimeContextStorage(
156+
const nostd::shared_ptr<RuntimeContextStorage> &storage) noexcept
156157
{
157158
GetStorage() = storage;
158159
}

api/include/opentelemetry/logs/event_id.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ namespace logs
1919
class EventId
2020
{
2121
public:
22-
EventId(int64_t id, nostd::string_view name) noexcept : id_{id}
22+
EventId(int64_t id, nostd::string_view name) noexcept
23+
: id_{id}, name_{nostd::unique_ptr<char[]>{new char[name.length() + 1]}}
2324
{
24-
name_ = nostd::unique_ptr<char[]>{new char[name.length() + 1]};
2525
std::copy(name.begin(), name.end(), name_.get());
2626
name_.get()[name.length()] = 0;
2727
}

api/include/opentelemetry/logs/provider.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class OPENTELEMETRY_EXPORT Provider
3939
/**
4040
* Changes the singleton LoggerProvider.
4141
*/
42-
static void SetLoggerProvider(nostd::shared_ptr<LoggerProvider> tp) noexcept
42+
static void SetLoggerProvider(const nostd::shared_ptr<LoggerProvider> &tp) noexcept
4343
{
4444
std::lock_guard<common::SpinLockMutex> guard(GetLock());
4545
GetProvider() = tp;
@@ -60,7 +60,7 @@ class OPENTELEMETRY_EXPORT Provider
6060
/**
6161
* Changes the singleton EventLoggerProvider.
6262
*/
63-
static void SetEventLoggerProvider(nostd::shared_ptr<EventLoggerProvider> tp) noexcept
63+
static void SetEventLoggerProvider(const nostd::shared_ptr<EventLoggerProvider> &tp) noexcept
6464
{
6565
std::lock_guard<common::SpinLockMutex> guard(GetLock());
6666
GetEventProvider() = tp;

api/include/opentelemetry/metrics/provider.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class Provider
3838
/**
3939
* Changes the singleton MeterProvider.
4040
*/
41-
static void SetMeterProvider(nostd::shared_ptr<MeterProvider> tp) noexcept
41+
static void SetMeterProvider(const nostd::shared_ptr<MeterProvider> &tp) noexcept
4242
{
4343
std::lock_guard<common::SpinLockMutex> guard(GetLock());
4444
GetProvider() = tp;

0 commit comments

Comments
 (0)