Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using STD library for API surface #374

Merged
merged 73 commits into from
Dec 22, 2020
Merged
Show file tree
Hide file tree
Changes from 72 commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
e29e971
Using STD library for API surface
maxgolov Oct 26, 2020
65f184e
Format using older format tools that are running in CI
maxgolov Oct 26, 2020
c9be76b
- Fix build issues with Ubuntu 18.04 and older CMake
maxgolov Oct 26, 2020
c3efe3c
Modify file permissions to +x
maxgolov Oct 26, 2020
bbbf850
Collection of build tools (no code changes)
maxgolov Oct 27, 2020
aae1c68
Merge branch 'master' into maxgolov/build_tools
maxgolov Nov 2, 2020
1bcbee4
Merge branch 'master' of https://github.com/open-telemetry/openteleme…
maxgolov Nov 2, 2020
50ca4f3
Merge branch 'master' of https://github.com/open-telemetry/openteleme…
maxgolov Nov 7, 2020
5e00ae2
Merge branch 'master' into maxgolov/build_tools
maxgolov Nov 7, 2020
f4e6c90
Merge branch 'master' of https://github.com/open-telemetry/openteleme…
maxgolov Nov 9, 2020
7c46e02
Add docker files for developer build
maxgolov Nov 14, 2020
b810c97
Move bazel-specific build files into bazel-specific directory.
maxgolov Nov 14, 2020
5e91eeb
Remove opentelemetry-proto - use submodule instead
maxgolov Nov 16, 2020
4efeee7
Modules
maxgolov Nov 16, 2020
f05e9e9
Move JSON bazel file to /bazel build files directory
maxgolov Nov 16, 2020
64bd715
Allow building with Docker
maxgolov Nov 16, 2020
0113aed
Clean-up Unix build tools
maxgolov Nov 16, 2020
71136a5
Add Windows build tools
maxgolov Nov 16, 2020
54cc0dd
Fix dependency issue for build on Windows with OTLP exporter enabled
maxgolov Nov 16, 2020
6a22842
Update benchmark to latest
maxgolov Nov 16, 2020
6b11443
Ignore scripts copied into docker build from /tools
maxgolov Nov 16, 2020
b72ddd9
Rework CMakeLists.txt to:
maxgolov Nov 16, 2020
c4d5675
Clean-up Dockerfile for Ubuntu 16/18/20 to make sure we do not unnece…
maxgolov Nov 16, 2020
68a4461
Clean modules
maxgolov Nov 16, 2020
de67ca5
Add submodule for opentelemetry-proto
maxgolov Nov 16, 2020
66489b9
Fix permissions and attributes
maxgolov Nov 16, 2020
c19519d
Initial implementation of VCPKG support
maxgolov Nov 16, 2020
c68bce5
Merge branch 'maxgolov/build_tools' of https://github.com/open-teleme…
maxgolov Nov 16, 2020
dea2d1a
Merge branch 'master' into maxgolov/build_tools
maxgolov Nov 16, 2020
b782d8d
Apply latest cmake format 0.6.13 - it looks much cleaner
maxgolov Nov 16, 2020
d3a06d0
Merge branch 'maxgolov/build_tools' of https://github.com/open-teleme…
maxgolov Nov 16, 2020
d171ad5
Add submodules to .bazelignore
maxgolov Nov 16, 2020
377640a
Try bazel clean builds to remove stale cache entries
maxgolov Nov 16, 2020
2b31204
Merge branch 'master' into maxgolov/build_tools
maxgolov Nov 17, 2020
03ff3c7
Trying to fix the Bazel build failure by recursively cloning with sub…
maxgolov Nov 17, 2020
220db8c
Don't clone submodules for DocFX and code format runs
maxgolov Nov 17, 2020
72f1c11
No need to clone it anymore: it's now there in the build tree as subm…
maxgolov Nov 17, 2020
9c2c607
Submit submodule updated to latest version v0.10.0
maxgolov Nov 17, 2020
a88a49c
Merge branch 'master' of https://github.com/open-telemetry/openteleme…
maxgolov Nov 17, 2020
177a3cf
Fix formatting issue after rebase
maxgolov Nov 17, 2020
53a94f8
nit: formatting
maxgolov Nov 17, 2020
6ccac73
Previous prometheus-cpp had a bug, update to latest
maxgolov Nov 17, 2020
7a8f2eb
Trying to fix a quirk with prometheus exporter build (shot in the dar…
maxgolov Nov 17, 2020
16cbf59
Recursively init just this module instead of full set from the top
maxgolov Nov 17, 2020
6e92bef
Allow OTLP to process const char * strings
maxgolov Nov 18, 2020
e1757ea
Add missing headers
maxgolov Nov 18, 2020
15ce22f
Use #ifdef instead of #if for unsupported feature that may be needed …
maxgolov Nov 18, 2020
65b012c
Merge branch 'master' of https://github.com/open-telemetry/openteleme…
maxgolov Nov 18, 2020
5f369d3
Partial merge of tools
maxgolov Nov 18, 2020
df09d8e
Merge branch 'maxgolov/build_tools' of https://github.com/open-teleme…
maxgolov Nov 18, 2020
d289827
Apply code and CMake formatting rules
maxgolov Nov 18, 2020
6d61cd1
Fix couple minor bugs
maxgolov Nov 18, 2020
636d4de
Formatting fix
maxgolov Nov 18, 2020
be51948
Add missing submodule
maxgolov Nov 18, 2020
bd009a9
Fix an issue in CI, where gcc-4.8 may try to link to GTest built with…
maxgolov Nov 18, 2020
ea99318
Add different build configurations to Visual Studio 2019 cmake (GUI) …
maxgolov Nov 18, 2020
f86b7f1
Undo the changes that are not relevant to STDLIB
maxgolov Nov 18, 2020
2c65732
Adjust script permissions
maxgolov Nov 18, 2020
87b248f
Resolve merge conflicts
maxgolov Dec 9, 2020
1785628
Merge branch 'master' of https://github.com/open-telemetry/openteleme…
maxgolov Dec 9, 2020
ced9ff7
Formatting change
maxgolov Dec 9, 2020
529ee67
Merge branch 'master' of https://github.com/open-telemetry/openteleme…
maxgolov Dec 10, 2020
5e84ccd
Address code review comments
maxgolov Dec 10, 2020
4fbb0da
Merge branch 'master' of https://github.com/open-telemetry/openteleme…
maxgolov Dec 18, 2020
a389935
Fix formatting issue
maxgolov Dec 18, 2020
a95813a
Merge branch 'master' into maxgolov/nostd_stl
maxgolov Dec 18, 2020
cc5a032
Merge branch 'master' of https://github.com/open-telemetry/openteleme…
maxgolov Dec 21, 2020
b8e7cb1
Addressing code review comments, moving benchmarks into a separate fu…
maxgolov Dec 21, 2020
1f05197
Update submodules to latest stable
maxgolov Dec 21, 2020
991932a
Merge branch 'maxgolov/nostd_stl' of https://github.com/open-telemetr…
maxgolov Dec 21, 2020
46572b4
Fix formatting issue
maxgolov Dec 21, 2020
f0b5506
Ignore Visual Studio temporary files directory
maxgolov Dec 21, 2020
2dc2313
Merge branch 'master' of https://github.com/open-telemetry/openteleme…
maxgolov Dec 22, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
42 changes: 42 additions & 0 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 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"
}
]
}
]
}
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
maxgolov marked this conversation as resolved.
Show resolved Hide resolved
// 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>,
maxgolov marked this conversation as resolved.
Show resolved Hide resolved
#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
1 change: 1 addition & 0 deletions api/include/opentelemetry/logs/logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "opentelemetry/nostd/shared_ptr.h"
#include "opentelemetry/nostd/span.h"
#include "opentelemetry/nostd/string_view.h"
#include "opentelemetry/nostd/type_traits.h"
#include "opentelemetry/trace/span_id.h"
#include "opentelemetry/trace/trace_flags.h"
#include "opentelemetry/trace/trace_id.h"
Expand Down
14 changes: 14 additions & 0 deletions api/include/opentelemetry/nostd/function_ref.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Copyright 2020, OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once

#include <memory>
Expand Down
Loading