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

Support async networking #63

Closed
wants to merge 53 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
73d9d9d
Setup dispatcher interface
rnburn Apr 11, 2020
9685fb2
Start libevent implementation
rnburn Apr 14, 2020
d6b175f
Add EventBase class
rnburn Apr 14, 2020
2b86e11
Integrate EventBase
rnburn Apr 15, 2020
8f387dc
Add Event
rnburn Apr 15, 2020
bd57639
Add Timer
rnburn Apr 15, 2020
3448df0
Add Timer test
rnburn Apr 16, 2020
2d2ea8e
Add FileEvent
rnburn Apr 16, 2020
dc35d6e
Add Exit test
rnburn Apr 16, 2020
fb83a8d
Integrate libevent with cmake
rnburn Apr 16, 2020
2d40011
Drop kTimeout
rnburn Apr 16, 2020
cabab7c
Integrat libevent with CI
rnburn Apr 16, 2020
d76fd24
Add commenting
rnburn Apr 16, 2020
fda54ee
Reformat
rnburn Apr 16, 2020
f3bb9b9
Add cmake depedency to bazel
rnburn Apr 16, 2020
e5596d8
Fix cmake toolchain
rnburn Apr 16, 2020
fe208d1
Fix cmake toolchain
rnburn Apr 16, 2020
3ac2aa5
Fix ci issues
rnburn Apr 17, 2020
919d396
Put back removed file
rnburn Apr 17, 2020
03eb077
Fix bazel build on windows
rnburn Apr 17, 2020
7d343ce
Fix bazel build
rnburn Apr 17, 2020
7bbbe29
Fix windows library name
rnburn Apr 17, 2020
11f0e46
Fix windows bazel build
rnburn Apr 17, 2020
515d01c
Fix windows library name
rnburn Apr 17, 2020
18791c1
Fix osx build
rnburn Apr 17, 2020
68ce934
Tweak test parameters
rnburn Apr 17, 2020
72fd4df
Make test less flaky
rnburn Apr 20, 2020
30cff79
Fix ci
rnburn Apr 20, 2020
e79b5f6
Reformat
rnburn Apr 20, 2020
9b62085
Fix windows ci
rnburn Apr 20, 2020
c120b8d
Fix comments
rnburn Apr 22, 2020
61b6b94
Separate out IoDispatcher
rnburn Apr 22, 2020
29a6b2f
Fix cmake build
rnburn Apr 22, 2020
7b59314
Fix formatting
rnburn Apr 22, 2020
23009af
Drop unused header
rnburn Apr 22, 2020
d14c11f
Renaming
rnburn Apr 23, 2020
0cef1d8
Work on async_timer
rnburn Apr 24, 2020
8c2b945
Fill in async timer
rnburn May 4, 2020
2f0cf96
Fill out async timer
rnburn May 4, 2020
76683b0
Reformat
rnburn May 4, 2020
53bcda4
Add async timer tests
rnburn May 4, 2020
4b162e4
Fix for gcc-4.8
rnburn May 4, 2020
3212ed4
Add test coverage
rnburn May 11, 2020
8f358c9
Add commenting
rnburn May 11, 2020
e086e77
Add more test coverage
rnburn May 11, 2020
ea0e87c
Add commenting
rnburn May 11, 2020
6234ee6
Update GH Actions
Jul 7, 2020
faf2973
Fix CI
Jul 7, 2020
1de581b
Build examples only with SDK
Jul 7, 2020
2cbf66c
Add libevent
Jul 7, 2020
8248ddd
Fix WITH_SDK flag
Jul 7, 2020
708f7b0
Increase timeout to avoid flaky tests
Jul 7, 2020
cc34479
Fix Windows dependencies
Jul 7, 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
12 changes: 11 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
- run: ./ci/setup_ci_environment.sh
- run: ./ci/setup_cmake.sh
- run: ./ci/install_protobuf.sh
- run: ./ci/install_libevent.sh
- run: ./ci/do_ci.sh cmake.test
- run: ./ci/do_ci.sh cmake.exporter.otprotocol.test
- store_artifacts:
Expand Down Expand Up @@ -42,9 +43,10 @@ jobs:
steps:
- checkout
- run: ./ci/setup_ci_environment.sh
- run: ./ci/setup_cmake.sh
- run: ./ci/install_bazelisk.sh
- run: ./ci/install_gcc48.sh
- run: CC=/usr/bin/gcc-4.8 ./ci/do_ci.sh bazel.legacy.test
- run: CC=/usr/bin/gcc-4.8 CXX=/usr/bin/g++-4.8 ./ci/do_ci.sh bazel.legacy.test

