Skip to content

Commit

Permalink
Merge branch 'master' into logs-elasticsearch-pr
Browse files Browse the repository at this point in the history
  • Loading branch information
Karen Xu authored Dec 22, 2020
2 parents 0526050 + ddec444 commit 58026b4
Show file tree
Hide file tree
Showing 87 changed files with 3,799 additions and 1,510 deletions.
19 changes: 10 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,16 @@ jobs:
- name: run tests
run: ./ci/do_ci.sh bazel.tsan

bazel_osx:
name: Bazel on MacOS
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- name: run tests
run: ./ci/do_ci.sh bazel.test

benchmark:
name: Benchmark
runs-on: ubuntu-latest
Expand Down Expand Up @@ -195,15 +205,6 @@ jobs:
- name: run tests
run: ./ci/do_ci.sh format

osx_test:
name: Bazel on MacOS
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- name: run tests
run: ./ci/do_ci.sh bazel.test

windows:
name: CMake -> exporter proto
Expand Down
57 changes: 50 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,48 @@ if(NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 11)
endif()

option(WITH_STL "Whether to use Standard Library for C++latest features" OFF)

option(WITH_ABSEIL "Whether to use Abseil for C++latest features" OFF)

if(WITH_ABSEIL)
add_definitions(-DHAVE_ABSEIL)
find_package(absl CONFIG REQUIRED)

# Abseil headers-only lib is needed for absl::variant to work vs2015.
# `nostd::mpark::variant` is not compiling in vs2015.
set(CORE_RUNTIME_LIBS absl::any absl::base absl::bits absl::city)

# target_link_libraries(main PRIVATE absl::any absl::base absl::bits
# absl::city)
endif()

if(WITH_STL)
# Require at least C++17. C++20 is needed to avoid gsl::span
add_definitions(-DHAVE_CPP_STDLIB -DHAVE_GSL)

if(CMAKE_MINOR_VERSION VERSION_GREATER "3.18")
# Ask for 20, may get anything below
set(CMAKE_CXX_STANDARD 20)
else()
# Ask for 17, may get anything below
set(CMAKE_CXX_STANDARD 17)
endif()

# Guidelines Support Library path. Used if we are not on not get C++20.
#
# TODO: respect WITH_ABSEIL as alternate implementation of std::span
set(GSL_DIR third_party/ms-gsl)
include_directories(${GSL_DIR}/include)

# Optimize for speed to reduce the hops
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(CMAKE_CXX_FLAGS_SPEED "/O2")
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} /Zc:__cplusplus ${CMAKE_CXX_FLAGS_SPEED}")
endif()
endif()

option(WITH_OTLP "Whether to include the OpenTelemetry Protocol in the SDK" OFF)

