diff --git a/.circleci/config.yml b/.circleci/config.yml index 7d972787b8..4c4557583b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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 @@ -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 @@ -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 diff --git a/CMakeLists.txt b/CMakeLists.txt index c10f92d39d..264d58992d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) @@ -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) diff --git a/WORKSPACE b/WORKSPACE index 13176f04b4..1dd2ea37fc 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -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( diff --git a/bazel/opentelemetry_proto.BUILD b/bazel/opentelemetry_proto.BUILD new file mode 100644 index 0000000000..ddb9915bf2 --- /dev/null +++ b/bazel/opentelemetry_proto.BUILD @@ -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( + 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"], +) diff --git a/ci/Dockerfile b/ci/Dockerfile index ffce3429d6..a1f43af928 100644 --- a/ci/Dockerfile +++ b/ci/Dockerfile @@ -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 diff --git a/ci/README.md b/ci/README.md index e985c6e3b8..f755d3f54a 100644 --- a/ci/README.md +++ b/ci/README.md @@ -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. diff --git a/ci/do_ci.ps1 b/ci/do_ci.ps1 index 0663a8da10..1056225ea2 100644 --- a/ci/do_ci.ps1 +++ b/ci/do_ci.ps1 @@ -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 ` diff --git a/ci/do_ci.sh b/ci/do_ci.sh index 85b887467e..6b3205843b 100755 --- a/ci/do_ci.sh +++ b/ci/do_ci.sh @@ -20,6 +20,16 @@ if [[ "$1" == "cmake.test" ]]; then make make test exit 0 +elif [[ "$1" == "cmake.exporter.otprotocol.test" ]]; then + 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}" @@ -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 //... diff --git a/ci/install_protobuf.sh b/ci/install_protobuf.sh new file mode 100755 index 0000000000..71390f9a2a --- /dev/null +++ b/ci/install_protobuf.sh @@ -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 +tar zxf protobuf-cpp-${PROTOBUF_VERSION}.tar.gz --no-same-owner +cd protobuf-${PROTOBUF_VERSION} +./configure +make && make install +ldconfig diff --git a/ci/install_windows_protobuf.ps1 b/ci/install_windows_protobuf.ps1 new file mode 100644 index 0000000000..79ba092781 --- /dev/null +++ b/ci/install_windows_protobuf.ps1 @@ -0,0 +1,5 @@ +$ErrorActionPreference = "Stop" +trap { $host.SetShouldExit(1) } + +cd vcpkg +./vcpkg install protobuf:x64-windows diff --git a/ci/setup_ci_environment.sh b/ci/setup_ci_environment.sh index 56be9af1f3..50c7b373e9 100755 --- a/ci/setup_ci_environment.sh +++ b/ci/setup_ci_environment.sh @@ -5,4 +5,5 @@ apt-get update apt-get install --no-install-recommends --no-install-suggests -y \ build-essential \ ca-certificates \ - wget + wget \ + git diff --git a/exporters/CMakeLists.txt b/exporters/CMakeLists.txt new file mode 100644 index 0000000000..c70dee5473 --- /dev/null +++ b/exporters/CMakeLists.txt @@ -0,0 +1,3 @@ +if(WITH_OTPROTOCOL) + add_subdirectory(otlp) +endif() diff --git a/exporters/otlp/BUILD b/exporters/otlp/BUILD new file mode 100644 index 0000000000..09b1516ab5 --- /dev/null +++ b/exporters/otlp/BUILD @@ -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", + ], +) diff --git a/exporters/otlp/CMakeLists.txt b/exporters/otlp/CMakeLists.txt new file mode 100644 index 0000000000..07311ce909 --- /dev/null +++ b/exporters/otlp/CMakeLists.txt @@ -0,0 +1,3 @@ +add_library(opentelemetry_exporter_otprotocol recordable.cc) +target_link_libraries(opentelemetry_exporter_otprotocol + $) diff --git a/exporters/otlp/recordable.cc b/exporters/otlp/recordable.cc new file mode 100644 index 0000000000..d38f284577 --- /dev/null +++ b/exporters/otlp/recordable.cc @@ -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 diff --git a/exporters/otlp/recordable.h b/exporters/otlp/recordable.h new file mode 100644 index 0000000000..5ea1edf497 --- /dev/null +++ b/exporters/otlp/recordable.h @@ -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 diff --git a/sdk/src/trace/recordable.h b/sdk/include/opentelemetry/sdk/trace/recordable.h similarity index 99% rename from sdk/src/trace/recordable.h rename to sdk/include/opentelemetry/sdk/trace/recordable.h index a7298200a5..32646a3bbe 100644 --- a/sdk/src/trace/recordable.h +++ b/sdk/include/opentelemetry/sdk/trace/recordable.h @@ -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. * diff --git a/sdk/src/trace/recorder.h b/sdk/src/trace/recorder.h index b701c113d6..22730a74cb 100644 --- a/sdk/src/trace/recorder.h +++ b/sdk/src/trace/recorder.h @@ -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 diff --git a/sdk/src/trace/span.h b/sdk/src/trace/span.h index f4f924aa33..26d74f426a 100644 --- a/sdk/src/trace/span.h +++ b/sdk/src/trace/span.h @@ -1,10 +1,10 @@ #pragma once +#include + #include "opentelemetry/version.h" #include "src/trace/tracer.h" -#include - OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk { diff --git a/third_party/opentelemetry-proto/Protobuf.cmake b/third_party/opentelemetry-proto/Protobuf.cmake new file mode 100644 index 0000000000..50a174f1fc --- /dev/null +++ b/third_party/opentelemetry-proto/Protobuf.cmake @@ -0,0 +1,48 @@ +set(PROTO_PATH "${CMAKE_SOURCE_DIR}/third_party/opentelemetry-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/third_party/opentelemetry-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/third_party/opentelemetry-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() diff --git a/third_party/opentelemetry-proto/README b/third_party/opentelemetry-proto/README new file mode 100644 index 0000000000..dfd3a68e21 --- /dev/null +++ b/third_party/opentelemetry-proto/README @@ -0,0 +1,2 @@ +From: https://github.com/open-telemetry/opentelemetry-proto +Commit: d496c80b353bc4a4f754ae686b59ca3c41de0946 diff --git a/third_party/opentelemetry-proto/opentelemetry/proto/collector/README.md b/third_party/opentelemetry-proto/opentelemetry/proto/collector/README.md new file mode 100644 index 0000000000..4a73a31ed8 --- /dev/null +++ b/third_party/opentelemetry-proto/opentelemetry/proto/collector/README.md @@ -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. diff --git a/third_party/opentelemetry-proto/opentelemetry/proto/collector/metrics/v1/metrics_service.proto b/third_party/opentelemetry-proto/opentelemetry/proto/collector/metrics/v1/metrics_service.proto new file mode 100644 index 0000000000..5a3cbee4c9 --- /dev/null +++ b/third_party/opentelemetry-proto/opentelemetry/proto/collector/metrics/v1/metrics_service.proto @@ -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 { +} diff --git a/third_party/opentelemetry-proto/opentelemetry/proto/collector/trace/v1/trace_service.proto b/third_party/opentelemetry-proto/opentelemetry/proto/collector/trace/v1/trace_service.proto new file mode 100644 index 0000000000..16784c666a --- /dev/null +++ b/third_party/opentelemetry-proto/opentelemetry/proto/collector/trace/v1/trace_service.proto @@ -0,0 +1,48 @@ +// 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"; + +// NOTE: This proto is experimental and is subject to change at this point. +// Please do not use it at the moment. + +package opentelemetry.proto.collector.trace.v1; + +import "opentelemetry/proto/trace/v1/trace.proto"; + +option java_multiple_files = true; +option java_package = "io.opentelemetry.proto.collector.trace.v1"; +option java_outer_classname = "TraceServiceProto"; +option go_package = "github.com/open-telemetry/opentelemetry-proto/gen/go/collector/trace/v1"; + +// Service that can be used to push spans between one Application instrumented with +// OpenTelemetry and an collector, or between an collector and a central collector (in this +// case spans are sent/received to/from multiple Applications). +service TraceService { + // For performance reasons, it is recommended to keep this RPC + // alive for the entire life of the application. + rpc Export(ExportTraceServiceRequest) returns (ExportTraceServiceResponse) {} +} + +message ExportTraceServiceRequest { + // An array of ResourceSpans. + // 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.trace.v1.ResourceSpans resource_spans = 1; +} + +message ExportTraceServiceResponse { +} diff --git a/third_party/opentelemetry-proto/opentelemetry/proto/collector/trace/v1/trace_service_http.yaml b/third_party/opentelemetry-proto/opentelemetry/proto/collector/trace/v1/trace_service_http.yaml new file mode 100644 index 0000000000..7754e5ff12 --- /dev/null +++ b/third_party/opentelemetry-proto/opentelemetry/proto/collector/trace/v1/trace_service_http.yaml @@ -0,0 +1,12 @@ +# This is an API configuration to generate an HTTP/JSON -> gRPC gateway for the +# OpenTelemetry service using github.com/grpc-ecosystem/grpc-gateway. +type: google.api.Service +config_version: 3 +http: + rules: + - selector: opentelemetry.proto.collector.trace.v1.TraceService.Export + post: /v1/trace + body: "*" + - selector: opentelemetry.proto.collector.metrics.v1.MetricsService.Export + post: /v1/trace + body: "*" \ No newline at end of file diff --git a/third_party/opentelemetry-proto/opentelemetry/proto/common/v1/common.proto b/third_party/opentelemetry-proto/opentelemetry/proto/common/v1/common.proto new file mode 100644 index 0000000000..b3b1852459 --- /dev/null +++ b/third_party/opentelemetry-proto/opentelemetry/proto/common/v1/common.proto @@ -0,0 +1,55 @@ +// 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.common.v1; + +option java_multiple_files = true; +option java_package = "io.opentelemetry.proto.common.v1"; +option java_outer_classname = "CommonProto"; +option go_package = "github.com/open-telemetry/opentelemetry-proto/gen/go/common/v1"; + +// AttributeKeyValue is a key-value pair that is used to store Span attributes, Link +// attributes, etc. +message AttributeKeyValue { + // ValueType is the enumeration of possible types that value can have. + enum ValueType { + STRING = 0; + INT = 1; + DOUBLE = 2; + BOOL = 3; + }; + + // key part of the key-value pair. + string key = 1; + + // type of the value. + ValueType type = 2; + + // Only one of the following fields is supposed to contain data (determined by `type` field). + // This is deliberately not using Protobuf `oneof` for performance reasons (verified by benchmarks). + + string string_value = 3; + int64 int_value = 4; + double double_value = 5; + bool bool_value = 6; +} + +// StringKeyValue is a pair of key/value strings. This is the simpler (and faster) version +// of AttributeKeyValue that only supports string values. +message StringKeyValue { + string key = 1; + string value = 2; +} diff --git a/third_party/opentelemetry-proto/opentelemetry/proto/metrics/v1/metrics.proto b/third_party/opentelemetry-proto/opentelemetry/proto/metrics/v1/metrics.proto new file mode 100644 index 0000000000..a15a7b6c2b --- /dev/null +++ b/third_party/opentelemetry-proto/opentelemetry/proto/metrics/v1/metrics.proto @@ -0,0 +1,355 @@ +// 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.metrics.v1; + +import "opentelemetry/proto/common/v1/common.proto"; +import "opentelemetry/proto/resource/v1/resource.proto"; + +option java_multiple_files = true; +option java_package = "io.opentelemetry.proto.metrics.v1"; +option java_outer_classname = "MetricsProto"; +option go_package = "github.com/open-telemetry/opentelemetry-proto/gen/go/metrics/v1"; + +// A collection of metrics from a Resource. +message ResourceMetrics { + // A list of metrics that originate from a resource. + repeated Metric metrics = 1; + + // The resource for the metrics in this message. + // If this field is not set then no resource info is known. + opentelemetry.proto.resource.v1.Resource resource = 2; +} + +// Defines a Metric which has one or more timeseries. +// +// The data model and relation between entities is shown in the diagram below. +// +// - Metric is composed of a MetricDescriptor and a list of data points. +// - MetricDescriptor contains a list of label keys (shown horizontally). +// - Data is a list of DataPoints (shown vertically). +// - DataPoint contains a list of label values and a value. +// +// Metric +// +----------+ +------------------------+ +// |descriptor|-------->| MetricDescriptor | +// | | |+-----+-----+ +-----+ | +// | | ||label|label|...|label| | +// | data|--+ ||key1 |key2 | |keyN | | +// +----------+ | |+-----+-----+ +-----+ | +// | +------------------------+ +// | +// | +---------------------------+ +// | |DataPoint 1 | +// v |+------+------+ +------+ | +// +-----+ ||label |label |...|label | | +// | 1 |-->||value1|value2|...|valueN| | +// +-----+ |+------+------+ +------+ | +// | . | |+-----+ | +// | . | ||value| | +// | . | |+-----+ | +// | . | +---------------------------+ +// | . | . +// | . | . +// | . | . +// | . | +---------------------------+ +// | . | |DataPoint M | +// +-----+ |+------+------+ +------+ | +// | M |-->||label |label |...|label | | +// +-----+ ||value1|value2|...|valueN| | +// |+------+------+ +------+ | +// |+-----+ | +// ||value| | +// |+-----+ | +// +---------------------------+ +// +//----------------------------------------------------------------------- +// DataPoint is a value of specific type corresponding to a given moment in +// time. Each DataPoint is timestamped. +// +// DataPoint is strongly typed: each DataPoint type has a specific Protobuf message +// depending on the value type of the metric and thus there are currently 4 DataPoint +// messages, which correspond to the types of metric values. +message Metric { + // metric_descriptor describes the Metric. + MetricDescriptor metric_descriptor = 1; + + // Data is a list of one or more DataPoints for a single metric. Only one of the + // following fields is used for the data, depending on the type of the metric defined + // by MetricDescriptor.type field. + repeated Int64DataPoint int64_datapoints = 2; + repeated DoubleDataPoint double_datapoints = 3; + repeated HistogramDataPoint histogram_datapoints = 4; + repeated SummaryDataPoint summary_datapoints = 5; +} + +// Defines a metric type and its schema. +message MetricDescriptor { + // name of the metric, including its DNS name prefix. It must be unique. + string name = 1; + + // description of the metric, which can be used in documentation. + string description = 2; + + // unit in which the metric value is reported. Follows the format + // described by http://unitsofmeasure.org/ucum.html. + string unit = 3; + + // Type of the metric. It describes how the data is reported. + // + // A gauge is an instantaneous measurement of a value. + // + // A counter/cumulative measurement is a value accumulated over a time + // interval. In a time series, cumulative measurements should have the same + // start time, increasing values, until an event resets the cumulative value + // to zero and sets a new start time for the subsequent points. + enum Type { + // Do not use this default value. + UNSPECIFIED = 0; + + // Integer gauge. The value can go both up and down over time. + // Corresponding values are stored in Int64DataPoint. + GAUGE_INT64 = 1; + + // Floating point gauge. The value can go both up and down over time. + // Corresponding values are stored in DoubleDataPoint. + GAUGE_DOUBLE = 2; + + // Histogram gauge measurement. + // Used in scenarios like a snapshot of time that current items in a queue + // have spent there. + // Corresponding values are stored in HistogramDataPoint. The count and sum of the + // histogram can go both up and down over time. Recorded values are always >= 0. + GAUGE_HISTOGRAM = 3; + + // Integer counter measurement. The value cannot decrease; if value is reset then + // start_time_unixnano should also be reset. + // Corresponding values are stored in Int64DataPoint. + COUNTER_INT64 = 4; + + // Floating point counter measurement. The value cannot decrease, if + // resets then the start_time_unixnano should also be reset. + // Recorded values are always >= 0. + // Corresponding values are stored in DoubleDataPoint. + COUNTER_DOUBLE = 5; + + // Histogram cumulative measurement. + // Corresponding values are stored in HistogramDataPoint. The count and sum of the + // histogram cannot decrease; if values are reset then start_time_unixnano + // should also be reset to the new start timestamp. + CUMULATIVE_HISTOGRAM = 6; + + // Summary value. Some frameworks implemented Histograms as a summary of observations + // (usually things like request durations and response sizes). While it + // also provides a total count of observations and a sum of all observed + // values, it calculates configurable percentiles over a sliding time + // window. + // Corresponding values are stored in SummaryDataPoint. + SUMMARY = 7; + } + Type type = 4; + + // The set of labels associated with the metric descriptor. Labels in this list apply to + // all data points. + repeated opentelemetry.proto.common.v1.StringKeyValue labels = 5; +} + +// Int64DataPoint is a single data point in a timeseries that describes the time-varying +// values of a int64 metric. +message Int64DataPoint { + // The set of labels that uniquely identify this timeseries. + repeated opentelemetry.proto.common.v1.StringKeyValue labels = 1; + + // start_time_unixnano is the time when the cumulative value was reset to zero. + // This is used for Counter type only. For Gauge the value is not specified and + // defaults to 0. + // + // The cumulative value is over the time interval (start_time_unixnano, timestamp_unixnano]. + // Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970. + // + // Value of 0 indicates that the timestamp is unspecified. In that case the timestamp + // may be decided by the backend. + fixed64 start_time_unixnano = 2; + + // timestamp_unixnano is the moment when this value was recorded. + // Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970. + fixed64 timestamp_unixnano = 3; + + // value itself. + int64 value = 4; +} + +// DoubleDataPoint is a single data point in a timeseries that describes the time-varying +// value of a double metric. +message DoubleDataPoint { + // The set of labels that uniquely identify this timeseries. + repeated opentelemetry.proto.common.v1.StringKeyValue labels = 1; + + // start_time_unixnano is the time when the cumulative value was reset to zero. + // This is used for Counter type only. For Gauge the value is not specified and + // defaults to 0. + // + // The cumulative value is over the time interval (start_time_unixnano, timestamp_unixnano]. + // Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970. + // + // Value of 0 indicates that the timestamp is unspecified. In that case the timestamp + // may be decided by the backend. + fixed64 start_time_unixnano = 2; + + // timestamp_unixnano is the moment when this value was recorded. + // Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970. + fixed64 timestamp_unixnano = 3; + + // value itself. + double value = 4; +} + +// HistogramDataPoint is a single data point in a timeseries that describes the time-varying +// values of a Histogram. A Histogram contains summary statistics for a population of values, +// it may optionally contain the distribution of those values across a set of buckets. +message HistogramDataPoint { + // The set of labels that uniquely identify this timeseries. + repeated opentelemetry.proto.common.v1.StringKeyValue labels = 1; + + // start_time_unixnano is the time when the cumulative value was reset to zero. + // + // The cumulative value is over the time interval (start_time_unixnano, timestamp_unixnano]. + // Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970. + // + // Value of 0 indicates that the timestamp is unspecified. In that case the timestamp + // may be decided by the backend. + // Note: this field is always unspecified and ignored if MetricDescriptor.type==GAUGE_HISTOGRAM. + fixed64 start_time_unixnano = 2; + + // timestamp_unixnano is the moment when this value was recorded. + // Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970. + fixed64 timestamp_unixnano = 3; + + // count is the number of values in the population. Must be non-negative. This value + // must be equal to the sum of the "count" fields in buckets if a histogram is provided. + uint64 count = 4; + + // sum of the values in the population. If count is zero then this field + // must be zero. This value must be equal to the sum of the "sum" fields in buckets if + // a histogram is provided. + double sum = 5; + + // Bucket contains values for a bucket. + message Bucket { + // The number of values in each bucket of the histogram, as described by + // bucket_options. + uint64 count = 1; + + // Exemplars are example points that may be used to annotate aggregated + // Histogram values. They are metadata that gives information about a + // particular value added to a Histogram bucket. + message Exemplar { + // Value of the exemplar point. It determines which bucket the exemplar belongs to. + // If bucket_options define bounds for this bucket then this value must be within + // the defined bounds. + double value = 1; + + // timestamp_unixnano is the moment when this exemplar was recorded. + // Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970. + fixed64 timestamp_unixnano = 2; + + // exemplar_attachments are contextual information about the example value. + // Keys in this list must be unique. + repeated opentelemetry.proto.common.v1.StringKeyValue attachments = 3; + } + + // exemplar is an optional representative value of the bucket. + Exemplar exemplar = 2; + } + + // buckets is an optional field contains the values of histogram for each bucket. + // + // The sum of the values in the buckets "count" field must equal the value in the count field. + // + // The number of elements in buckets array must be by one greater than the + // number of elements in bucket_bounds array. + // + // Note: if HistogramDataPoint.bucket_options defines bucket bounds then this field + // must also be present and number of elements in this field must be equal to the + // number of buckets defined by bucket_options. + repeated Bucket buckets = 6; + + // A histogram may optionally contain the distribution of the values in the population. + // In that case one of the option fields below and "buckets" field both must be defined. + // Otherwise all option fields and "buckets" field must be omitted in which case the + // distribution of values in the histogram is unknown and only the total count and sum are known. + + // explicit_bounds is the only supported bucket option currently. + // TODO: Add more bucket options. + + // explicit_bounds specifies buckets with explicitly defined bounds for values. + // The bucket boundaries are described by "bounds" field. + // + // This defines size(bounds) + 1 (= N) buckets. The boundaries for bucket + // at index i are: + // + // [0, bounds[i]) for i == 0 + // [bounds[i-1], bounds[i]) for 0 < i < N-1 + // [bounds[i], +infinity) for i == N-1 + // The values in bounds array must be strictly increasing and > 0. + // + // Note: only [a, b) intervals are currently supported for each bucket. If we decides + // to also support (a, b] intervals we should add support for these by defining a boolean + // value which decides what type of intervals to use. + repeated double explicit_bounds = 7; +} + +// SummaryDataPoint is a single data point in a timeseries that describes the time-varying +// values of a Summary metric. +message SummaryDataPoint { + // The set of labels that uniquely identify this timeseries. + repeated opentelemetry.proto.common.v1.StringKeyValue labels = 1; + + // start_time_unixnano is the time when the cumulative value was reset to zero. + // + // The cumulative value is over the time interval (start_time_unixnano, timestamp_unixnano]. + // Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970. + // + // Value of 0 indicates that the timestamp is unspecified. In that case the timestamp + // may be decided by the backend. + fixed64 start_time_unixnano = 2; + + // timestamp_unixnano is the moment when this value was recorded. + // Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970. + fixed64 timestamp_unixnano = 3; + + // The total number of recorded values since start_time. Optional since + // some systems don't expose this. + uint64 count = 4; + + // The total sum of recorded values since start_time. Optional since some + // systems don't expose this. If count is zero then this field must be zero. + double sum = 5; + + // Represents the value at a given percentile of a distribution. + message ValueAtPercentile { + // The percentile of a distribution. Must be in the interval + // [0.0, 100.0]. + double percentile = 1; + + // The value at the given percentile of a distribution. + double value = 2; + } + + // A list of values at different percentiles of the distribution calculated + // from the current snapshot. The percentiles must be strictly increasing. + repeated ValueAtPercentile percentile_values = 6; +} diff --git a/third_party/opentelemetry-proto/opentelemetry/proto/resource/v1/resource.proto b/third_party/opentelemetry-proto/opentelemetry/proto/resource/v1/resource.proto new file mode 100644 index 0000000000..a9e1711af4 --- /dev/null +++ b/third_party/opentelemetry-proto/opentelemetry/proto/resource/v1/resource.proto @@ -0,0 +1,34 @@ +// 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.resource.v1; + +import "opentelemetry/proto/common/v1/common.proto"; + +option java_multiple_files = true; +option java_package = "io.opentelemetry.proto.resource.v1"; +option java_outer_classname = "ResourceProto"; +option go_package = "github.com/open-telemetry/opentelemetry-proto/gen/go/resource/v1"; + +// Resource information. +message Resource { + // Set of labels that describe the resource. + repeated opentelemetry.proto.common.v1.AttributeKeyValue attributes = 1; + + // dropped_attributes_count is the number of dropped attributes. If the value is 0, then + // no attributes were dropped. + uint32 dropped_attributes_count = 2; +} diff --git a/third_party/opentelemetry-proto/opentelemetry/proto/trace/v1/trace.proto b/third_party/opentelemetry-proto/opentelemetry/proto/trace/v1/trace.proto new file mode 100644 index 0000000000..7f0e4a75c0 --- /dev/null +++ b/third_party/opentelemetry-proto/opentelemetry/proto/trace/v1/trace.proto @@ -0,0 +1,251 @@ +// 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.trace.v1; + +import "opentelemetry/proto/common/v1/common.proto"; +import "opentelemetry/proto/resource/v1/resource.proto"; + +option java_multiple_files = true; +option java_package = "io.opentelemetry.proto.trace.v1"; +option java_outer_classname = "TraceProto"; +option go_package = "github.com/open-telemetry/opentelemetry-proto/gen/go/trace/v1"; + +// A collection of spans from a Resource. +message ResourceSpans { + // The resource for the spans in this message. + // If this field is not set then no resource info is known. + opentelemetry.proto.resource.v1.Resource resource = 1; + + // A list of Spans that originate from a resource. + repeated Span spans = 2; +} + +// Span represents a single operation within a trace. Spans can be +// nested to form a trace tree. Spans may also be linked to other spans +// from the same or different trace and form graphs. Often, a trace +// contains a root span that describes the end-to-end latency, and one +// or more subspans for its sub-operations. A trace can also contain +// multiple root spans, or none at all. Spans do not need to be +// contiguous - there may be gaps or overlaps between spans in a trace. +// +// The next available field id is 17. +message Span { + // A unique identifier for a trace. All spans from the same trace share + // the same `trace_id`. The ID is a 16-byte array. An ID with all zeroes + // is considered invalid. + // + // This field is semantically required. Receiver should generate new + // random trace_id if empty or invalid trace_id was received. + // + // This field is required. + bytes trace_id = 1; + + // A unique identifier for a span within a trace, assigned when the span + // is created. The ID is an 8-byte array. An ID with all zeroes is considered + // invalid. + // + // This field is semantically required. Receiver should generate new + // random span_id if empty or invalid span_id was received. + // + // This field is required. + bytes span_id = 2; + + // trace_state conveys information about request position in multiple distributed tracing graphs. + // It is a trace_state in w3c-trace-context format: https://www.w3.org/TR/trace-context/#tracestate-header + // See also https://github.com/w3c/distributed-tracing for more details about this field. + string trace_state = 3; + + // The `span_id` of this span's parent span. If this is a root span, then this + // field must be empty. The ID is an 8-byte array. + bytes parent_span_id = 4; + + // A description of the span's operation. + // + // For example, the name can be a qualified method name or a file name + // and a line number where the operation is called. A best practice is to use + // the same display name at the same call point in an application. + // This makes it easier to correlate spans in different traces. + // + // This field is semantically required to be set to non-empty string. + // When null or empty string received - receiver may use string "name" + // as a replacement. There might be smarted algorithms implemented by + // receiver to fix the empty span name. + // + // This field is required. + string name = 5; + + // SpanKind is the type of span. Can be used to specify additional relationships between spans + // in addition to a parent/child relationship. + enum SpanKind { + // Unspecified. Do NOT use as default. + // Implementations MAY assume SpanKind to be INTERNAL when receiving UNSPECIFIED. + SPAN_KIND_UNSPECIFIED = 0; + + // Indicates that the span represents an internal operation within an application, + // as opposed to an operations happening at the boundaries. Default value. + INTERNAL = 1; + + // Indicates that the span covers server-side handling of an RPC or other + // remote network request. + SERVER = 2; + + // Indicates that the span describes a request to some remote service. + CLIENT = 3; + + // Indicates that the span describes a producer sending a message to a broker. + // Unlike CLIENT and SERVER, there is often no direct critical path latency relationship + // between producer and consumer spans. A PRODUCER span ends when the message was accepted + // by the broker while the logical processing of the message might span a much longer time. + PRODUCER = 4; + + // Indicates that the span describes consumer receiving a message from a broker. + // Like the PRODUCER kind, there is often no direct critical path latency relationship + // between producer and consumer spans. + CONSUMER = 5; + } + + // Distinguishes between spans generated in a particular context. For example, + // two spans with the same name may be distinguished using `CLIENT` (caller) + // and `SERVER` (callee) to identify queueing latency associated with the span. + SpanKind kind = 6; + + // start_time_unixnano is the start time of the span. On the client side, this is the time + // kept by the local machine where the span execution starts. On the server side, this + // is the time when the server's application handler starts running. + // Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970. + // + // This field is semantically required and it is expected that end_time >= start_time. + fixed64 start_time_unixnano = 7; + + // end_time_unixnano is the end time of the span. On the client side, this is the time + // kept by the local machine where the span execution ends. On the server side, this + // is the time when the server application handler stops running. + // Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970. + // + // This field is semantically required and it is expected that end_time >= start_time. + fixed64 end_time_unixnano = 8; + + // attributes is a collection of key/value pairs. The value can be a string, + // an integer, a double or the Boolean values `true` or `false`. Note, global attributes + // like server name can be set using the resource API. Examples of attributes: + // + // "/http/user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36" + // "/http/server_latency": 300 + // "abc.com/myattribute": true + // "abc.com/score": 10.239 + repeated opentelemetry.proto.common.v1.AttributeKeyValue attributes = 9; + + // dropped_attributes_count is the number of attributes that were discarded. Attributes + // can be discarded because their keys are too long or because there are too many + // attributes. If this value is 0, then no attributes were dropped. + uint32 dropped_attributes_count = 10; + + // Event is a time-stamped annotation of the span, consisting of user-supplied + // text description and key-value pairs. + message Event { + // time_unixnano is the time the event occurred. + fixed64 time_unixnano = 1; + + // name of the event. + // This field is semantically required to be set to non-empty string. + string name = 2; + + // attributes is a collection of attribute key/value pairs on the event. + repeated opentelemetry.proto.common.v1.AttributeKeyValue attributes = 3; + + // dropped_attributes_count is the number of dropped attributes. If the value is 0, + // then no attributes were dropped. + uint32 dropped_attributes_count = 4; + } + + // events is a collection of Event items. + repeated Event events = 11; + + // dropped_events_count is the number of dropped events. If the value is 0, then no + // events were dropped. + uint32 dropped_events_count = 12; + + // A pointer from the current span to another span in the same trace or in a + // different trace. For example, this can be used in batching operations, + // where a single batch handler processes multiple requests from different + // traces or when the handler receives a request from a different project. + message Link { + // A unique identifier of a trace that this linked span is part of. The ID is a + // 16-byte array. + bytes trace_id = 1; + + // A unique identifier for the linked span. The ID is an 8-byte array. + bytes span_id = 2; + + // The trace_state associated with the link. + string trace_state = 3; + + // attributes is a collection of attribute key/value pairs on the link. + repeated opentelemetry.proto.common.v1.AttributeKeyValue attributes = 4; + + // dropped_attributes_count is the number of dropped attributes. If the value is 0, + // then no attributes were dropped. + uint32 dropped_attributes_count = 5; + } + + // links is a collection of Links, which are references from this span to a span + // in the same or different trace. + repeated Link links = 13; + + // dropped_links_count is the number of dropped links after the maximum size was + // enforced. If this value is 0, then no links were dropped. + uint32 dropped_links_count = 14; + + // An optional final status for this span. Semantically when Status + // wasn't set it is means span ended without errors and assume + // Status.Ok (code = 0). + Status status = 15; +} + +// The Status type defines a logical error model that is suitable for different +// programming environments, including REST APIs and RPC APIs. +message Status { + + // StatusCode mirrors the codes defined at + // https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/api-tracing.md#statuscanonicalcode + enum StatusCode { + Ok = 0; + Cancelled = 1; + UnknownError = 2; + InvalidArgument = 3; + DeadlineExceeded = 4; + NotFound = 5; + AlreadyExists = 6; + PermissionDenied = 7; + ResourceExhausted = 8; + FailedPrecondition = 9; + Aborted = 10; + OutOfRange = 11; + Unimplemented = 12; + InternalError = 13; + Unavailable = 14; + DataLoss = 15; + Unauthenticated = 16; + }; + + // The status code. This is optional field. It is safe to assume 0 (OK) + // when not set. + StatusCode code = 1; + + // A developer-facing human readable error message. + string message = 2; +} diff --git a/third_party/opentelemetry-proto/opentelemetry/proto/trace/v1/trace_config.proto b/third_party/opentelemetry-proto/opentelemetry/proto/trace/v1/trace_config.proto new file mode 100644 index 0000000000..7269da1ee8 --- /dev/null +++ b/third_party/opentelemetry-proto/opentelemetry/proto/trace/v1/trace_config.proto @@ -0,0 +1,78 @@ +// 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.trace.v1; + +option java_multiple_files = true; +option java_package = "io.opentelemetry.proto.trace.v1"; +option java_outer_classname = "TraceConfigProto"; +option go_package = "github.com/open-telemetry/opentelemetry-proto/gen/go/collector/trace/v1"; + +// Global configuration of the trace service. All fields must be specified, or +// the default (zero) values will be used for each type. +message TraceConfig { + + // The global default sampler used to make decisions on span sampling. + oneof sampler { + ConstantSampler constant_sampler = 1; + + ProbabilitySampler probability_sampler = 2; + + RateLimitingSampler rate_limiting_sampler = 3; + } + + // The global default max number of attributes per span. + int64 max_number_of_attributes = 4; + + // The global default max number of annotation events per span. + int64 max_number_of_timed_events= 5; + + // The global default max number of attributes per timed event. + int64 max_number_of_attributes_per_timed_event = 6; + + // The global default max number of link entries per span. + int64 max_number_of_links = 7; + + // The global default max number of attributes per span. + int64 max_number_of_attributes_per_link = 8; +} + +// Sampler that always makes a constant decision on span sampling. +message ConstantSampler { + // How spans should be sampled: + // - Always off + // - Always on + // - Always follow the parent Span's decision (off if no parent). + enum ConstantDecision { + ALWAYS_OFF = 0; + ALWAYS_ON = 1; + ALWAYS_PARENT = 2; + } + ConstantDecision decision = 1; +} + +// Sampler that tries to uniformly sample traces with a given probability. +// The probability of sampling a trace is equal to that of the specified probability. +message ProbabilitySampler { + // The desired probability of sampling. Must be within [0.0, 1.0]. + double samplingProbability = 1; +} + +// Sampler that tries to sample with a rate per time window. +message RateLimitingSampler { + // Rate per second. + int64 qps = 1; +}