Skip to content

Commit

Permalink
Merge branch 'master' into sampling-api-header
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliver Zhang committed Jun 22, 2020
2 parents 8d43a4a + 1a54e5d commit 7586d1d
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 6 deletions.
28 changes: 28 additions & 0 deletions .github/.codecov.yaml
Original file line number Diff line number Diff line change
@@ -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/::"
16 changes: 16 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).*

Expand Down
1 change: 1 addition & 0 deletions ci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
10 changes: 10 additions & 0 deletions ci/do_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
1 change: 1 addition & 0 deletions ci/setup_ci_environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ apt-get install --no-install-recommends --no-install-suggests -y \
ca-certificates \
wget \
git
apt-get install -y lcov
10 changes: 10 additions & 0 deletions examples/simple/README.md
Original file line number Diff line number Diff line change
@@ -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.
4 changes: 2 additions & 2 deletions examples/simple/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ void initTracer()
auto processor = std::shared_ptr<sdktrace::SpanProcessor>(
new sdktrace::SimpleSpanProcessor(std::move(exporter)));
auto provider = nostd::shared_ptr<trace::TracerProvider>(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();
Expand Down

0 comments on commit 7586d1d

Please sign in to comment.