Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimiter 'malkia' Stanev committed Jan 19, 2024
2 parents f2e8e54 + 2b5c2b4 commit 552ab66
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 18 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,8 @@ jobs:
./ci/install_windows_protobuf.ps1
- name: run cmake test (DLL build)
run: ./ci/do_ci.ps1 cmake.dll.test
- name: run cmake cxx20 test (DLL build)
run: ./ci/do_ci.ps1 cmake.dll.cxx20.test
- name: run otprotocol test (DLL build)
run: ./ci/do_ci.ps1 cmake.exporter.otprotocol.dll.test

Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Increment the:
[#2449](https://github.com/open-telemetry/opentelemetry-cpp/pull/2449)
* [BUILD] Introduce CXX 20 CI pipeline for MSVC/Windows
[#2450](https://github.com/open-telemetry/opentelemetry-cpp/pull/2450)
* [BUILD] Add DLL build CI pipeline with CXX20
[#2465](https://github.com/open-telemetry/opentelemetry-cpp/pull/2465)
* [EXPORTER] Set `is_monotonic` flag for Observable Counters
[#2478](https://github.com/open-telemetry/opentelemetry-cpp/pull/2478)
* [PROTO] Upgrade to opentelemetry-proto v1.1.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,15 @@
// C++ Version Check
// -----------------------------------------------------------------------------

// Enforce C++11 as the minimum. Note that Visual Studio has not
// advanced __cplusplus despite being good enough for our purposes, so
// so we exempt it from the check.
#if defined(__cplusplus) && !defined(_MSC_VER)
// Enforce C++11 as the minimum.
#if defined(_MSVC_LANG)
#if _MSVC_LANG < 201103L
#error "C++ versions less than C++11 are not supported."
#endif // _MSVC_LANG < 201103L
#elif defined(__cplusplus)
#if __cplusplus < 201103L
#error "C++ versions less than C++11 are not supported."
#endif
#endif // __cplusplus < 201103L
#endif

// -----------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,8 @@ using underlying_type_t = typename std::underlying_type<T>::type;

namespace type_traits_internal {

#if __cplusplus >= 201703L
#if (!defined(_MSVC_LANG) && (__cplusplus >= 201703L)) || \
(defined(_MSVC_LANG) && (_MSVC_LANG >= 201703L))
// std::result_of is deprecated (C++17) or removed (C++20)
template<typename> struct result_of;
template<typename F, typename... Args>
Expand Down
38 changes: 38 additions & 0 deletions ci/do_ci.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,44 @@ switch ($action) {
exit $exit
}
}
"cmake.dll.cxx20.test" {
cd "$BUILD_DIR"
cmake $SRC_DIR `
-DCMAKE_CXX_STANDARD=20 `
-DVCPKG_TARGET_TRIPLET=x64-windows `
-DOPENTELEMETRY_BUILD_DLL=1 `
"-DCMAKE_TOOLCHAIN_FILE=$VCPKG_DIR/scripts/buildsystems/vcpkg.cmake"
$exit = $LASTEXITCODE
if ($exit -ne 0) {
exit $exit
}
cmake --build . -j $nproc
$exit = $LASTEXITCODE
if ($exit -ne 0) {
exit $exit
}
ctest -C Debug
$exit = $LASTEXITCODE
if ($exit -ne 0) {
exit $exit
}
$env:PATH = "$BUILD_DIR\ext\src\dll\Debug;$env:PATH"
examples\simple\Debug\example_simple.exe
$exit = $LASTEXITCODE
if ($exit -ne 0) {
exit $exit
}
examples\metrics_simple\Debug\metrics_ostream_example.exe
$exit = $LASTEXITCODE
if ($exit -ne 0) {
exit $exit
}
examples\logs_simple\Debug\example_logs_simple.exe
$exit = $LASTEXITCODE
if ($exit -ne 0) {
exit $exit
}
}
"cmake.maintainer.test" {
cd "$BUILD_DIR"
cmake $SRC_DIR `
Expand Down
5 changes: 2 additions & 3 deletions examples/common/logs_foo_library/foo_library.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ void foo_library()
auto scoped_span = trace::Scope(get_tracer()->StartSpan("foo_library"));
auto ctx = span->GetContext();
auto logger = get_logger();
logger->EmitLogRecord(opentelemetry::logs::Severity::kDebug, "body", ctx.trace_id(),
ctx.span_id(), ctx.trace_flags(),
opentelemetry::common::SystemTimestamp(std::chrono::system_clock::now()));

logger->Debug("body", ctx.trace_id(), ctx.span_id(), ctx.trace_flags());
}
12 changes: 6 additions & 6 deletions examples/logs_simple/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@

# Simple Logs Example

In this example, the application in `main.cc` initializes an
`OStreamLogRecordExporter` instance and registers a logger
provider, as well as initializes a `StdoutSpanExporter` instance and registers a
tracer provider from the [OpenTelemetry
tracer provider from the [OpenTelemetry C++
SDK](https://github.com/open-telemetry/opentelemetry-cpp).

The application then calls a `logs_foo_library` which has been instrumented
using the [OpenTelemetry
API](https://github.com/open-telemetry/opentelemetry-cpp/tree/main/api).
Resulting logs and traces are directed to stdout.
The application then calls into
[`logs_foo_library`](https://github.com/open-telemetry/opentelemetry-cpp/blob/main/examples/common/logs_foo_library/foo_library.cc)
which has been instrumented using the [OpenTelemetry Logs
API](../../api/include/opentelemetry/logs/logger.h). Resulting logs and traces
are directed to stdout.

See [CONTRIBUTING.md](../../CONTRIBUTING.md) for instructions on building and
running the example.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ void print_value(const nostd::span<T> &vec, std::ostream &sout)
}

// Prior to C++14, generic lambda is not available so fallback to functor.
#if __cplusplus < 201402L
#if (!defined(_MSVC_LANG) && (__cplusplus < 201402L)) || \
(defined(_MSVC_LANG) && (_MSVC_LANG < 201402L))

class OwnedAttributeValueVisitor
{
Expand Down Expand Up @@ -97,7 +98,8 @@ class AttributeValueVisitor
inline void print_value(const opentelemetry::sdk::common::OwnedAttributeValue &value,
std::ostream &sout)
{
#if __cplusplus < 201402L
#if (!defined(_MSVC_LANG) && (__cplusplus < 201402L)) || \
(defined(_MSVC_LANG) && (_MSVC_LANG < 201402L))
opentelemetry::nostd::visit(OwnedAttributeValueVisitor(sout), value);
#else
opentelemetry::nostd::visit(
Expand All @@ -111,7 +113,8 @@ inline void print_value(const opentelemetry::sdk::common::OwnedAttributeValue &v

inline void print_value(const opentelemetry::common::AttributeValue &value, std::ostream &sout)
{
#if __cplusplus < 201402L
#if (!defined(_MSVC_LANG) && (__cplusplus < 201402L)) || \
(defined(_MSVC_LANG) && (_MSVC_LANG < 201402L))
opentelemetry::nostd::visit(AttributeValueVisitor(sout), value);
#else
opentelemetry::nostd::visit(
Expand Down

0 comments on commit 552ab66

Please sign in to comment.