Skip to content

Commit b6fcc19

Browse files
authored
Merge branch 'main' into poc_config_yaml
2 parents 96bf29b + 1863fe7 commit b6fcc19

File tree

37 files changed

+584
-152
lines changed

37 files changed

+584
-152
lines changed

.github/workflows/ci.yml

Lines changed: 71 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,38 @@ on:
77
branches: [ main ]
88

99
jobs:
10-
arm64_test:
11-
name: CMake test arm64 (with modern protobuf,grpc and abseil)
12-
runs-on: actuated-arm64-4cpu-16gb
13-
steps:
14-
- uses: actions/checkout@v4
15-
with:
16-
submodules: 'recursive'
17-
- name: setup
18-
env:
19-
PROTOBUF_VERSION: '23.3'
20-
ABSEIL_CPP_VERSION: '20230125.3'
21-
CXX_STANDARD: '14'
22-
CC: /usr/bin/gcc-10
23-
CXX: /usr/bin/g++-10
24-
run: |
25-
sudo -E ./ci/setup_gcc10.sh
26-
sudo -E ./ci/setup_cmake.sh
27-
sudo -E ./ci/setup_ci_environment.sh
28-
sudo -E ./ci/setup_googletest.sh
29-
sudo -E ./ci/install_abseil.sh
30-
sudo -E ./ci/install_protobuf.sh
31-
- name: run otlp exporter tests
32-
env:
33-
CC: /usr/bin/gcc-10
34-
CXX: /usr/bin/g++-10
35-
WITH_ABSEIL: 'ON'
36-
CXX_STANDARD: '14'
37-
run: |
38-
sudo -E ./ci/setup_grpc.sh -m -p protobuf -p abseil-cpp
39-
./ci/do_ci.sh cmake.exporter.otprotocol.test
10+
11+
# Commented 2024-11-06, lack of workers in github causes CI failures
12+
# arm64_test:
13+
# name: CMake test arm64 (with modern protobuf,grpc and abseil)
14+
# runs-on: actuated-arm64-4cpu-16gb
15+
# steps:
16+
# - uses: actions/checkout@v4
17+
# with:
18+
# submodules: 'recursive'
19+
# - name: setup
20+
# env:
21+
# PROTOBUF_VERSION: '23.3'
22+
# ABSEIL_CPP_VERSION: '20230125.3'
23+
# CXX_STANDARD: '14'
24+
# CC: /usr/bin/gcc-10
25+
# CXX: /usr/bin/g++-10
26+
# run: |
27+
# sudo -E ./ci/setup_gcc10.sh
28+
# sudo -E ./ci/setup_cmake.sh
29+
# sudo -E ./ci/setup_ci_environment.sh
30+
# sudo -E ./ci/setup_googletest.sh
31+
# sudo -E ./ci/install_abseil.sh
32+
# sudo -E ./ci/install_protobuf.sh
33+
# - name: run otlp exporter tests
34+
# env:
35+
# CC: /usr/bin/gcc-10
36+
# CXX: /usr/bin/g++-10
37+
# WITH_ABSEIL: 'ON'
38+
# CXX_STANDARD: '14'
39+
# run: |
40+
# sudo -E ./ci/setup_grpc.sh -m -p protobuf -p abseil-cpp
41+
# ./ci/do_ci.sh cmake.exporter.otprotocol.test
4042

4143
cmake_test:
4244
name: CMake test (without otlp-exporter)
@@ -957,3 +959,42 @@ jobs:
957959
- name: run ./ci/docfx.cmd
958960
shell: cmd
959961
run: ./ci/docfx.cmd
962+
963+
w3c_trace_context_compliance_v1:
964+
name: W3C Distributed Tracing Validation V1
965+
runs-on: ubuntu-latest
966+
steps:
967+
- name: Checkout open-telemetry/opentelemetry-cpp
968+
uses: actions/checkout@v4
969+
with:
970+
submodules: 'recursive'
971+
- name: setup
972+
env:
973+
CC: /usr/bin/gcc-10
974+
CXX: /usr/bin/g++-10
975+
run: |
976+
sudo -E ./ci/setup_googletest.sh
977+
sudo -E ./ci/setup_ci_environment.sh
978+
- name: run w3c trace-context test server (background)
979+
env:
980+
CXX_STANDARD: '14'
981+
run: |
982+
./ci/do_ci.sh cmake.w3c.trace-context.build-server
983+
cd $HOME/build/ext/test/w3c_tracecontext_http_test_server
984+
./w3c_tracecontext_http_test_server &
985+
- name: Checkout w3c/trace-context repo
986+
uses: actions/checkout@v4
987+
with:
988+
repository: w3c/trace-context
989+
path: trace-context
990+
- name: install dependencies
991+
run: |
992+
sudo apt update && sudo apt install python3-pip
993+
sudo pip3 install aiohttp
994+
- name: run w3c trace-context test suite
995+
env:
996+
SPEC_LEVEL: 1
997+
run:
998+
|
999+
python ${GITHUB_WORKSPACE}/trace-context/test/test.py http://localhost:30000/test TraceContextTest AdvancedTest
1000+
curl http://localhost:30000/stop

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ Increment the:
1515

