Skip to content

Commit 15045c5

Browse files
authored
Merge branch 'main' into ks/bazel-enable-incompatible_disallow_empty_glob
2 parents 52ed4cb + 84d4270 commit 15045c5

File tree

46 files changed

+1206
-79
lines changed

Some content is hidden

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

46 files changed

+1206
-79
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)
@@ -923,3 +925,42 @@ jobs:
923925
- name: run ./ci/docfx.cmd
924926
shell: cmd
925927
run: ./ci/docfx.cmd
928+
929+
w3c_trace_context_compliance_v1:
930+
name: W3C Distributed Tracing Validation V1
931+
runs-on: ubuntu-latest
932+
steps:
933+
- name: Checkout open-telemetry/opentelemetry-cpp
934+
uses: actions/checkout@v4
935+
with:
936+
submodules: 'recursive'
937+
- name: setup
938+
env:
939+
CC: /usr/bin/gcc-10
940+
CXX: /usr/bin/g++-10
941+
run: |
942+
sudo -E ./ci/setup_googletest.sh
943+
sudo -E ./ci/setup_ci_environment.sh
944+
- name: run w3c trace-context test server (background)
945+
env:
946+
CXX_STANDARD: '14'
947+
run: |
948+
./ci/do_ci.sh cmake.w3c.trace-context.build-server
949+
cd $HOME/build/ext/test/w3c_tracecontext_test
950+
./w3c_tracecontext_test &
951+
- name: Checkout w3c/trace-context repo
952+
uses: actions/checkout@v4
953+
with:
954+
repository: w3c/trace-context
955+
path: trace-context
956+
- name: install dependencies
957+
run: |
958+
sudo apt update && sudo apt install python3-pip
959+
sudo pip3 install aiohttp
960+
- name: run w3c trace-context test suite
961+
env:
962+
SPEC_LEVEL: 1
963+
run:
964+
|
965+
python ${GITHUB_WORKSPACE}/trace-context/test/test.py http://localhost:30000/test TraceContextTest AdvancedTest
966+
curl http://localhost:30000/stop

CHANGELOG.md

Lines changed: 6 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,9 @@ 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+
3238
## [1.17 2024-10-07]
3339

3440
* [CI] Add a clang-tidy build

CMakeLists.txt

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

218+
option(WITH_CURL_LOGGING "Whether to enable select CURL verbosity in OTel logs"
219+
OFF)
220+
218221
option(WITH_ZIPKIN "Whether to include the Zipkin exporter in the SDK" OFF)
219222

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

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/metrics/meter.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ class Histogram;
2121
template <typename T>
2222
class UpDownCounter;
2323

24+
template <typename T>
25+
class Gauge;
26+
2427
class ObservableInstrument;
2528

2629
/**
@@ -91,6 +94,27 @@ class Meter
9194
nostd::string_view description = "",
9295
nostd::string_view unit = "") noexcept = 0;
9396

97+
#if OPENTELEMETRY_ABI_VERSION_NO >= 2
98+
/**
99+
* Creates a Gauge with the passed characteristics and returns a unique_ptr to that Gauge.
100+
*
101+
* @param name the name of the new Gauge.
102+
* @param description a brief description of what the Gauge is used for.
103+
* @param unit the unit of metric values following https://unitsofmeasure.org/ucum.html.
104+
* @return a unique pointer to the created Gauge.
105+
*/
106+
107+
virtual nostd::unique_ptr<Gauge<int64_t>> CreateInt64Gauge(
108+
nostd::string_view name,
109+
nostd::string_view description = "",
110+
nostd::string_view unit = "") noexcept = 0;
111+
112+
virtual nostd::unique_ptr<Gauge<double>> CreateDoubleGauge(
113+
nostd::string_view name,
114+
nostd::string_view description = "",
115+
nostd::string_view unit = "") noexcept = 0;
116+
#endif
117+
94118
/**
95119
* Creates a Asynchronous (Observable) Gauge with the passed characteristics and returns a
96120
* shared_ptr to that Observable Gauge

api/include/opentelemetry/metrics/noop.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,26 @@ class NoopUpDownCounter : public UpDownCounter<T>
7171
{}
7272
};
7373

74+
#if OPENTELEMETRY_ABI_VERSION_NO >= 2
75+
template <class T>
76+
class NoopGauge : public Gauge<T>
77+
{
78+
public:
79+
NoopGauge(nostd::string_view /* name */,
80+
nostd::string_view /* description */,
81+
nostd::string_view /* unit */) noexcept
82+
{}
83+
~NoopGauge() override = default;
84+
void Record(T /* value */) noexcept override {}
85+
void Record(T /* value */, const context::Context & /* context */) noexcept override {}
86+
void Record(T /* value */, const common::KeyValueIterable & /* attributes */) noexcept override {}
87+
void Record(T /* value */,
88+
const common::KeyValueIterable & /* attributes */,
89+
const context::Context & /* context */) noexcept override
90+
{}
91+
};
92+
#endif
93+
7494
class NoopObservableInstrument : public ObservableInstrument
7595
{
7696
public:
@@ -140,6 +160,22 @@ class NoopMeter final : public Meter
140160
return nostd::unique_ptr<Histogram<double>>{new NoopHistogram<double>(name, description, unit)};
141161
}
142162

