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

Add Recordable implementation for otprotocol exporter #49

Merged
merged 49 commits into from
Apr 6, 2020
Merged
Show file tree
Hide file tree
Changes from 33 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
3 changes: 3 additions & 0 deletions .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 @@ -112,6 +114,7 @@ jobs:
- run: ./ci/setup_windows_cmake.ps1
- run: ./ci/setup_windows_ci_environment.ps1
- run: ./ci/do_ci.ps1 cmake.test
- run: ./ci/do_ci.sh cmake.exporter.otprotocol.test

windows_plugin_test:
executor: win/vs2019
Expand Down
20 changes: 20 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,27 @@ 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(BUILD_TESTING)
find_package(GTest REQUIRED)
find_package(benchmark REQUIRED)
Expand All @@ -20,4 +37,7 @@ endif()

include_directories(api/include)
add_subdirectory(api)
include_directories(sdk/include)
include_directories(sdk)
add_subdirectory(sdk)
add_subdirectory(examples)
23 changes: 23 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,29 @@
workspace(name = "io_opentelemetry_cpp")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository")
g-easy marked this conversation as resolved.
Show resolved Hide resolved

# 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_git_repository(
g-easy marked this conversation as resolved.
Show resolved Hide resolved
name = "com_github_opentelemetry_proto",
build_file = "//bazel:opentelemetry_proto.BUILD",
commit = "d496c80b353bc4a4f754ae686b59ca3c41de0946",
remote = "https://github.com/open-telemetry/opentelemetry-proto",
)

# GoogleTest framework.
# Only needed for tests, not to build the OpenTelemetry library.
Expand Down
4 changes: 0 additions & 4 deletions api/include/opentelemetry/plugin/tracer.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ class Span final : public trace::Span
{
span_->AddEvent(name, timestamp);
}
void AddEvent(nostd::string_view name, core::SteadyTimestamp timestamp) noexcept override
{
span_->AddEvent(name, timestamp);
}