1616
## [Unreleased]
1717

18+
* [API] Comply with W3C Trace Context [#3115](https://github.com/open-telemetry/opentelemetry-cpp/pull/3115)
19+
* Also adds CI check to ensure continued compliance
20+
1821
* [API] Jaeger Propagator should not be deprecated
1922
[#3086](https://github.com/open-telemetry/opentelemetry-cpp/pull/3086)
2023

@@ -29,6 +32,14 @@ Important changes:
2932
as the Jaeger propagator can be used without the (now removed)
3033
Jaeger exporter.
3134

35+
* Upgrade to prometheus 1.3.0
36+
[#3122](https://github.com/open-telemetry/opentelemetry-cpp/pull/3122)
37+
38+
* [EXPORTER] Change log resources location for ElasticsearchLogRecordExporter
39+
[#3119](https://github.com/open-telemetry/opentelemetry-cpp/pull/3131)
40+
41+
* Moved from `root/resources` to `root`
42+
3243
## [1.17 2024-10-07]
3344

3445
* [CI] Add a clang-tidy build

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,9 @@ option(
217217
"Whether to include gzip compression for the OTLP http exporter in the SDK"
218218
OFF)
219219

220+
option(WITH_CURL_LOGGING "Whether to enable select CURL verbosity in OTel logs"
221+
OFF)
222+
220223
option(WITH_ZIPKIN "Whether to include the Zipkin exporter in the SDK" OFF)
221224

222225
option(WITH_PROMETHEUS "Whether to include the Prometheus Client in the SDK"

api/include/opentelemetry/common/spin_lock_mutex.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,10 @@ class SpinLockMutex
6868
# else
6969
__builtin_ia32_pause();
7070
# endif
71-
#elif defined(__arm__)
72-
__asm__ volatile("yield" ::: "memory");
71+
#elif defined(__armel__) || defined(__ARMEL__)
72+
asm volatile("nop" ::: "memory");
73+
#elif defined(__arm__) || defined(__aarch64__) // arm big endian / arm64
74+
__asm__ __volatile__("yield" ::: "memory");
7375
#else
7476
// TODO: Issue PAGE/YIELD on other architectures.
7577
#endif

api/include/opentelemetry/common/string_util.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ class StringUtil
1515
public:
1616
static nostd::string_view Trim(nostd::string_view str, size_t left, size_t right) noexcept
1717
{
18-
while (left <= right && str[static_cast<std::size_t>(left)] == ' ')
18+
while (left <= right && isspace(str[left]))
1919
{
2020
left++;
2121
}
22-
while (left <= right && str[static_cast<std::size_t>(right)] == ' ')
22+
while (left <= right && isspace(str[right]))
2323
{
2424
right--;
2525
}

api/include/opentelemetry/logs/event_logger.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,8 @@ class EventLogger
6565
}
6666
nostd::unique_ptr<LogRecord> log_record = delegate_logger->CreateLogRecord();
6767

68-
IgnoreTraitResult(
69-
detail::LogRecordSetterTrait<typename std::decay<ArgumentType>::type>::template Set(
70-
log_record.get(), std::forward<ArgumentType>(args))...);
68+
IgnoreTraitResult(detail::LogRecordSetterTrait<typename std::decay<ArgumentType>::type>::Set(
69+
log_record.get(), std::forward<ArgumentType>(args))...);
7170

7271
EmitEvent(event_name, std::move(log_record));
7372
}

api/include/opentelemetry/logs/logger.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,8 @@ class Logger
7272
return;
7373
}
7474

75-
IgnoreTraitResult(
76-
detail::LogRecordSetterTrait<typename std::decay<ArgumentType>::type>::template Set(
77-
log_record.get(), std::forward<ArgumentType>(args))...);
75+
IgnoreTraitResult(detail::LogRecordSetterTrait<typename std::decay<ArgumentType>::type>::Set(
76+
log_record.get(), std::forward<ArgumentType>(args))...);
7877

7978
EmitLogRecord(std::move(log_record));
8079
}

api/include/opentelemetry/logs/logger_type_traits.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ struct LogRecordSetterTrait
166166
* = nullptr>
167167
inline static LogRecord *Set(LogRecord *log_record, ArgumentType &&arg) noexcept
168168
{
169-
return LogRecordSetterTrait<common::KeyValueIterable>::template Set(
170-
log_record, std::forward<ArgumentType>(arg));
169+
return LogRecordSetterTrait<common::KeyValueIterable>::Set(log_record,
170+
std::forward<ArgumentType>(arg));
171171
}
172172

173173
template <class ArgumentType,

api/include/opentelemetry/trace/propagation/http_trace_context.h

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,8 @@ class HttpTraceContext : public context::propagation::TextMapPropagator
8686
}
8787

8888
private:
89-
static constexpr uint8_t kInvalidVersion = 0xFF;
90-
91-
static bool IsValidVersion(nostd::string_view version_hex)
92-
{
93-
uint8_t version;
94-
detail::HexToBinary(version_hex, &version, sizeof(version));
95-
return version != kInvalidVersion;
96-
}
89+
static constexpr uint8_t kInvalidVersion = 0xFF;
90+
static constexpr uint8_t kDefaultAssumedVersion = 0x00;
9791

9892
static void InjectImpl(context::propagation::TextMapCarrier &carrier,
9993
const SpanContext &span_context)
@@ -122,11 +116,6 @@ class HttpTraceContext : public context::propagation::TextMapPropagator
122116
static SpanContext ExtractContextFromTraceHeaders(nostd::string_view trace_parent,
123117
nostd::string_view trace_state)
124118
{
125-
if (trace_parent.size() != kTraceParentSize)
126-
{
127-
return SpanContext::GetInvalid();
128-
}
129-
130119
std::array<nostd::string_view, 4> fields{};
131120
if (detail::SplitString(trace_parent, '-', fields.data(), 4) != 4)
132121
{
@@ -150,11 +139,33 @@ class HttpTraceContext : public context::propagation::TextMapPropagator
150139
return SpanContext::GetInvalid();
151140
}
152141

153-
if (!IsValidVersion(version_hex))
142+
// hex is valid, convert it to binary
143+
uint8_t version_binary;
144+
detail::HexToBinary(version_hex, &version_binary, sizeof(version_binary));
145+
if (version_binary == kInvalidVersion)
154146
{
147+
// invalid version encountered
155148
return SpanContext::GetInvalid();
156149
}
157150

151+
// See https://www.w3.org/TR/trace-context/#versioning-of-traceparent
152+
if (version_binary > kDefaultAssumedVersion)
153+
{
154+
// higher than default version detected
155+
if (trace_parent.size() < kTraceParentSize)
156+
{
157+
return SpanContext::GetInvalid();
158+
}
159+
}
160+
else
161+
{
162+
// version is either lower or same as the default version
163+
if (trace_parent.size() != kTraceParentSize)
164+
{
165+
return SpanContext::GetInvalid();
166+
}
167+
}
168+
158169
TraceId trace_id = TraceIdFromHex(trace_id_hex);
159170
SpanId span_id = SpanIdFromHex(span_id_hex);
160171

@@ -169,7 +180,8 @@ class HttpTraceContext : public context::propagation::TextMapPropagator
169180

170181
static SpanContext ExtractImpl(const context::propagation::TextMapCarrier &carrier)
171182
{
172-
nostd::string_view trace_parent = carrier.Get(kTraceParent);
183+
// Get trace_parent after trimming the leading and trailing whitespaces
184+
nostd::string_view trace_parent = common::StringUtil::Trim(carrier.Get(kTraceParent));
173185
nostd::string_view trace_state = carrier.Get(kTraceState);
174186
if (trace_parent == "")
175187
{

api/include/opentelemetry/trace/trace_state.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ class OPENTELEMETRY_EXPORT TraceState
5959
size_t cnt = kv_str_tokenizer.NumTokens(); // upper bound on number of kv pairs
6060
if (cnt > kMaxKeyValuePairs)
6161
{
62-
cnt = kMaxKeyValuePairs;
62+
// trace state should be discarded if count exceeds
63+
return GetDefault();
6364
}
6465

6566
nostd::shared_ptr<TraceState> ts(new TraceState(cnt));

0 commit comments

Comments
 (0)