bazel_test:
resource_class: xlarge
Expand All @@ -53,6 +55,7 @@ jobs:
steps:
- checkout
- run: ./ci/setup_ci_environment.sh
- run: ./ci/setup_cmake.sh
- run: ./ci/install_bazelisk.sh
- run: ./ci/do_ci.sh bazel.test

Expand All @@ -63,6 +66,7 @@ jobs:
steps:
- checkout
- run: ./ci/setup_ci_environment.sh
- run: ./ci/setup_cmake.sh
- run: ./ci/install_bazelisk.sh
- run: ./ci/do_ci.sh bazel.noexcept

Expand All @@ -73,6 +77,7 @@ jobs:
steps:
- checkout
- run: ./ci/setup_ci_environment.sh
- run: ./ci/setup_cmake.sh
- run: ./ci/install_bazelisk.sh
- run: ./ci/do_ci.sh bazel.asan

Expand All @@ -83,6 +88,7 @@ jobs:
steps:
- checkout
- run: ./ci/setup_ci_environment.sh
- run: ./ci/setup_cmake.sh
- run: ./ci/install_bazelisk.sh
- run: ./ci/do_ci.sh bazel.tsan

Expand All @@ -93,6 +99,7 @@ jobs:
steps:
- checkout
- run: ./ci/setup_ci_environment.sh
- run: ./ci/setup_cmake.sh
- run: ./ci/install_bazelisk.sh
- run: env BENCHMARK_DIR=/benchmark ./ci/do_ci.sh benchmark
- store_artifacts:
Expand All @@ -114,6 +121,7 @@ jobs:
xcode: "11.0.0"
steps:
- checkout
- run: ./ci/install_osx_cmake.sh
- run: ./ci/install_osx_bazelisk.sh
- run: ./ci/do_ci.sh bazel.test

Expand All @@ -126,13 +134,15 @@ jobs:
- run:
command: ./ci/install_windows_protobuf.ps1
no_output_timeout: 15m
- run: ./ci/install_windows_libevent.ps1
- run: ./ci/do_ci.ps1 cmake.test
- run: ./ci/do_ci.sh cmake.exporter.otprotocol.test

windows_bazel:
executor: win/vs2019
steps:
- checkout
- run: ./ci/setup_windows_cmake.ps1
- run: ./ci/install_windows_bazelisk.ps1
- run: ./ci/do_ci.ps1 bazel.build

Expand Down
20 changes: 13 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ jobs:
run: |
sudo ./ci/setup_cmake.sh
sudo ./ci/setup_ci_environment.sh
sudo ./ci/install_protobuf.sh
sudo ./ci/install_libevent.sh
- name: run tests
run: ./ci/do_ci.sh cmake.test
run: |
./ci/do_ci.sh cmake.test
./ci/do_ci.sh cmake.exporter.otprotocol.test

cmake_test_cxx20:
name: CMake C++20 test
Expand All @@ -28,6 +32,7 @@ jobs:
run: |
sudo ./ci/setup_ci_environment.sh
sudo ./ci/setup_cmake.sh
sudo ./ci/install_libevent.sh
- name: run tests
run: ./ci/do_ci.sh cmake.c++20.test

Expand All @@ -50,6 +55,7 @@ jobs:
- uses: actions/checkout@v2
- name: setup
run: |
sudo ./ci/setup_cmake.sh
sudo ./ci/setup_ci_environment.sh
sudo ./ci/install_bazelisk.sh
sudo ./ci/install_gcc48.sh
Expand Down Expand Up @@ -143,6 +149,8 @@ jobs:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: setup
run: ./ci/install_osx_cmake.sh
- name: run tests
run: ./ci/do_ci.sh bazel.test

Expand All @@ -153,9 +161,10 @@ jobs:
- uses: actions/checkout@v2
- name: setup
run: |
./ci/setup_windows_cmake.ps1
./ci/setup_windows_ci_environment.ps1
./ci/install_windows_protobuf.ps1
- name: setup libevent
run: ./ci/install_windows_libevent.ps1
- name: run cmake test
run: ./ci/do_ci.ps1 cmake.test
- name: run otprotocol test
Expand All @@ -166,8 +175,6 @@ jobs:
runs-on: windows-2019
steps:
- uses: actions/checkout@v2
- name: setup
run: ./ci/install_windows_bazelisk.ps1
- name: run tests
run: ./ci/do_ci.ps1 bazel.build

Expand All @@ -177,9 +184,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: setup
run: |
./ci/setup_windows_cmake.ps1
./ci/setup_windows_ci_environment.ps1
run: ./ci/setup_windows_ci_environment.ps1
- name: run tests
run: ./ci/do_ci.ps1 cmake.test_example_plugin

