Skip to content

Commit

Permalink
Merge branch 'main' into wip-ceph
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomsonTan authored Jan 28, 2022
2 parents f1cbe56 + 16a9c53 commit 387a8d1
Show file tree
Hide file tree
Showing 192 changed files with 5,078 additions and 715 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: OpenTelemetry-cpp benchmarks
on:
push:
branches:
- main

permissions:
contents: write
deployments: write

jobs:
benchmark:
name: Run OpenTelemetry-cpp benchmarks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- name: Mount Bazel Cache
uses: actions/cache@v2
env:
cache-name: bazel_cache
with:
path: /home/runner/.cache/bazel
key: bazel_benchmark
- name: setup
run: |
sudo ./ci/setup_cmake.sh
sudo ./ci/setup_ci_environment.sh
- name: Run benchmark
id: run_benchmarks
run: |
ci/do_ci.sh bazel.benchmark
mkdir -p benchmarks
mv api-benchmark_result.json benchmarks
mv sdk-benchmark_result.json benchmarks
mv exporters-benchmark_result.json benchmarks
- uses: actions/upload-artifact@master
with:
name: benchmark_results
path: benchmarks
store_benchmark:
needs: benchmark
strategy:
matrix:
components: ["api", "sdk", "exporters"]
name: Store benchmark result
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@master
with:
name: benchmark_results
path: benchmarks
- name: Print json files
id: print_json
run: |
cat benchmarks/*
- name: Push benchmark result
uses: benchmark-action/github-action-benchmark@v1
with:
name: OpenTelemetry-cpp ${{ matrix.components }} Benchmark
tool: 'googlecpp'
output-file-path: benchmarks/${{ matrix.components }}-benchmark_result.json
github-token: ${{ secrets.GITHUB_TOKEN }}
auto-push: true
# Show alert with commit comment on detecting possible performance regression
alert-threshold: '200%'
comment-on-alert: true
fail-on-alert: true
gh-pages-branch: gh-pages
benchmark-data-dir-path: benchmarks
24 changes: 23 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,28 @@ jobs:
- name: run tests
run: ./ci/do_ci.sh bazel.test

bazel_with_abseil:
name: Bazel with external abseil
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- name: Mount Bazel Cache
uses: actions/cache@v2
env:
cache-name: bazel_cache
with:
path: /home/runner/.cache/bazel
key: bazel_test
- name: setup
run: |
sudo ./ci/setup_thrift.sh dependencies_only
sudo ./ci/setup_ci_environment.sh
sudo ./ci/install_bazelisk.sh
- name: run tests
run: ./ci/do_ci.sh bazel.with_abseil

bazel_valgrind:
name: Bazel valgrind
runs-on: ubuntu-latest
Expand Down Expand Up @@ -386,7 +408,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: install docfx
run: choco install docfx -y
run: choco install docfx -y --version=2.58.5
- name: run ./ci/docfx.cmd
shell: cmd
run: ./ci/docfx.cmd
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,5 @@
/bazel-*
/plugin
/build

tags
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,31 @@ Increment the:

## [Unreleased]

* [API/SDK] Logger: Support for Instrumentation library ([#1128](https://github.com/open-telemetry/opentelemetry-cpp/pull/1128))
* [SDK] Add LogLevel to internal_log ([#1147](https://github.com/open-telemetry/opentelemetry-cpp/pull/1147))
* [API/SDK] Logger: Propagating resources through LoggerProvider ([#1154](https://github.com/open-telemetry/opentelemetry-cpp/pull/1154))
* [API]: Allow to use external abseil for bazel targets ([#1172](https://github.com/open-telemetry/opentelemetry-cpp/pull/1172))

## [1.1.1] 2021-12-20

* [SDK] Rename OTEL_CPP_GET_ATTR macro, and define it using fully qualified attr function ([#1140](https://github.com/open-telemetry/opentelemetry-cpp/pull/1140))
* [SDK] Default resource attributes and attributes in OTEL_RESOURCE_ATTRIBUTES are missing when using Otlp*LogExporter ([#1082](https://github.com/open-telemetry/opentelemetry-cpp/pull/1082))
* [METRICS] Add Meter and MeterProvider in the SDK ([#1078](https://github.com/open-telemetry/opentelemetry-cpp/pull/1078))
* [EXPORTER] ZipkinExporter shutdown ([#1153](https://github.com/open-telemetry/opentelemetry-cpp/pull/1153))
* [EXPORTER] Jaeger exporter shutdown ([#1150](https://github.com/open-telemetry/opentelemetry-cpp/pull/1150))
* [EXPORTER] Bugfix: `jaeger::TUDPTransport::write` crash when `getaddrinfo` returns error ([#1116](https://github.com/open-telemetry/opentelemetry-cpp/pull/1116))
* [EXPORTER] Bugfix: Jaeger exporter: extend supported attributes types ([#1106](https://github.com/open-telemetry/opentelemetry-cpp/pull/1106))
* [EXPORTER] Fix otlp generates null span ids ([#1113](https://github.com/open-telemetry/opentelemetry-cpp/pull/1113))
* [EXPORTER] Jaeger bazel (Linux only) ([#1077](https://github.com/open-telemetry/opentelemetry-cpp/pull/1077))
* [DOCS] Add note on DLL support ([#1137](https://github.com/open-telemetry/opentelemetry-cpp/pull/1137))
* [DOCS] Improve the instructions for Bazel build ([#1136](https://github.com/open-telemetry/opentelemetry-cpp/pull/1136))
* [DOCS] Document dependencies ([#1119](https://github.com/open-telemetry/opentelemetry-cpp/pull/1119))
* [DOCS] Dockerfile for quick demo/troubleshooting purpose ([#905](https://github.com/open-telemetry/opentelemetry-cpp/pull/905))
* [TESTS] Fix data race in BM_ThreadYieldSpinLockThrashing ([#1099](https://github.com/open-telemetry/opentelemetry-cpp/pull/1099))
* [EXAMPLE] Otlp gRPC log example ([#1083](https://github.com/open-telemetry/opentelemetry-cpp/pull/1083))
* [BUILD] C++20 not Building with VS2019 ([#1144](https://github.com/open-telemetry/opentelemetry-cpp/pull/1144))
* [BUILD] Mark tags to bazel targets([#1075](https://github.com/open-telemetry/opentelemetry-cpp/pull/1075))

## [1.1.0] 2021-11-19

* [BUILD] build release tarball when nlohmann-json not installed ([#1074](https://github.com/open-telemetry/opentelemetry-cpp/pull/1074))
Expand Down
65 changes: 38 additions & 27 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ else()
)
endif()

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

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

Expand Down Expand Up @@ -137,18 +139,6 @@ if(WITH_STL)
# (absl::variant or std::variant) in variant unit test code is consistent with
# the global project build definitions.
add_definitions(-DHAVE_CPP_STDLIB)
add_definitions(-DHAVE_GSL)

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

# Optimize for speed to reduce the hops
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
Expand All @@ -165,6 +155,20 @@ if(WITH_STL)
endif()
endif()

if(WITH_GSL)
add_definitions(-DHAVE_GSL)

# Guidelines Support Library path. Used if we are not on not get C++20.
#
find_package(Microsoft.GSL QUIET)
if(TARGET Microsoft.GSL::GSL)
list(APPEND CORE_RUNTIME_LIBS Microsoft.GSL::GSL)
else()
set(GSL_DIR third_party/ms-gsl)
include_directories(${GSL_DIR}/include)
endif()
endif()

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

Expand Down Expand Up @@ -204,7 +208,7 @@ endif(WIN32)

option(
WITH_API_ONLY
"Only build the API (use as a header-only library). Overrides WITH_EXAMPLES"
"Only build the API (use as a header-only library). Overrides WITH_EXAMPLES and all options to enable exporters"
OFF)
option(WITH_EXAMPLES "Whether to build examples" ON)

Expand Down Expand Up @@ -271,13 +275,14 @@ endif()
include(GNUInstallDirs)

if((NOT WITH_API_ONLY)
OR WITH_ELASTICSEARCH
OR WITH_ZIPKIN
OR WITH_OTLP
OR WITH_OTLP_HTTP
OR WITH_ZPAGES
OR BUILD_W3CTRACECONTEXT_TEST
OR WITH_ETW)
AND (WITH_ELASTICSEARCH
OR WITH_ZIPKIN
OR WITH_OTLP
OR WITH_OTLP_HTTP
OR WITH_ZPAGES
OR BUILD_W3CTRACECONTEXT_TEST
OR WITH_ETW
))
# nlohmann_json package is required for most SDK build configurations
find_package(nlohmann_json QUIET)
set(nlohmann_json_clone FALSE)
Expand Down Expand Up @@ -326,7 +331,8 @@ endif()
if(WITH_OTLP)
set(protobuf_MODULE_COMPATIBLE ON)
find_package(Protobuf)
if(WITH_OTLP_GRPC)
if(WITH_OTLP_GRPC OR (NOT DEFINED WITH_OTLP_GRPC AND NOT DEFINED
CACHE{WITH_OTLP_GRPC}))
find_package(gRPC)
endif()
if((NOT Protobuf_FOUND AND NOT PROTOBUF_FOUND) OR (NOT gRPC_FOUND))
Expand All @@ -344,7 +350,9 @@ if(WITH_OTLP)
if(NOT Protobuf_FOUND AND NOT PROTOBUF_FOUND)
find_package(Protobuf REQUIRED)
endif()
if(WITH_OTLP_GRPC AND NOT gRPC_FOUND)
if(NOT gRPC_FOUND
AND (WITH_OTLP_GRPC OR (NOT DEFINED WITH_OTLP_GRPC
AND NOT DEFINED CACHE{WITH_OTLP_GRPC})))
find_package(gRPC)
endif()
if(WIN32)
Expand All @@ -360,18 +368,21 @@ if(WITH_OTLP)
set(PROTOBUF_PROTOC_EXECUTABLE ${Protobuf_PROTOC_EXECUTABLE})
endif()
endif()
message("PROTOBUF_PROTOC_EXECUTABLE=${PROTOBUF_PROTOC_EXECUTABLE}")

include(cmake/opentelemetry-proto.cmake)
include(CMakeDependentOption)
find_package(CURL)
if(WITH_OTLP_HTTP OR (NOT DEFINED WITH_OTLP_HTTP AND NOT DEFINED
CACHE{WITH_OTLP_HTTP}))
find_package(CURL)
endif()

cmake_dependent_option(
WITH_OTLP_GRPC "Whether to include the OTLP gRPC exporter in the SDK" ON
"gRPC_FOUND" OFF)
cmake_dependent_option(
WITH_OTLP_HTTP "Whether to include the OTLP http exporter in the SDK" ON
"CURL_FOUND" OFF)

message(STATUS "PROTOBUF_PROTOC_EXECUTABLE=${PROTOBUF_PROTOC_EXECUTABLE}")
include(cmake/opentelemetry-proto.cmake)
endif()

list(APPEND CMAKE_PREFIX_PATH "${CMAKE_BINARY_DIR}")
Expand Down
27 changes: 23 additions & 4 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
[CMake](https://cmake.org/) and [Bazel](https://bazel.build) are the official
build systems for opentelemetry-cpp.

## Dependencies

You can link OpenTelemetry C++ SDK with libraries provided in [dependencies.md](https://github.com/open-telemetry/opentelemetry-cpp/blob/main/docs/dependencies.md) (complete list of libraries with versions used in our CI can be found [here](https://github.com/open-telemetry/opentelemetry-cpp/blob/main/third_party_release)).

## Build instructions using CMake

### Prerequisites for CMake
Expand All @@ -19,9 +23,14 @@ build systems for opentelemetry-cpp.
unittests. We use CMake version 3.15.2 in our build system. To install CMake,
consult the [Installing CMake](https://cmake.org/install/) guide.
- [GoogleTest](https://github.com/google/googletest) framework to build and run
the unittests. We use GoogleTest version 1.10.0 in our build system. To
the unittests. Refer to [third_party_release](https://github.com/open-telemetry/opentelemetry-cpp/blob/main/third_party_release#L5)
for version of GoogleTest used in CI. To
install GoogleTest, consult the [GoogleTest Build
Instructions](https://github.com/google/googletest/blob/master/googletest/README.md#generic-build-instructions).
- [Google Benchmark](https://github.com/google/benchmark) framework to build and run
benchmark tests. Refer to [third_party_release](https://github.com/open-telemetry/opentelemetry-cpp/blob/main/third_party_release#L4)
for version of Benchmark used in CI. To install Benchmark,
consult the [GoogleBenchmark Build Instructions](https://github.com/google/benchmark#installation).
- Apart from above core requirements, the Exporters and Propagators have their
build dependencies which are not covered here. E.g, Otlp Exporter needs
grpc/protobuf library, Zipkin exporter needs nlohmann-json and libcurl, ETW
Expand Down Expand Up @@ -66,7 +75,9 @@ build systems for opentelemetry-cpp.
configuration, the code is compiled without `-fpic` option, so it is not
suitable for inclusion in shared libraries. To enable the code for
inclusion in shared libraries, this variable is used.

- `-DBUILD_SHARED_LIBS=ON` : To build shared libraries for the targets. Please
refer to note [below](#building-shared-libs-for-windows) for Windows DLL
support
- `-DWITH_OTLP=ON` : To enable building Otlp exporter.
- `-DWITH_PROMETHEUS=ON` : To enable building prometheus exporter.

Expand Down Expand Up @@ -133,7 +144,8 @@ target_link_libraries(foo PRIVATE ${OPENTELEMETRY_CPP_LIBRARIES})

## Build instructions using Bazel

NOTE: Experimental, and not supported for all the components.
NOTE: Experimental, and not supported for all the components. Make sure the
[GoogleTest](https://github.com/google/googletest) installation may fail if there is a different version of googletest already installed in system-defined path.

### Prerequisites for Bazel

Expand Down Expand Up @@ -166,9 +178,10 @@ To install Bazel, consult the [Installing Bazel](https://docs.bazel.build/versio
$
```

2. Download the dependencies and build the source code:
2. Navigate to the repository cloned above, download the dependencies and build the source code:

```console
$ cd opentelemtry-cpp
$ bazel build //...
bazel build -- //... -//exporters/otlp/... -//exporters/prometheus/...
Extracting Bazel installation...
Expand Down Expand Up @@ -237,6 +250,12 @@ cc_library(
)
```

## Building shared libs for Windows

Windows DLL build is not supported. There are some constraints on how C++ DLLs work on
Windows, specifically we can't safely allocate memory in one DLL and free it in another.
For now, OpenTelemetry C++ targets need to be statically linked into the Windows applications.

## Using Package Managers

If you are using [Conan](https://www.conan.io/) to manage your dependencies,
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ For edit access, get in touch on
Approvers
([@open-telemetry/cpp-approvers](https://github.com/orgs/open-telemetry/teams/cpp-approvers)):

* [Ehsan Saei](https://github.com/esigo)
* [Johannes Tax](https://github.com/pyohannes), Microsoft
* [Josh Suereth](https://github.com/jsuereth), Google
* [Max Golovanov](https://github.com/maxgolov), Microsoft
Expand Down
24 changes: 24 additions & 0 deletions api/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,34 @@
# See the License for the specific language governing permissions and
# limitations under the License.

load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")

package(default_visibility = ["//visibility:public"])

bool_flag(
name = "with_abseil",
build_setting_default = False,
)

cc_library(
name = "api",
hdrs = glob(["include/**/*.h"]),
defines = select({
":with_external_abseil": ["HAVE_ABSEIL"],
"//conditions:default": [],
}),
strip_include_prefix = "include",
tags = ["api"],
deps = select({
":with_external_abseil": [
"@com_google_absl//absl/base",
"@com_google_absl//absl/types:variant",
],
"//conditions:default": [],
}),
)

config_setting(
name = "with_external_abseil",
flag_values = {":with_abseil": "true"},
)
Loading

0 comments on commit 387a8d1

Please sign in to comment.