option(WITH_PROMETHEUS "Whether to include the Prometheus Client in the SDK"
Expand All @@ -21,8 +63,6 @@ option(WITH_ELASTICSEARCH
option(BUILD_TESTING "Whether to enable tests" ON)
option(WITH_EXAMPLES "Whether to build examples" ON)

set(WITH_PROTOBUF OFF)

find_package(Threads)

function(install_windows_deps)
Expand All @@ -32,7 +72,8 @@ function(install_windows_deps)
execute_process(
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tools/setup-buildtools.cmd)
set(CMAKE_TOOLCHAIN_FILE
${CMAKE_CURRENT_SOURCE_DIR}/tools/vcpkg/scripts/buildsystems/vcpkg.cmake)
${CMAKE_CURRENT_SOURCE_DIR}/tools/vcpkg/scripts/buildsystems/vcpkg.cmake
PARENT_SCOPE)
endfunction()

if(MSVC)
Expand All @@ -43,17 +84,19 @@ if(MSVC)
endif()

if(WITH_OTLP)
set(WITH_PROTOBUF ON)
endif()

if(WITH_PROTOBUF)
set(protobuf_MODULE_COMPATIBLE ON)
find_package(Protobuf)
find_package(gRPC)
if((NOT protobuf_FOUND) OR (NOT gRPC_FOUND))
if(WIN32 AND (NOT DEFINED CMAKE_TOOLCHAIN_FILE))
install_windows_deps()
endif()

if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
message(STATUS_FATAL "Windows dependency installation failed!")
endif()
include(${CMAKE_TOOLCHAIN_FILE})

if(NOT protobuf_FOUND)
find_package(Protobuf REQUIRED)
endif()
Expand Down
57 changes: 57 additions & 0 deletions CMakeSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,63 @@
"type": "BOOL"
}
]
},
{
"name": "stdlib-x64-Debug",
"generator": "Ninja",
"configurationType": "Debug",
"inheritEnvironments": [ "msvc_x64_x64" ],
"buildRoot": "${projectDir}\\out\\vs2019\\${name}",
"installRoot": "${projectDir}\\out\\vs2019\\${name}\\install",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"variables": [
{
"name": "WITH_STL",
"value": "True",
"type": "BOOL"
},
{
"name": "WITH_OTLP",
"value": "True",
"type": "BOOL"
},
{
"name": "WITH_EXAMPLES",
"value": "true",
"type": "BOOL"
}
]
},
{
"name": "stdlib-x64-Release",
"generator": "Ninja",
"configurationType": "RelWithDebInfo",
"inheritEnvironments": [ "msvc_x64_x64" ],
"buildRoot": "${projectDir}\\out\\vs2019\\${name}",
"installRoot": "${projectDir}\\out\\vs2019\\${name}\\install",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"cmakeToolchain": "",
"variables": [
{
"name": "WITH_STL",
"value": "True",
"type": "BOOL"
},
{
"name": "WITH_OTLP",
"value": "True",
"type": "BOOL"
},
{
"name": "WITH_EXAMPLES",
"value": "true",
"type": "BOOL"
}
]
}
]
}
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,19 @@ Please note that supporting the [C Programming
Language](https://en.wikipedia.org/wiki/C_(programming_language)) is not a goal
of the current project.

## Supported Development Platforms

Our CI pipeline builds and tests on following `x86-64` platforms:

* ubuntu-18.04 ( Default GCC Compiler - 7.5.0 )
* ubuntu-18.04 ( GCC 4.8 with -std=c++11 flag)
* ubuntu-20.04 ( Default GCC Compiler - 9.3.0 with -std=c++20 flags )
* macOS 10.15 ( Xcode 12.2 )
* Windows Server 2019 (Visual Studio Enterprise 2019 )

In general, the code shipped from this repository should build on all platforms having C++ compiler with [supported C++ standards](#supported-c-versions)


## Installation

Please refer to [INSTALL.md](./INSTALL.md).
Expand Down
6 changes: 6 additions & 0 deletions api/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,9 @@ install(
if(BUILD_TESTING)
add_subdirectory(test)
endif()

if(WITH_STL)
message("Building with standard library types...")
else()
message("Building with nostd types...")
endif()
44 changes: 29 additions & 15 deletions api/include/opentelemetry/common/attribute_value.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,30 @@
OPENTELEMETRY_BEGIN_NAMESPACE
namespace common
{
using AttributeValue = nostd::variant<bool,
int,
int64_t,
unsigned int,
uint64_t,
double,
nostd::string_view,
nostd::span<const bool>,
nostd::span<const int>,
nostd::span<const int64_t>,
nostd::span<const unsigned int>,
nostd::span<const uint64_t>,
nostd::span<const double>,
nostd::span<const nostd::string_view>>;
using AttributeValue =
nostd::variant<bool,
int32_t,
int64_t,
uint32_t,
uint64_t,
double,
nostd::string_view,
#ifdef HAVE_CSTRING_TYPE
// TODO: add C-string as possible value on API surface
const char *,
#endif
#ifdef HAVE_SPAN_BYTE
// TODO: 8-bit byte arrays / binary blobs are not part of OT spec yet!
// Ref: https://github.com/open-telemetry/opentelemetry-specification/issues/780
nostd::span<const uint8_t>,
#endif
nostd::span<const bool>,
nostd::span<const int32_t>,
nostd::span<const int64_t>,
nostd::span<const uint32_t>,
nostd::span<const uint64_t>,
nostd::span<const double>,
nostd::span<const nostd::string_view>>;

enum AttributeType
{
Expand All @@ -34,8 +44,12 @@ enum AttributeType
TYPE_UINT64,
TYPE_DOUBLE,
TYPE_STRING,
#ifdef HAVE_CSTRING_TYPE
TYPE_CSTRING,
// TYPE_SPAN_BYTE, // TODO: not part of OT spec yet
#endif
#ifdef HAVE_SPAN_BYTE
TYPE_SPAN_BYTE,
#endif
TYPE_SPAN_BOOL,
TYPE_SPAN_INT,
TYPE_SPAN_INT64,
Expand Down
18 changes: 18 additions & 0 deletions api/include/opentelemetry/common/key_value_iterable.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,23 @@ class KeyValueIterable
*/
virtual size_t size() const noexcept = 0;
};

//
// NULL object pattern empty iterable.
//
class NullKeyValueIterable : public KeyValueIterable
{
public:
NullKeyValueIterable(){};

virtual bool ForEachKeyValue(
nostd::function_ref<bool(nostd::string_view, common::AttributeValue)>) const noexcept
{
return true;
};

virtual size_t size() const noexcept { return 0; }
};

} // namespace common
OPENTELEMETRY_END_NAMESPACE
Loading

0 comments on commit 58026b4

Please sign in to comment.