Expand All @@ -192,6 +197,7 @@ jobs:
run: |
sudo ./ci/setup_cmake.sh
sudo ./ci/setup_ci_environment.sh
sudo ./ci/install_libevent.sh
- name: run tests and generate report
run: ./ci/do_ci.sh code.coverage
- name: upload report
Expand Down
25 changes: 18 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,18 @@ if(NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 11)
endif()

option(WITH_SDK "Whether to build the SDK or just the API" ON)
option(WITH_OTPROTOCOL
"Whether to include the OpenTelemetry Protocol in the SDK" OFF)
option(WITH_LIBEVENT "Build SDK with libevent support" ON)

set(WITH_PROTOBUF OFF)
if(WITH_OTPROTOCOL)
set(WITH_PROTOBUF ON)
endif()

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")

include(CTest)

find_package(Threads)
Expand All @@ -29,7 +33,7 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus")
endif()

if(WITH_PROTOBUF)
if(WITH_SDK AND WITH_PROTOBUF)
set(protobuf_MODULE_COMPATIBLE ON)
find_package(Protobuf CONFIG NAMES protobuf)
# Older versions of protobuf don't use cmake config files.
Expand All @@ -38,21 +42,28 @@ if(WITH_PROTOBUF)
endif()
endif()

if(WITH_OTPROTOCOL)
if(WITH_SDK AND WITH_OTPROTOCOL)
include(third_party/opentelemetry-proto/Protobuf.cmake)
endif()

if(WITH_SDK AND WITH_LIBEVENT)
find_package(Libevent REQUIRED)
include_directories(SYSTEM ${LIBEVENT_INCLUDE_DIRS})
endif()

if(BUILD_TESTING)
find_package(GTest REQUIRED)
find_package(benchmark REQUIRED)
include_directories(SYSTEM ${GTEST_INCLUDE_DIRS})
endif()

include_directories(.)
include_directories(api/include)
add_subdirectory(api)
include_directories(sdk/include)
include_directories(sdk)
add_subdirectory(sdk)
include_directories(.)
add_subdirectory(exporters)
if(WITH_SDK)
include_directories(sdk/include)
include_directories(sdk)
add_subdirectory(sdk)
add_subdirectory(exporters)
endif()
add_subdirectory(examples)
30 changes: 30 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,36 @@ new_local_repository(
path = "third_party/opentelemetry-proto",
)

http_archive(
name = "bazel_skylib",
sha256 = "64ad2728ccdd2044216e4cec7815918b7bb3bb28c95b7e9d951f9d4eccb07625",
strip_prefix = "bazel-skylib-1.0.2",
urls = [
"https://github.com/bazelbuild/bazel-skylib/archive/1.0.2.zip",
],
)

http_archive(
name = "rules_foreign_cc",
strip_prefix = "rules_foreign_cc-456425521973736ef346d93d3d6ba07d807047df",
url = "https://github.com/bazelbuild/rules_foreign_cc/archive/456425521973736ef346d93d3d6ba07d807047df.zip",
)

load("@rules_foreign_cc//:workspace_definitions.bzl", "rules_foreign_cc_dependencies")

rules_foreign_cc_dependencies([
])

http_archive(
name = "com_github_libevent_libevent",
build_file = "//bazel:libevent.BUILD",
sha256 = "70158101eab7ed44fd9cc34e7f247b3cae91a8e4490745d9d6eb7edc184e4d96",
strip_prefix = "libevent-release-2.1.8-stable",
urls = [
"https://github.com/libevent/libevent/archive/release-2.1.8-stable.zip",
],
)

