Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
3503d72
Start Recorder api
rnburn Mar 3, 2020
79b4f1d
Fill out Span api
rnburn Mar 3, 2020
8bcff6e
Reformat
rnburn Mar 3, 2020
c5e9a9e
Fill out Tracer class
rnburn Mar 3, 2020
a69206f
Add cmake build
rnburn Mar 4, 2020
87170e3
Add commenting
rnburn Mar 4, 2020
4c7d2c0
Merge branch 'master' of https://github.com/open-telemetry/openteleme…
rnburn Mar 4, 2020
320add0
Fix formatting
rnburn Mar 4, 2020
1a3761e
Reformat
rnburn Mar 4, 2020
597f0f3
Fix date
rnburn Mar 4, 2020
0d8649f
Make mutex mutable
rnburn Mar 4, 2020
c15286e
s/mutex_/mu_/
rnburn Mar 4, 2020
3c6fbb0
Remove AddEvent with steady timestamp
rnburn Mar 5, 2020
b0d1548
Fix typo
rnburn Mar 6, 2020
6210da0
Fill in IsRecordable
rnburn Mar 6, 2020
c619e2b
Set up protobuf dependency
rnburn Mar 10, 2020
84d5ccd
Install protobuf in docker image
rnburn Mar 10, 2020
23c23b6
Merge branch 'recorder-interface' into otprotocol
rnburn Mar 10, 2020
eecc683
Merge in Recordable
rnburn Mar 10, 2020
414957f
Add exporter folder
rnburn Mar 10, 2020
c8fc557
Integrate protobuf files into build
rnburn Mar 11, 2020
b98eb9d
Add otprotocol Recordable
rnburn Mar 11, 2020
d2e2198
Set up protobuf with bazel
rnburn Mar 12, 2020
f470dd0
Reformat
rnburn Mar 12, 2020
51f9182
Install git in CI
rnburn Mar 12, 2020
d240118
Add otprotocol to cmake test
rnburn Mar 12, 2020
427314a
Fix typo
rnburn Mar 12, 2020
5f5050c
Fix install_protobuf.sh
rnburn Mar 12, 2020
092bd8d
Fix install_protobuf.sh
rnburn Mar 12, 2020
a979b8e
Fix install_protobuf.sh
rnburn Mar 12, 2020
fda73fe
Fix do_ci.sh
rnburn Mar 12, 2020
366e9e0
Add otprotocol windows tests
rnburn Mar 12, 2020
9094a52
Fix typo
rnburn Mar 12, 2020
b3d611b
Make protobuf install optional for windows
rnburn Mar 12, 2020
3b94521
Fix install_windows_protobuf.ps1
rnburn Mar 12, 2020
04284e0
Merge branch 'master' of https://github.com/open-telemetry/openteleme…
rnburn Mar 13, 2020
27e8526
Remove unnecessary globs
rnburn Mar 13, 2020
1fbb06e
Refactor
rnburn Mar 17, 2020
2f3296c
Rearrange protobuf files
rnburn Mar 19, 2020
49c27fe
Clean up workspace
rnburn Mar 19, 2020
28c8e5b
Fix formatting
rnburn Mar 19, 2020
f16dd46
Merge branch 'master' of https://github.com/open-telemetry/openteleme…
rnburn Mar 26, 2020
6f5316c
Update CI
rnburn Mar 26, 2020
2db1682
Merge branch 'master' of https://github.com/open-telemetry/openteleme…
rnburn Apr 4, 2020
1d83819
Restructure
rnburn Apr 4, 2020
f64c826
Reformat
rnburn Apr 4, 2020
49c375f
Refactor legacy test
rnburn Apr 6, 2020
ab62b01
Fix legacy target
rnburn Apr 6, 2020
336d466
Fix legacy target
rnburn Apr 6, 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
6 changes: 5 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ jobs:
- checkout
- run: ./ci/setup_ci_environment.sh
- run: ./ci/setup_cmake.sh
- run: ./ci/install_protobuf.sh
- run: ./ci/do_ci.sh cmake.test
- run: ./ci/do_ci.sh cmake.exporter.otprotocol.test
- store_artifacts:
path: ~/build/Testing/Temporary/LastTest.log
destination: Test.log
Expand Down Expand Up @@ -42,7 +44,7 @@ jobs:
- run: ./ci/setup_ci_environment.sh
- run: ./ci/install_bazelisk.sh
- run: ./ci/install_gcc48.sh
- run: CC=/usr/bin/g++-4.8 ./ci/do_ci.sh bazel.test
- run: CC=/usr/bin/g++-4.8 ./ci/do_ci.sh bazel.legacy.test

bazel_test:
resource_class: xlarge
Expand Down Expand Up @@ -121,7 +123,9 @@ jobs:
- checkout
- run: ./ci/setup_windows_cmake.ps1
- run: ./ci/setup_windows_ci_environment.ps1
- run: ./ci/install_windows_protobuf.ps1
- run: ./ci/do_ci.ps1 cmake.test
- run: ./ci/do_ci.sh cmake.exporter.otprotocol.test

windows_bazel:
executor: win/vs2019
Expand Down
23 changes: 23 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,31 @@ project(opentelemetry-cpp)

