From 9048d452bbe1e45d14b600bf37852b125914428c Mon Sep 17 00:00:00 2001 From: Tigran Najaryan <4194920+tigrannajaryan@users.noreply.github.com> Date: Thu, 18 Jun 2020 12:04:59 -0400 Subject: [PATCH 1/3] Remove Tigran Najaryan from Approvers list (#120) I haven't been able to contribute to this SIG. Please remove me. Will be glad to return if I get a chance to work on C++ in the future. :-) --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index a53ef98f7c..b9cee55c84 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,6 @@ Approvers ([@open-telemetry/cpp-approvers](https://github.com/orgs/open-telemetr - [Max Golovanov](https://github.com/maxgolov), Microsoft - [Johannes Tax](https://github.com/pyohannes), New Relic - [Ryan Burn](https://github.com/rnburn), Lightstep -- [Tigran Najaryan](https://github.com/tigrannajaryan), Splunk *Find more about the approver role in [community repository](https://github.com/open-telemetry/community/blob/master/community-membership.md#approver).* From c86794e41b96337ef999dd513d380c3970737f2e Mon Sep 17 00:00:00 2001 From: Ankit Bhargava Date: Fri, 19 Jun 2020 13:14:59 -0400 Subject: [PATCH 2/3] Enhancements to PR #86 Add minimal tracer example (#94) --- CMakeLists.txt | 6 +++--- examples/simple/README.md | 10 ++++++++++ examples/simple/main.cc | 4 ++-- 3 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 examples/simple/README.md diff --git a/CMakeLists.txt b/CMakeLists.txt index ee6dcbe380..9fbfc1c059 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,9 +23,9 @@ include(CTest) find_package(Threads) if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - # Options for Visual C++ compiler: - # /Zc:__cplusplus - report an updated value for recent C++ language standards. - # Without this option MSVC returns the value of __cplusplus="199711L" + # Options for Visual C++ compiler: /Zc:__cplusplus - report an updated value + # for recent C++ language standards. Without this option MSVC returns the + # value of __cplusplus="199711L" set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus") endif() diff --git a/examples/simple/README.md b/examples/simple/README.md new file mode 100644 index 0000000000..d59a1423cd --- /dev/null +++ b/examples/simple/README.md @@ -0,0 +1,10 @@ + +# Simple Trace Example + +In this example, the application in `main.cc` initializes and registers a tracer +provider from the [OpenTelemetry SDK](https://github.com/open-telemetry/opentelemetry-cpp). +The application then calls a `foo_library` which has been instrumented using +the [OpenTelemetry API](https://github.com/open-telemetry/opentelemetry-cpp/tree/master/api). +Resulting telemetry is directed to stdout through a custom exporter. + +See [CONTRIBUTING.md](../../CONTRIBUTING.md) for instructions on building and running the example. \ No newline at end of file diff --git a/examples/simple/main.cc b/examples/simple/main.cc index af03d2e6db..756c764e89 100644 --- a/examples/simple/main.cc +++ b/examples/simple/main.cc @@ -15,14 +15,14 @@ void initTracer() auto processor = std::shared_ptr( new sdktrace::SimpleSpanProcessor(std::move(exporter))); auto provider = nostd::shared_ptr(new sdktrace::TracerProvider(processor)); + // Set the global trace provider trace::Provider::SetTracerProvider(provider); } } // namespace int main() { - // Removing this line will leave OT initialized with the default noop - // tracer, thus being effectively deactivated. + // Removing this line will leave the default noop TracerProvider in place. initTracer(); foo_library(); From 1a54e5d65ccbbf4aa19c6ddc88635a32f4c807d8 Mon Sep 17 00:00:00 2001 From: Brandon Kimberly Date: Fri, 19 Jun 2020 19:49:06 -0400 Subject: [PATCH 3/3] Add code coverage using codecov.io (#121) --- .github/.codecov.yaml | 28 ++++++++++++++++++++++++++++ .github/workflows/ci.yml | 16 ++++++++++++++++ ci/README.md | 1 + ci/do_ci.sh | 10 ++++++++++ ci/setup_ci_environment.sh | 1 + 5 files changed, 56 insertions(+) create mode 100644 .github/.codecov.yaml diff --git a/.github/.codecov.yaml b/.github/.codecov.yaml new file mode 100644 index 0000000000..354ed22dd4 --- /dev/null +++ b/.github/.codecov.yaml @@ -0,0 +1,28 @@ +codecov: + require_ci_to_pass: yes + max_report_age: off + +coverage: + precision: 2 + round: down + range: "80...100" + +parsers: + gcov: + branch_detection: + conditional: yes + loop: yes + method: no + macro: no + +comment: + layout: "reach,diff,flags,tree" + behavior: default + require_changes: no + +# Relative file path fixing. +# CI file paths must match Git file paths. +# This fix removes the "/home/runner/" prefix +# to coverage report file paths. +fixes: + - "/home/runner/::" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 036f062ef5..a5d36c4a61 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -182,3 +182,19 @@ jobs: ./ci/setup_windows_ci_environment.ps1 - name: run tests run: ./ci/do_ci.ps1 cmake.test_example_plugin + + code_coverage: + name: Code coverage + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: setup + run: | + sudo ./ci/setup_cmake.sh + sudo ./ci/setup_ci_environment.sh + - name: run tests and generate report + run: ./ci/do_ci.sh code.coverage + - name: upload report + uses: codecov/codecov-action@v1 + with: + file: /home/runner/build/coverage.info diff --git a/ci/README.md b/ci/README.md index 5741684d9f..6695c8b134 100644 --- a/ci/README.md +++ b/ci/README.md @@ -13,6 +13,7 @@ CI tests can be run on docker by invoking the script `./ci/run_docker.sh ./ci/do * `bazel.tsan`: build bazel targets and run tests with ThreadSanitizer. * `benchmark`: run all benchmarks. * `format`: use `tools/format.sh` to enforce text formatting. +* `code.coverage`: build cmake targets and run tests. Then upload coverage report to [codecov.io](https://codecov.io/). Additionally, `./ci/run_docker.sh` can be invoked with no arguments to get a docker shell where tests can be run manually. diff --git a/ci/do_ci.sh b/ci/do_ci.sh index cd41b0a6b4..b6d23f763f 100755 --- a/ci/do_ci.sh +++ b/ci/do_ci.sh @@ -116,6 +116,16 @@ elif [[ "$1" == "format" ]]; then exit 1 fi exit 0 +elif [[ "$1" == "code.coverage" ]]; then + cd "${BUILD_DIR}" + rm -rf * + cmake -DCMAKE_BUILD_TYPE=Debug \ + -DCMAKE_CXX_FLAGS="-Werror --coverage" \ + "${SRC_DIR}" + make + make test + lcov --directory $PWD --capture --output-file coverage.info + exit 0 fi echo "Invalid do_ci.sh target, see ci/README.md for valid targets." diff --git a/ci/setup_ci_environment.sh b/ci/setup_ci_environment.sh index 50c7b373e9..9d7df6a1d5 100755 --- a/ci/setup_ci_environment.sh +++ b/ci/setup_ci_environment.sh @@ -7,3 +7,4 @@ apt-get install --no-install-recommends --no-install-suggests -y \ ca-certificates \ wget \ git +apt-get install -y lcov