# GoogleTest framework.
# Only needed for tests, not to build the OpenTelemetry library.
http_archive(
Expand Down
33 changes: 33 additions & 0 deletions bazel/libevent.BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
load("@rules_foreign_cc//tools/build_defs:cmake.bzl", "cmake_external")

filegroup(
name = "srcs",
srcs = glob(["**"]),
)

cmake_external(
name = "libevent",
cache_entries = {
"CMAKE_BUILD_TYPE": "Release",
"CMAKE_POSITION_INDEPENDENT_CODE": "on",
"BUILD_SHARED_LIBS": "off",
"BUILD_STATIC_LIBS": "on",
"EVENT__DISABLE_OPENSSL": "on",
"EVENT__DISABLE_REGRESS": "on",
"EVENT__DISABLE_TESTS": "on",
},
generate_crosstool_file = select({
"@io_opentelemetry_cpp//bazel:windows": True,
"//conditions:default": None,
}),
lib_source = ":srcs",
make_commands = select({
"@io_opentelemetry_cpp//bazel:windows": ["MSBuild.exe INSTALL.vcxproj"],
"//conditions:default": None,
}),
static_libraries = select({
"@io_opentelemetry_cpp//bazel:windows": ["event.lib"],
"//conditions:default": ["libevent.a"],
}),
visibility = ["//visibility:public"],
)
12 changes: 6 additions & 6 deletions bazel/opentelemetry_proto.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ load("@rules_proto//proto:defs.bzl", "proto_library")
proto_library(
name = "common_proto",
srcs = [
"opentelemetry/proto/common/v1/common.proto",
"opentelemetry/proto/common/v1/common.proto",
],
)

Expand All @@ -31,10 +31,10 @@ cc_proto_library(
proto_library(
name = "resource_proto",
srcs = [
"opentelemetry/proto/resource/v1/resource.proto",
"opentelemetry/proto/resource/v1/resource.proto",
],
deps = [
":common_proto",
":common_proto",
],
)

Expand All @@ -46,11 +46,11 @@ cc_proto_library(
proto_library(
name = "trace_proto",
srcs = [
"opentelemetry/proto/trace/v1/trace.proto",
"opentelemetry/proto/trace/v1/trace.proto",
],
deps = [
":common_proto",
":resource_proto",
":common_proto",
":resource_proto",
],
)

Expand Down
2 changes: 2 additions & 0 deletions ci/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ ADD setup_ci_environment.sh /setup-ci
ADD setup_cmake.sh /setup-ci
ADD install_gcc48.sh /setup-ci
ADD install_bazelisk.sh /setup-ci
ADD install_libevent.sh /setup-ci
ADD install_protobuf.sh /setup-ci
ADD install_format_tools.sh /setup-ci

RUN /setup-ci/setup_ci_environment.sh \
&& /setup-ci/setup_cmake.sh \
&& /setup-ci/install_gcc48.sh \
&& /setup-ci/install_bazelisk.sh \
&& /setup-ci/install_libevent.sh \
&& /setup-ci/install_protobuf.sh \
&& /setup-ci/install_format_tools.sh
6 changes: 4 additions & 2 deletions ci/do_ci.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ switch ($action) {
cd "$BUILD_DIR"
cmake $SRC_DIR `
-DVCPKG_TARGET_TRIPLET=x64-windows `
"-DCMAKE_TOOLCHAIN_FILE=$VCPKG_DIR\scripts\buildsystems\vcpkg.cmake"
"-DCMAKE_TOOLCHAIN_FILE=$VCPKG_DIR\scripts\buildsystems\vcpkg.cmake" `
-DWITH_SDK=OFF
$exit = $LASTEXITCODE
if ($exit -ne 0) {
exit $exit
Expand All @@ -89,7 +90,8 @@ switch ($action) {
cd "$BUILD_DIR"
cmake $SRC_DIR `
-DVCPKG_TARGET_TRIPLET=x64-windows `
"-DCMAKE_TOOLCHAIN_FILE=$VCPKG_DIR\scripts\buildsystems\vcpkg.cmake"
"-DCMAKE_TOOLCHAIN_FILE=$VCPKG_DIR\scripts\buildsystems\vcpkg.cmake" `
-DWITH_SDK=OFF
$exit = $LASTEXITCODE
if ($exit -ne 0) {
exit $exit
Expand Down
2 changes: 2 additions & 0 deletions ci/do_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ EOF
-DCMAKE_CXX_FLAGS="-Werror" \
-DCMAKE_EXE_LINKER_FLAGS="$LINKER_FLAGS" \
-DCMAKE_SHARED_LINKER_FLAGS="$LINKER_FLAGS" \
-DWITH_SDK=OFF \
"${SRC_DIR}"
make example_plugin
cp examples/plugin/plugin/libexample_plugin.so ${PLUGIN_DIR}
Expand All @@ -70,6 +71,7 @@ EOF
rm -rf *
cmake -DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_CXX_FLAGS="-Werror" \
-DWITH_SDK=OFF \
"${SRC_DIR}"
make load_plugin_example
examples/plugin/load/load_plugin_example ${PLUGIN_DIR}/libexample_plugin.so /dev/null
Expand Down
7 changes: 7 additions & 0 deletions ci/install_libevent.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

set -e

apt-get install --no-install-recommends --no-install-suggests -y \
libevent-dev
g-easy marked this conversation as resolved.
Show resolved Hide resolved

5 changes: 5 additions & 0 deletions ci/install_osx_cmake.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

set -e

brew install cmake
Loading