set(CMAKE_CXX_STANDARD 11)

option(WITH_OTPROTOCOL
"Whether to include the OpenTelemetry Protocol in the SDK" OFF)

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

include(CTest)

find_package(Threads)

if(WITH_PROTOBUF)
set(protobuf_MODULE_COMPATIBLE ON)
find_package(Protobuf CONFIG NAMES protobuf)
# Older versions of protobuf don't use cmake config files.
if(NOT protobuf_FOUND)
find_package(Protobuf REQUIRED)
endif()
endif()

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

if(BUILD_TESTING)
find_package(GTest REQUIRED)
find_package(benchmark REQUIRED)
Expand All @@ -23,4 +44,6 @@ add_subdirectory(api)
include_directories(sdk/include)
include_directories(sdk)
add_subdirectory(sdk)
include_directories(.)
add_subdirectory(exporters)
add_subdirectory(examples)
21 changes: 21 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,27 @@ workspace(name = "io_opentelemetry_cpp")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

# Uses older protobuf version because of
# https://github.com/protocolbuffers/protobuf/issues/7179
http_archive(
name = "com_google_protobuf",
sha256 = "b679cef31102ed8beddc39ecfd6368ee311cbee6f50742f13f21be7278781821",
strip_prefix = "protobuf-3.11.2",
urls = [
"https://github.com/protocolbuffers/protobuf/releases/download/v3.11.2/protobuf-all-3.11.2.tar.gz",
],
)

load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")

protobuf_deps()

new_local_repository(
name = "com_github_opentelemetry_proto",
build_file = "//bazel:opentelemetry_proto.BUILD",
path = "third_party/opentelemetry-proto",
)