163+
#if OPENTELEMETRY_ABI_VERSION_NO >= 2
164+
nostd::unique_ptr<Gauge<int64_t>> CreateInt64Gauge(nostd::string_view name,
165+
nostd::string_view description = "",
166+
nostd::string_view unit = "") noexcept override
167+
{
168+
return nostd::unique_ptr<Gauge<int64_t>>{new NoopGauge<int64_t>(name, description, unit)};
169+
}
170+
171+
nostd::unique_ptr<Gauge<double>> CreateDoubleGauge(nostd::string_view name,
172+
nostd::string_view description = "",
173+
nostd::string_view unit = "") noexcept override
174+
{
175+
return nostd::unique_ptr<Gauge<double>>{new NoopGauge<double>(name, description, unit)};
176+
}
177+
#endif
178+
143179
nostd::shared_ptr<ObservableInstrument> CreateInt64ObservableGauge(
144180
nostd::string_view name,
145181
nostd::string_view description = "",

api/include/opentelemetry/metrics/sync_instruments.h

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,5 +247,82 @@ class UpDownCounter : public SynchronousInstrument
247247
}
248248
};
249249

250+
#if OPENTELEMETRY_ABI_VERSION_NO >= 2
251+
/* A Gauge instrument that records values. */
252+
template <class T>
253+
class Gauge : public SynchronousInstrument
254+
{
255+
256+
public:
257+
/**
258+
* Record a value
259+
*
260+
* @param value The measurement value. May be positive, negative or zero.
261+
*/
262+
virtual void Record(T value) noexcept = 0;
263+
264+
/**
265+
* Record a value
266+
*
267+
* @param value The measurement value. May be positive, negative or zero.
268+
* @param context The explicit context to associate with this measurement.
269+
*/
270+
virtual void Record(T value, const context::Context &context) noexcept = 0;
271+
272+
/**
273+
* Record a value with a set of attributes.
274+
*
275+
* @param value The measurement value. May be positive, negative or zero.
276+
* @param attributes A set of attributes to associate with the value.
277+
*/
278+
279+
virtual void Record(T value, const common::KeyValueIterable &attributes) noexcept = 0;
280+
281+
/**
282+
* Record a value with a set of attributes.
283+
*
284+
* @param value The measurement value. May be positive, negative or zero.
285+
* @param attributes A set of attributes to associate with the value.
286+
* @param context The explicit context to associate with this measurement.
287+
*/
288+
virtual void Record(T value,
289+
const common::KeyValueIterable &attributes,
290+
const context::Context &context) noexcept = 0;
291+
292+
template <class U,
293+
nostd::enable_if_t<common::detail::is_key_value_iterable<U>::value> * = nullptr>
294+
void Record(T value, const U &attributes) noexcept
295+
{
296+
this->Record(value, common::KeyValueIterableView<U>{attributes});
297+
}
298+
299+
template <class U,
300+
nostd::enable_if_t<common::detail::is_key_value_iterable<U>::value> * = nullptr>
301+
void Record(T value, const U &attributes, const context::Context &context) noexcept
302+
{
303+
this->Record(value, common::KeyValueIterableView<U>{attributes}, context);
304+
}
305+
306+
void Record(T value,
307+
std::initializer_list<std::pair<nostd::string_view, common::AttributeValue>>
308+
attributes) noexcept
309+
{
310+
this->Record(value, nostd::span<const std::pair<nostd::string_view, common::AttributeValue>>{
311+
attributes.begin(), attributes.end()});
312+
}
313+
314+
void Record(
315+
T value,
316+
std::initializer_list<std::pair<nostd::string_view, common::AttributeValue>> attributes,
317+
const context::Context &context) noexcept
318+
{
319+
this->Record(value,
320+
nostd::span<const std::pair<nostd::string_view, common::AttributeValue>>{
321+
attributes.begin(), attributes.end()},
322+
context);
323+
}
324+
};
325+
#endif
326+
250327
} // namespace metrics
251328
OPENTELEMETRY_END_NAMESPACE

0 commit comments

Comments
 (0)