void SetStatus(trace::CanonicalCode code, nostd::string_view description) noexcept override
{
Expand Down
1 change: 0 additions & 1 deletion api/include/opentelemetry/trace/noop.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class NoopSpan final : public Span
void AddEvent(nostd::string_view name) noexcept override {}

void AddEvent(nostd::string_view name, core::SystemTimestamp timestamp) noexcept override {}
void AddEvent(nostd::string_view name, core::SteadyTimestamp timestamp) noexcept override {}

void SetStatus(CanonicalCode code, nostd::string_view description) noexcept override {}

Expand Down
1 change: 0 additions & 1 deletion api/include/opentelemetry/trace/span.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ class Span

// Adds an event to the Span, with a custom timestamp.
virtual void AddEvent(nostd::string_view name, core::SystemTimestamp timestamp) noexcept = 0;
virtual void AddEvent(nostd::string_view name, core::SteadyTimestamp timestamp) noexcept = 0;

// TODO
// Adds an event to the Span, with a custom timestamp, and attributes.
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(
g-easy marked this conversation as resolved.
Show resolved Hide resolved
name = "common_proto",
srcs = glob([
g-easy marked this conversation as resolved.
Show resolved Hide resolved
"opentelemetry/proto/common/v1/common.proto",
]),
)

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

proto_library(
name = "resource_proto",
srcs = glob([
"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 = glob([
"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
21 changes: 21 additions & 0 deletions ci/do_ci.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,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
10 changes: 10 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
g-easy marked this conversation as resolved.
Show resolved Hide 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
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
g-easy marked this conversation as resolved.
Show resolved Hide resolved
tar zxf protobuf-cpp-${PROTOBUF_VERSION}.tar.gz --no-same-owner
cd protobuf-${PROTOBUF_VERSION}
./configure
make && make install
ldconfig
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
1 change: 1 addition & 0 deletions ci/setup_windows_ci_environment.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ $VCPKG_DIR=(Get-Item -Path ".\").FullName
./vcpkg integrate install
./vcpkg install benchmark:x64-windows
./vcpkg install gtest:x64-windows
./vcpkg install protobuf:x64-windows
2 changes: 0 additions & 2 deletions examples/plugin/plugin/tracer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ class Span final : public trace::Span

void AddEvent(nostd::string_view /*name*/, core::SystemTimestamp /*timestamp*/) noexcept override
{}
void AddEvent(nostd::string_view /*name*/, core::SteadyTimestamp /*timestamp*/) noexcept override
{}

void SetStatus(trace::CanonicalCode /*code*/,
nostd::string_view /*description*/) noexcept override
Expand Down
5 changes: 5 additions & 0 deletions sdk/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
if(WITH_OTPROTOCOL)
include(proto/opentelemetry/Protobuf.cmake)
endif()

add_subdirectory(src)
48 changes: 48 additions & 0 deletions sdk/proto/opentelemetry/Protobuf.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
set(PROTO_PATH "${CMAKE_SOURCE_DIR}/sdk/proto")

set(COMMON_PROTO "${PROTO_PATH}/opentelemetry/proto/common/v1/common.proto")
set(RESOURCE_PROTO "${PROTO_PATH}/opentelemetry/proto/resource/v1/resource.proto")
set(TRACE_PROTO "${PROTO_PATH}/opentelemetry/proto/trace/v1/trace.proto")

set(GENERATED_PROTOBUF_PATH "${CMAKE_BINARY_DIR}/generated/sdk/proto")

file(MAKE_DIRECTORY "${GENERATED_PROTOBUF_PATH}")

set(COMMON_PB_CPP_FILE "${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/common/v1/common.pb.cc")
set(COMMON_PB_H_FILE "${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/common/v1/common.pb.h")
set(RESOURCE_PB_CPP_FILE "${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/resource/v1/resource.pb.cc")
set(RESOURCE_PB_H_FILE "${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/resource/v1/resource.pb.h")
set(TRACE_PB_CPP_FILE "${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/trace/v1/trace.pb.cc")
set(TRACE_PB_H_FILE "${GENERATED_PROTOBUF_PATH}/opentelemetry/proto/trace/v1/trace.pb.h")

foreach(IMPORT_DIR ${PROTOBUF_IMPORT_DIRS})
list(APPEND PROTOBUF_INCLUDE_FLAGS "-I${IMPORT_DIR}")
endforeach()

add_custom_command(
OUTPUT
${COMMON_PB_H_FILE}
${COMMON_PB_CPP_FILE}
${RESOURCE_PB_H_FILE}
${RESOURCE_PB_CPP_FILE}
${TRACE_PB_H_FILE}
${TRACE_PB_CPP_FILE}
COMMAND ${PROTOBUF_PROTOC_EXECUTABLE}
ARGS
"--proto_path=${PROTO_PATH}"
${PROTOBUF_INCLUDE_FLAGS}
"--cpp_out=${GENERATED_PROTOBUF_PATH}"
${COMMON_PROTO}
${RESOURCE_PROTO}
${TRACE_PROTO}
)

include_directories(SYSTEM "${CMAKE_BINARY_DIR}/generated/sdk/proto")

add_library(opentelemetry_proto OBJECT
${COMMON_PB_CPP_FILE}
${RESOURCE_PB_CPP_FILE}
${TRACE_PB_CPP_FILE})
if (BUILD_SHARED_LIBS)
set_property(TARGET opentelemetry_proto PROPERTY POSITION_INDEPENDENT_CODE ON)
endif()
2 changes: 2 additions & 0 deletions sdk/proto/opentelemetry/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
From: https://github.com/open-telemetry/opentelemetry-proto
g-easy marked this conversation as resolved.
Show resolved Hide resolved
Commit: d496c80b353bc4a4f754ae686b59ca3c41de0946
9 changes: 9 additions & 0 deletions sdk/proto/opentelemetry/proto/collector/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# OpenTelemetry Collector Proto

This package describes the OpenTelemetry collector protocol.

## Packages

1. `common` package contains the common messages shared between different services.
2. `trace` package contains the Trace Service protos.
3. `metrics` package contains the Metrics Service protos.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright 2019, 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.

syntax = "proto3";

package opentelemetry.proto.collector.metrics.v1;

import "opentelemetry/proto/metrics/v1/metrics.proto";

option java_multiple_files = true;
option java_package = "io.opentelemetry.proto.collector.metrics.v1";
option java_outer_classname = "MetricsServiceProto";
option go_package = "github.com/open-telemetry/opentelemetry-proto/gen/go/collector/metrics/v1";

// Service that can be used to push metrics between one Application
// instrumented with OpenTelemetry and a collector, or between a collector and a
// central collector.
service MetricsService {
// For performance reasons, it is recommended to keep this RPC
// alive for the entire life of the application.
rpc Export(ExportMetricsServiceRequest) returns (ExportMetricsServiceResponse) {}
}

message ExportMetricsServiceRequest {
// An array of ResourceMetrics.
// For data coming from a single resource this array will typically contain one
// element. Intermediary nodes (such as OpenTelemetry Collector) that receive
// data from multiple origins typically batch the data before forwarding further and
// in that case this array will contain multiple elements.
repeated opentelemetry.proto.metrics.v1.ResourceMetrics resource_metrics = 1;
}

message ExportMetricsServiceResponse {
}
Loading