# GoogleTest framework.
# Only needed for tests, not to build the OpenTelemetry library.
http_archive(
Expand Down
60 changes: 60 additions & 0 deletions bazel/opentelemetry_proto.BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# 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.

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

load("@rules_proto//proto:defs.bzl", "proto_library")

proto_library(
Comment thread
g-easy marked this conversation as resolved.
name = "common_proto",
srcs = [
"opentelemetry/proto/common/v1/common.proto",
],
)

cc_proto_library(
name = "common_proto_cc",
deps = [":common_proto"],
)

proto_library(
name = "resource_proto",
srcs = [
"opentelemetry/proto/resource/v1/resource.proto",
],
deps = [
":common_proto",
],
)

cc_proto_library(
name = "resource_proto_cc",
deps = [":resource_proto"],
)

proto_library(
name = "trace_proto",
srcs = [
"opentelemetry/proto/trace/v1/trace.proto",
],
deps = [
":common_proto",
":resource_proto",
],
)

cc_proto_library(
name = "trace_proto_cc",
deps = [":trace_proto"],
)
2 changes: 2 additions & 0 deletions ci/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ 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_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_protobuf.sh \
&& /setup-ci/install_format_tools.sh
2 changes: 2 additions & 0 deletions ci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ CI tests can be run on docker by invoking the script `./ci/run_docker.sh ./ci/do

* `cmake.test`: build cmake targets and run tests.
* `cmake.test_example_plugin`: build and test an example OpenTelemetry plugin.
* `cmake.exporter.otprotocol.test`: build and test the otprotocol exporter
* `bazel.test`: build bazel targets and run tests.
* `bazel.legacy.test`: build bazel targets and run tests for the targets meant to work with older compilers.
* `bazel.noexcept`: build bazel targets and run tests with exceptions disabled.
* `bazel.asan`: build bazel targets and run tests with AddressSanitizer.
* `bazel.tsan`: build bazel targets and run tests with ThreadSanitizer.
Expand Down
21 changes: 21 additions & 0 deletions ci/do_ci.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,27 @@ switch ($action) {
exit $exit
}
}
"cmake.exporter.otprotocol.test" {
cd "$BUILD_DIR"
cmake $SRC_DIR `
-DVCPKG_TARGET_TRIPLET=x64-windows `
-DWITH_OTPROTCOL=ON `
"-DCMAKE_TOOLCHAIN_FILE=$VCPKG_DIR\scripts\buildsystems\vcpkg.cmake"
$exit = $LASTEXITCODE
if ($exit -ne 0) {
exit $exit
}
cmake --build .
$exit = $LASTEXITCODE
if ($exit -ne 0) {
exit $exit
}
ctest -C Debug
$exit = $LASTEXITCODE
if ($exit -ne 0) {
exit $exit
}
}
"cmake.build_example_plugin" {
cd "$BUILD_DIR"
cmake $SRC_DIR `
Expand Down
14 changes: 14 additions & 0 deletions ci/do_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ if [[ "$1" == "cmake.test" ]]; then
make
make test
exit 0
elif [[ "$1" == "cmake.exporter.otprotocol.test" ]]; then
Comment thread
g-easy marked this conversation as resolved.
cd "${BUILD_DIR}"
rm -rf *
cmake -DCMAKE_BUILD_TYPE=Debug \
-DWITH_OTPROTOCOL=ON \
-DCMAKE_CXX_FLAGS="-Werror" \
"${SRC_DIR}"
make
make test
exit 0
elif [[ "$1" == "cmake.test_example_plugin" ]]; then
# Build the plugin
cd "${BUILD_DIR}"
Expand Down Expand Up @@ -58,6 +68,10 @@ elif [[ "$1" == "bazel.test" ]]; then
bazel build $BAZEL_OPTIONS //...
bazel test $BAZEL_TEST_OPTIONS //...
exit 0
elif [[ "$1" == "bazel.legacy.test" ]]; then
bazel build $BAZEL_OPTIONS -- //... -//exporters/otlp/...
bazel test $BAZEL_TEST_OPTIONS -- //... -//exporters/otlp/...
exit 0
elif [[ "$1" == "bazel.noexcept" ]]; then
bazel build --copt=-fno-exceptions $BAZEL_OPTIONS //...
bazel test --copt=-fno-exceptions $BAZEL_TEST_OPTIONS //...
Expand Down
13 changes: 13 additions & 0 deletions ci/install_protobuf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

set -e

[ -z "${PROTOBUF_VERSION}" ] && export PROTOBUF_VERSION="3.11.4"

cd /
wget https://github.com/google/protobuf/releases/download/v${PROTOBUF_VERSION}/protobuf-cpp-${PROTOBUF_VERSION}.tar.gz
Comment thread
g-easy marked this conversation as resolved.
tar zxf protobuf-cpp-${PROTOBUF_VERSION}.tar.gz --no-same-owner
cd protobuf-${PROTOBUF_VERSION}
./configure
make && make install
ldconfig
5 changes: 5 additions & 0 deletions ci/install_windows_protobuf.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
$ErrorActionPreference = "Stop"
trap { $host.SetShouldExit(1) }

cd vcpkg
./vcpkg install protobuf:x64-windows
3 changes: 2 additions & 1 deletion ci/setup_ci_environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ apt-get update
apt-get install --no-install-recommends --no-install-suggests -y \
build-essential \
ca-certificates \
wget
wget \
git
3 changes: 3 additions & 0 deletions exporters/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
if(WITH_OTPROTOCOL)
add_subdirectory(otlp)
endif()
30 changes: 30 additions & 0 deletions exporters/otlp/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# 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.

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

cc_library(
name = "recordable",
srcs = [
"recordable.cc",
],
hdrs = [
"recordable.h",
],
include_prefix = "exporters/otlp",
deps = [
"//sdk/src/trace",
"@com_github_opentelemetry_proto//:trace_proto_cc",
],
)
3 changes: 3 additions & 0 deletions exporters/otlp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
add_library(opentelemetry_exporter_otprotocol recordable.cc)
target_link_libraries(opentelemetry_exporter_otprotocol
$<TARGET_OBJECTS:opentelemetry_proto>)
25 changes: 25 additions & 0 deletions exporters/otlp/recordable.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include "exporters/otlp/recordable.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace exporter
{
namespace otlp
{
void Recordable::AddEvent(nostd::string_view name, core::SystemTimestamp timestamp) noexcept
{
(void)name;
}

void Recordable::SetStatus(trace::CanonicalCode code, nostd::string_view description) noexcept
{
(void)code;
(void)description;
}

void Recordable::SetName(nostd::string_view name) noexcept
{
span_.set_name(name.data(), name.size());
}
} // namespace otlp
} // namespace exporter
OPENTELEMETRY_END_NAMESPACE
29 changes: 29 additions & 0 deletions exporters/otlp/recordable.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#pragma once

#include "opentelemetry/proto/trace/v1/trace.pb.h"
#include "opentelemetry/sdk/trace/recordable.h"
#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace exporter
{
namespace otlp
{
class Recordable final : public sdk::trace::Recordable
{
public:
const proto::trace::v1::Span &span() const noexcept { return span_; }

// sdk::trace::Recordable
void AddEvent(nostd::string_view name, core::SystemTimestamp timestamp) noexcept override;

void SetStatus(trace::CanonicalCode code, nostd::string_view description) noexcept override;

void SetName(nostd::string_view name) noexcept override;

private:
proto::trace::v1::Span span_;
};
} // namespace otlp
} // namespace exporter
OPENTELEMETRY_END_NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
OPENTELEMETRY_BEGIN_NAMESPACE
namespace sdk
{
namespace trace_api = opentelemetry::trace;
namespace trace
{
namespace trace_api = opentelemetry::trace;

/**
* Maintains a representation of a span in a format that can be processed by a recorder.
Comment thread
g-easy marked this conversation as resolved.
*
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/trace/recorder.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#pragma once

#include "opentelemetry/sdk/trace/recordable.h"
#include "opentelemetry/trace/span_id.h"
#include "opentelemetry/trace/trace_id.h"
#include "opentelemetry/version.h"
#include "src/trace/recordable.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace sdk
Expand Down
4 changes: 2 additions & 2 deletions sdk/src/trace/span.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#pragma once

#include <mutex>

#include "opentelemetry/version.h"
#include "src/trace/tracer.h"

#include <mutex>

OPENTELEMETRY_BEGIN_NAMESPACE
namespace sdk
{
Expand Down
Loading