You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by li...@apache.org on 2022/07/27 11:36:40 UTC
[rocketmq-clients] branch cpp_cmake updated: WIP: build stats with cmake
This is an automated email from the ASF dual-hosted git repository.
lizhanhui pushed a commit to branch cpp_cmake
in repository https://gitbox.apache.org/repos/asf/rocketmq-clients.git
The following commit(s) were added to refs/heads/cpp_cmake by this push:
new 7927146 WIP: build stats with cmake
7927146 is described below
commit 79271466c476140b803dd769d25fc3a78775b7d9
Author: Li Zhanhui <li...@gmail.com>
AuthorDate: Wed Jul 27 19:36:32 2022 +0800
WIP: build stats with cmake
---
cpp/source/CMakeLists.txt | 2 +
cpp/source/client/CMakeLists.txt | 2 +-
cpp/source/rocketmq/CMakeLists.txt | 18 +
cpp/source/rocketmq/Producer.cpp | 3 +-
cpp/source/rocketmq/StaticNameServerResolver.cpp | 3 +-
cpp/source/{client => stats}/CMakeLists.txt | 20 +-
cpp/source/stats/MetricBidiReactor.cpp | 3 +-
cpp/source/stats/StdoutHandler.cpp | 4 +-
cpp/third_party/CMakeLists.txt | 3 +-
cpp/third_party/opencensus/proto/CMakeLists.txt | 21 ++
.../proto/opencensus/proto/agent/README.md | 13 +
.../opencensus/proto/agent/common/v1/BUILD.bazel | 34 ++
.../opencensus/proto/agent/common/v1/common.proto | 98 +++++
.../opencensus/proto/agent/metrics/v1/BUILD.bazel | 55 +++
.../proto/agent/metrics/v1/metrics_service.proto | 56 +++
.../opencensus/proto/agent/trace/v1/BUILD.bazel | 56 +++
.../proto/agent/trace/v1/trace_service.proto | 85 +++++
.../proto/agent/trace/v1/trace_service_http.yaml | 9 +
.../proto/opencensus/proto/metrics/v1/BUILD.bazel | 48 +++
.../opencensus/proto/metrics/v1/metrics.proto | 301 +++++++++++++++
.../proto/opencensus/proto/resource/v1/BUILD.bazel | 38 ++
.../opencensus/proto/resource/v1/resource.proto | 33 ++
.../proto/opencensus/proto/stats/v1/BUILD.bazel | 45 +++
.../proto/opencensus/proto/stats/v1/stats.proto | 136 +++++++
.../proto/opencensus/proto/trace/v1/BUILD.bazel | 83 ++++
.../proto/opencensus/proto/trace/v1/trace.proto | 417 +++++++++++++++++++++
.../opencensus/proto/trace/v1/trace_config.proto | 79 ++++
27 files changed, 1648 insertions(+), 17 deletions(-)
diff --git a/cpp/source/CMakeLists.txt b/cpp/source/CMakeLists.txt
index 742a345..6c1b432 100644
--- a/cpp/source/CMakeLists.txt
+++ b/cpp/source/CMakeLists.txt
@@ -4,6 +4,8 @@ add_subdirectory(client)
add_subdirectory(concurrent)
add_subdirectory(log)
add_subdirectory(scheduler)
+add_subdirectory(stats)
+#add_subdirectory(rocketmq)
add_library(rocketmq
$<TARGET_OBJECTS:admin>
diff --git a/cpp/source/client/CMakeLists.txt b/cpp/source/client/CMakeLists.txt
index 95cf267..7b06197 100644
--- a/cpp/source/client/CMakeLists.txt
+++ b/cpp/source/client/CMakeLists.txt
@@ -1,7 +1,7 @@
file(GLOB SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
add_library(client OBJECT ${SRC_FILES})
target_include_directories(client
- PRIVATE
+ PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include)
target_link_libraries(client
PRIVATE
diff --git a/cpp/source/rocketmq/CMakeLists.txt b/cpp/source/rocketmq/CMakeLists.txt
index e69de29..52411de 100644
--- a/cpp/source/rocketmq/CMakeLists.txt
+++ b/cpp/source/rocketmq/CMakeLists.txt
@@ -0,0 +1,18 @@
+file(GLOB SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
+
+add_library(impl OBJECT ${SRC_FILES})
+target_include_directories(impl
+ PRIVATE
+ ${CMAKE_CURRENT_SOURCE_DIR}/include)
+target_link_libraries(impl
+ PRIVATE
+ api
+ absl::strings
+ base
+ fmt
+ proto
+ client
+ opencensus_api
+ scheduler
+ spdlog
+ )
\ No newline at end of file
diff --git a/cpp/source/rocketmq/Producer.cpp b/cpp/source/rocketmq/Producer.cpp
index ce007bc..147fc8b 100644
--- a/cpp/source/rocketmq/Producer.cpp
+++ b/cpp/source/rocketmq/Producer.cpp
@@ -21,7 +21,8 @@
#include <system_error>
#include <utility>
-#include "LoggerImpl.h"
+#include "rocketmq/Logger.h"
+#include "spdlog/spdlog.h"
#include "MixAll.h"
#include "ProducerImpl.h"
#include "StaticNameServerResolver.h"
diff --git a/cpp/source/rocketmq/StaticNameServerResolver.cpp b/cpp/source/rocketmq/StaticNameServerResolver.cpp
index c7f0804..8f2d255 100644
--- a/cpp/source/rocketmq/StaticNameServerResolver.cpp
+++ b/cpp/source/rocketmq/StaticNameServerResolver.cpp
@@ -18,7 +18,8 @@
#include "absl/strings/str_split.h"
-#include "LoggerImpl.h"
+#include "rocketmq/Logger.h"
+#include "spdlog/spdlog.h"
ROCKETMQ_NAMESPACE_BEGIN
diff --git a/cpp/source/client/CMakeLists.txt b/cpp/source/stats/CMakeLists.txt
similarity index 50%
copy from cpp/source/client/CMakeLists.txt
copy to cpp/source/stats/CMakeLists.txt
index 95cf267..47f113e 100644
--- a/cpp/source/client/CMakeLists.txt
+++ b/cpp/source/stats/CMakeLists.txt
@@ -1,18 +1,18 @@
file(GLOB SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
-add_library(client OBJECT ${SRC_FILES})
-target_include_directories(client
- PRIVATE
+
+add_library(rocketmq_stats OBJECT ${SRC_FILES})
+target_include_directories(rocketmq_stats
+ PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include)
-target_link_libraries(client
+target_link_libraries(rocketmq_stats
PRIVATE
api
- asio
base
- proto
+ client
fmt
- gRPC::grpc
- OpenSSL::SSL
opencensus::stats
- opencensus::trace
+ opencensus_proto
+ proto
+ spdlog
scheduler
- spdlog)
\ No newline at end of file
+ )
\ No newline at end of file
diff --git a/cpp/source/stats/MetricBidiReactor.cpp b/cpp/source/stats/MetricBidiReactor.cpp
index 43e69ed..22363bd 100644
--- a/cpp/source/stats/MetricBidiReactor.cpp
+++ b/cpp/source/stats/MetricBidiReactor.cpp
@@ -18,7 +18,8 @@
#include <chrono>
-#include "LoggerImpl.h"
+#include "rocketmq/Logger.h"
+#include "spdlog/spdlog.h"
#include "OpencensusExporter.h"
#include "Signature.h"
diff --git a/cpp/source/stats/StdoutHandler.cpp b/cpp/source/stats/StdoutHandler.cpp
index 9d18d78..3cc7538 100644
--- a/cpp/source/stats/StdoutHandler.cpp
+++ b/cpp/source/stats/StdoutHandler.cpp
@@ -26,14 +26,14 @@ void StdoutHandler::ExportViewData(
for (const auto& datum : data) {
const auto& view_data = datum.second;
const auto& descriptor = datum.first;
- auto start_times = view_data.start_times();
+ auto record_time = view_data.end_time();
auto columns = descriptor.columns();
switch (view_data.type()) {
case opencensus::stats::ViewData::Type::kInt64: {
auto data_map = view_data.int_data();
for (const auto& entry : data_map) {
- absl::Time time = start_times[entry.first];
+ absl::Time time = record_time;
std::string line;
line.append(absl::FormatTime(time)).append(" ");
line.append(descriptor.name());
diff --git a/cpp/third_party/CMakeLists.txt b/cpp/third_party/CMakeLists.txt
index 3ce47f1..c00c963 100644
--- a/cpp/third_party/CMakeLists.txt
+++ b/cpp/third_party/CMakeLists.txt
@@ -4,4 +4,5 @@ add_subdirectory(fmt/9.0.0)
add_subdirectory(spdlog/1.10.0)
include(OpenCensusHelpers)
-add_subdirectory(opencensus/0.4.0)
\ No newline at end of file
+add_subdirectory(opencensus/0.4.0)
+add_subdirectory(opencensus/proto)
\ No newline at end of file
diff --git a/cpp/third_party/opencensus/proto/CMakeLists.txt b/cpp/third_party/opencensus/proto/CMakeLists.txt
new file mode 100644
index 0000000..4f08ac4
--- /dev/null
+++ b/cpp/third_party/opencensus/proto/CMakeLists.txt
@@ -0,0 +1,21 @@
+set(PROTO_FILES
+ opencensus/proto/stats/v1/stats.proto
+ opencensus/proto/metrics/v1/metrics.proto
+ opencensus/proto/agent/metrics/v1/metrics_service.proto
+ opencensus/proto/agent/common/v1/common.proto
+ opencensus/proto/resource/v1/resource.proto)
+
+add_library(opencensus_proto ${PROTO_FILES})
+target_link_libraries(opencensus_proto
+ PUBLIC
+ protobuf::libprotobuf
+ gRPC::grpc
+ gRPC::grpc++)
+target_include_directories(opencensus_proto PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
+
+#
+# Compile protobuf and grpc files in myproto target to cpp
+#
+get_target_property(grpc_cpp_plugin_location gRPC::grpc_cpp_plugin LOCATION)
+protobuf_generate(TARGET opencensus_proto LANGUAGE cpp)
+protobuf_generate(TARGET opencensus_proto LANGUAGE grpc GENERATE_EXTENSIONS .grpc.pb.h .grpc.pb.cc PLUGIN "protoc-gen-grpc=${grpc_cpp_plugin_location}")
\ No newline at end of file
diff --git a/cpp/third_party/opencensus/proto/opencensus/proto/agent/README.md b/cpp/third_party/opencensus/proto/opencensus/proto/agent/README.md
new file mode 100644
index 0000000..00e41d9
--- /dev/null
+++ b/cpp/third_party/opencensus/proto/opencensus/proto/agent/README.md
@@ -0,0 +1,13 @@
+# OpenCensus Agent Proto
+
+This package describes the OpenCensus Agent protocol. For the architecture and implementation of
+OpenCensus Agent, please refer to the specs in
+[OpenCensus-Service](https://github.com/census-instrumentation/opencensus-service#opencensus-agent).
+
+## Packages
+
+1. `common` package contains the common messages shared between different services, such as
+`Node`, `Service` and `Library` identifiers.
+2. `trace` package contains the Trace Service protos.
+3. `metrics` package contains the Metrics Service protos.
+4. (Coming soon) `stats` package contains the Stats Service protos.
diff --git a/cpp/third_party/opencensus/proto/opencensus/proto/agent/common/v1/BUILD.bazel b/cpp/third_party/opencensus/proto/opencensus/proto/agent/common/v1/BUILD.bazel
new file mode 100644
index 0000000..a078e61
--- /dev/null
+++ b/cpp/third_party/opencensus/proto/opencensus/proto/agent/common/v1/BUILD.bazel
@@ -0,0 +1,34 @@
+# Copyright 2018, OpenCensus 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("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
+
+proto_library(
+ name = "common_proto",
+ srcs = ["common.proto"],
+ deps = [
+ "@com_google_protobuf//:timestamp_proto",
+ ],
+)
+
+go_proto_library(
+ name = "common_proto_go",
+ proto = ":common_proto",
+ importpath = "github.com/census-instrumentation/opencensus-proto/gen-go/agent/common/v1",
+ deps = [
+ "@com_github_golang_protobuf//ptypes/timestamp:go_default_library",
+ ],
+)
diff --git a/cpp/third_party/opencensus/proto/opencensus/proto/agent/common/v1/common.proto b/cpp/third_party/opencensus/proto/opencensus/proto/agent/common/v1/common.proto
new file mode 100644
index 0000000..10d2fda
--- /dev/null
+++ b/cpp/third_party/opencensus/proto/opencensus/proto/agent/common/v1/common.proto
@@ -0,0 +1,98 @@
+// Copyright 2018, OpenCensus 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 opencensus.proto.agent.common.v1;
+
+import "google/protobuf/timestamp.proto";
+
+option java_multiple_files = true;
+option java_package = "io.opencensus.proto.agent.common.v1";
+option java_outer_classname = "CommonProto";
+
+option go_package = "github.com/census-instrumentation/opencensus-proto/gen-go/agent/common/v1";
+
+// Identifier metadata of the Node that produces the span or tracing data.
+// Note, this is not the metadata about the Node or service that is described by associated spans.
+// In the future we plan to extend the identifier proto definition to support
+// additional information (e.g cloud id, etc.)
+message Node {
+ // Identifier that uniquely identifies a process within a VM/container.
+ ProcessIdentifier identifier = 1;
+
+ // Information on the OpenCensus Library that initiates the stream.
+ LibraryInfo library_info = 2;
+
+ // Additional information on service.
+ ServiceInfo service_info = 3;
+
+ // Additional attributes.
+ map<string, string> attributes = 4;
+
+ // TODO(songya): Add more identifiers in the future as needed, like cloud
+ // identifiers.
+}
+
+// Identifier that uniquely identifies a process within a VM/container.
+message ProcessIdentifier {
+
+ // The host name. Usually refers to the machine/container name.
+ // For example: os.Hostname() in Go, socket.gethostname() in Python.
+ string host_name = 1;
+
+ // Process id.
+ uint32 pid = 2;
+
+ // Start time of this ProcessIdentifier. Represented in epoch time.
+ google.protobuf.Timestamp start_timestamp = 3;
+}
+
+// Information on OpenCensus Library.
+message LibraryInfo {
+
+ enum Language {
+ LANGUAGE_UNSPECIFIED = 0;
+ CPP = 1;
+ C_SHARP = 2;
+ ERLANG = 3;
+ GO_LANG = 4;
+ JAVA = 5;
+ NODE_JS = 6;
+ PHP = 7;
+ PYTHON = 8;
+ RUBY = 9;
+ }
+
+ // Language of OpenCensus Library.
+ Language language = 1;
+
+ // Version of Agent exporter of Library.
+ string exporter_version = 2;
+
+ // Version of OpenCensus Library.
+ string core_library_version = 3;
+}
+
+// Additional service information.
+message ServiceInfo {
+
+ // Name of the service.
+ string name = 1;
+
+ // TODO(songya): add more fields as needed.
+}
diff --git a/cpp/third_party/opencensus/proto/opencensus/proto/agent/metrics/v1/BUILD.bazel b/cpp/third_party/opencensus/proto/opencensus/proto/agent/metrics/v1/BUILD.bazel
new file mode 100644
index 0000000..4983e5b
--- /dev/null
+++ b/cpp/third_party/opencensus/proto/opencensus/proto/agent/metrics/v1/BUILD.bazel
@@ -0,0 +1,55 @@
+# Copyright 2018, OpenCensus 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("@grpc_java//:java_grpc_library.bzl", "java_grpc_library")
+load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
+
+proto_library(
+ name = "metrics_service_proto",
+ srcs = ["metrics_service.proto"],
+ deps = [
+ "//opencensus/proto/agent/common/v1:common_proto",
+ "//opencensus/proto/metrics/v1:metrics_proto",
+ "//opencensus/proto/resource/v1:resource_proto",
+ ],
+)
+
+cc_proto_library(
+ name = "metrics_service_proto_cc",
+ deps = [":metrics_service_proto"],
+)
+
+java_proto_library(
+ name = "metrics_service_proto_java",
+ deps = [":metrics_service_proto"],
+)
+
+java_grpc_library(
+ name = "metrics_service_grpc_java",
+ srcs = [":metrics_service_proto"],
+ deps = [":metrics_service_proto_java"],
+)
+
+go_proto_library(
+ name = "metrics_service_proto_go",
+ proto = ":metrics_service_proto",
+ importpath = "github.com/census-instrumentation/opencensus-proto/gen-go/agent/metrics/v1",
+ deps = [
+ "//opencensus/proto/agent/common/v1:common_proto_go",
+ "//opencensus/proto/metrics/v1:metrics_proto_go",
+ "//opencensus/proto/resource/v1:resource_proto_go",
+ ],
+)
diff --git a/cpp/third_party/opencensus/proto/opencensus/proto/agent/metrics/v1/metrics_service.proto b/cpp/third_party/opencensus/proto/opencensus/proto/agent/metrics/v1/metrics_service.proto
new file mode 100644
index 0000000..f2aac28
--- /dev/null
+++ b/cpp/third_party/opencensus/proto/opencensus/proto/agent/metrics/v1/metrics_service.proto
@@ -0,0 +1,56 @@
+// Copyright 2018, OpenCensus 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 opencensus.proto.agent.metrics.v1;
+
+import "opencensus/proto/agent/common/v1/common.proto";
+import "opencensus/proto/metrics/v1/metrics.proto";
+import "opencensus/proto/resource/v1/resource.proto";
+
+option java_multiple_files = true;
+option java_package = "io.opencensus.proto.agent.metrics.v1";
+option java_outer_classname = "MetricsServiceProto";
+
+option go_package = "github.com/census-instrumentation/opencensus-proto/gen-go/agent/metrics/v1";
+
+// Service that can be used to push metrics between one Application
+// instrumented with OpenCensus and an agent, or between an agent 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(stream ExportMetricsServiceRequest) returns (stream ExportMetricsServiceResponse) {}
+}
+
+message ExportMetricsServiceRequest {
+ // This is required only in the first message on the stream or if the
+ // previous sent ExportMetricsServiceRequest message has a different Node (e.g.
+ // when the same RPC is used to send Metrics from multiple Applications).
+ opencensus.proto.agent.common.v1.Node node = 1;
+
+ // A list of metrics that belong to the last received Node.
+ repeated opencensus.proto.metrics.v1.Metric metrics = 2;
+
+ // The resource for the metrics in this message that do not have an explicit
+ // resource set.
+ // If unset, the most recently set resource in the RPC stream applies. It is
+ // valid to never be set within a stream, e.g. when no resource info is known
+ // at all or when all sent metrics have an explicit resource set.
+ opencensus.proto.resource.v1.Resource resource = 3;
+}
+
+message ExportMetricsServiceResponse {
+}
diff --git a/cpp/third_party/opencensus/proto/opencensus/proto/agent/trace/v1/BUILD.bazel b/cpp/third_party/opencensus/proto/opencensus/proto/agent/trace/v1/BUILD.bazel
new file mode 100644
index 0000000..819c5e4
--- /dev/null
+++ b/cpp/third_party/opencensus/proto/opencensus/proto/agent/trace/v1/BUILD.bazel
@@ -0,0 +1,56 @@
+# Copyright 2018, OpenCensus 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("@grpc_java//:java_grpc_library.bzl", "java_grpc_library")
+load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
+
+proto_library(
+ name = "trace_service_proto",
+ srcs = ["trace_service.proto"],
+ deps = [
+ "//opencensus/proto/agent/common/v1:common_proto",
+ "//opencensus/proto/resource/v1:resource_proto",
+ "//opencensus/proto/trace/v1:trace_proto",
+ "//opencensus/proto/trace/v1:trace_config_proto",
+ ],
+)
+
+cc_proto_library(
+ name = "trace_service_proto_cc",
+ deps = [":trace_service_proto"],
+)
+
+java_proto_library(
+ name = "trace_service_proto_java",
+ deps = [":trace_service_proto"],
+)
+
+java_grpc_library(
+ name = "trace_service_grpc_java",
+ srcs = [":trace_service_proto"],
+ deps = [":trace_service_proto_java"],
+)
+
+go_proto_library(
+ name = "trace_service_proto_go",
+ proto = ":trace_service_proto",
+ importpath = "github.com/census-instrumentation/opencensus-proto/gen-go/agent/trace/v1",
+ deps = [
+ "//opencensus/proto/agent/common/v1:common_proto_go",
+ "//opencensus/proto/resource/v1:resource_proto_go",
+ "//opencensus/proto/trace/v1:trace_and_config_proto_go",
+ ],
+)
diff --git a/cpp/third_party/opencensus/proto/opencensus/proto/agent/trace/v1/trace_service.proto b/cpp/third_party/opencensus/proto/opencensus/proto/agent/trace/v1/trace_service.proto
new file mode 100644
index 0000000..ed564ac
--- /dev/null
+++ b/cpp/third_party/opencensus/proto/opencensus/proto/agent/trace/v1/trace_service.proto
@@ -0,0 +1,85 @@
+// Copyright 2018, OpenCensus 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 opencensus.proto.agent.trace.v1;
+
+import "opencensus/proto/agent/common/v1/common.proto";
+import "opencensus/proto/resource/v1/resource.proto";
+import "opencensus/proto/trace/v1/trace.proto";
+import "opencensus/proto/trace/v1/trace_config.proto";
+
+option java_multiple_files = true;
+option java_package = "io.opencensus.proto.agent.trace.v1";
+option java_outer_classname = "TraceServiceProto";
+
+option go_package = "github.com/census-instrumentation/opencensus-proto/gen-go/agent/trace/v1";
+
+// Service that can be used to push spans and configs between one Application
+// instrumented with OpenCensus and an agent, or between an agent and a
+// central collector or config service (in this case spans and configs are
+// sent/received to/from multiple Applications).
+service TraceService {
+ // After initialization, this RPC must be kept alive for the entire life of
+ // the application. The agent pushes configs down to applications via a
+ // stream.
+ rpc Config(stream CurrentLibraryConfig) returns (stream UpdatedLibraryConfig) {}
+
+ // For performance reasons, it is recommended to keep this RPC
+ // alive for the entire life of the application.
+ rpc Export(stream ExportTraceServiceRequest) returns (stream ExportTraceServiceResponse) {}
+}
+
+message CurrentLibraryConfig {
+ // This is required only in the first message on the stream or if the
+ // previous sent CurrentLibraryConfig message has a different Node (e.g.
+ // when the same RPC is used to configure multiple Applications).
+ opencensus.proto.agent.common.v1.Node node = 1;
+
+ // Current configuration.
+ opencensus.proto.trace.v1.TraceConfig config = 2;
+}
+
+message UpdatedLibraryConfig {
+ // This field is ignored when the RPC is used to configure only one Application.
+ // This is required only in the first message on the stream or if the
+ // previous sent UpdatedLibraryConfig message has a different Node.
+ opencensus.proto.agent.common.v1.Node node = 1;
+
+ // Requested updated configuration.
+ opencensus.proto.trace.v1.TraceConfig config = 2;
+}
+
+message ExportTraceServiceRequest {
+ // This is required only in the first message on the stream or if the
+ // previous sent ExportTraceServiceRequest message has a different Node (e.g.
+ // when the same RPC is used to send Spans from multiple Applications).
+ opencensus.proto.agent.common.v1.Node node = 1;
+
+ // A list of Spans that belong to the last received Node.
+ repeated opencensus.proto.trace.v1.Span spans = 2;
+
+ // The resource for the spans in this message that do not have an explicit
+ // resource set.
+ // If unset, the most recently set resource in the RPC stream applies. It is
+ // valid to never be set within a stream, e.g. when no resource info is known.
+ opencensus.proto.resource.v1.Resource resource = 3;
+}
+
+message ExportTraceServiceResponse {
+}
diff --git a/cpp/third_party/opencensus/proto/opencensus/proto/agent/trace/v1/trace_service_http.yaml b/cpp/third_party/opencensus/proto/opencensus/proto/agent/trace/v1/trace_service_http.yaml
new file mode 100644
index 0000000..f2f254a
--- /dev/null
+++ b/cpp/third_party/opencensus/proto/opencensus/proto/agent/trace/v1/trace_service_http.yaml
@@ -0,0 +1,9 @@
+# This is an API configuration to generate an HTTP/JSON -> gRPC gateway for the
+# OpenCensus service using github.com/grpc-ecosystem/grpc-gateway.
+type: google.api.Service
+config_version: 3
+http:
+ rules:
+ - selector: opencensus.proto.agent.trace.v1.TraceService.Export
+ post: /v1/trace
+ body: "*"
diff --git a/cpp/third_party/opencensus/proto/opencensus/proto/metrics/v1/BUILD.bazel b/cpp/third_party/opencensus/proto/opencensus/proto/metrics/v1/BUILD.bazel
new file mode 100644
index 0000000..333c027
--- /dev/null
+++ b/cpp/third_party/opencensus/proto/opencensus/proto/metrics/v1/BUILD.bazel
@@ -0,0 +1,48 @@
+# Copyright 2018, OpenCensus 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("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
+
+proto_library(
+ name = "metrics_proto",
+ srcs = ["metrics.proto"],
+ deps = [
+ "@com_google_protobuf//:timestamp_proto",
+ "@com_google_protobuf//:wrappers_proto",
+ "//opencensus/proto/resource/v1:resource_proto",
+ ],
+)
+
+cc_proto_library(
+ name = "metrics_proto_cc",
+ deps = [":metrics_proto"],
+)
+
+java_proto_library(
+ name = "metrics_proto_java",
+ deps = [":metrics_proto"],
+)
+
+go_proto_library(
+ name = "metrics_proto_go",
+ proto = ":metrics_proto",
+ importpath = "github.com/census-instrumentation/opencensus-proto/gen-go/metrics/v1",
+ deps = [
+ "//opencensus/proto/resource/v1:resource_proto_go",
+ "@com_github_golang_protobuf//ptypes/timestamp:go_default_library",
+ "@com_github_golang_protobuf//ptypes/wrappers:go_default_library",
+ ],
+)
diff --git a/cpp/third_party/opencensus/proto/opencensus/proto/metrics/v1/metrics.proto b/cpp/third_party/opencensus/proto/opencensus/proto/metrics/v1/metrics.proto
new file mode 100644
index 0000000..44ba0d3
--- /dev/null
+++ b/cpp/third_party/opencensus/proto/opencensus/proto/metrics/v1/metrics.proto
@@ -0,0 +1,301 @@
+// Copyright 2018, OpenCensus 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.
+
+// This package describes the Metrics data model. It is currently experimental
+// but may eventually become the wire format for metrics. Please see
+// https://github.com/census-instrumentation/opencensus-specs/blob/master/stats/Metrics.md
+// for more details.
+
+syntax = "proto3";
+
+package opencensus.proto.metrics.v1;
+
+import "google/protobuf/timestamp.proto";
+import "google/protobuf/wrappers.proto";
+import "opencensus/proto/resource/v1/resource.proto";
+
+option go_package = "github.com/census-instrumentation/opencensus-proto/gen-go/metrics/v1";
+
+option java_multiple_files = true;
+option java_package = "io.opencensus.proto.metrics.v1";
+option java_outer_classname = "MetricsProto";
+
+// Defines a Metric which has one or more timeseries.
+message Metric {
+ // The descriptor of the Metric.
+ // TODO(issue #152): consider only sending the name of descriptor for
+ // optimization.
+ MetricDescriptor metric_descriptor = 1;
+
+ // One or more timeseries for a single metric, where each timeseries has
+ // one or more points.
+ repeated TimeSeries timeseries = 2;
+
+ // The resource for the metric. If unset, it may be set to a default value
+ // provided for a sequence of messages in an RPC stream.
+ opencensus.proto.resource.v1.Resource resource = 3;
+}
+
+// Defines a metric type and its schema.
+message MetricDescriptor {
+ // The metric type, including its DNS name prefix. It must be unique.
+ string name = 1;
+
+ // A detailed description of the metric, which can be used in documentation.
+ string description = 2;
+
+ // The unit in which the metric value is reported. Follows the format
+ // described by http://unitsofmeasure.org/ucum.html.
+ string unit = 3;
+
+ // The kind of metric. It describes how the data is reported.
+ //
+ // A gauge is an instantaneous measurement of a value.
+ //
+ // A cumulative measurement is a value accumulated over a time interval. In
+ // a time series, cumulative measurements should have the same start time,
+ // increasing values and increasing end times, until an event resets the
+ // cumulative value to zero and sets a new start time for the following
+ // points.
+ enum Type {
+ // Do not use this default value.
+ UNSPECIFIED = 0;
+
+ // Integer gauge. The value can go both up and down.
+ GAUGE_INT64 = 1;
+
+ // Floating point gauge. The value can go both up and down.
+ GAUGE_DOUBLE = 2;
+
+ // Distribution gauge measurement. The count and sum can go both up and
+ // down. Recorded values are always >= 0.
+ // Used in scenarios like a snapshot of time the current items in a queue
+ // have spent there.
+ GAUGE_DISTRIBUTION = 3;
+
+ // Integer cumulative measurement. The value cannot decrease, if resets
+ // then the start_time should also be reset.
+ CUMULATIVE_INT64 = 4;
+
+ // Floating point cumulative measurement. The value cannot decrease, if
+ // resets then the start_time should also be reset. Recorded values are
+ // always >= 0.
+ CUMULATIVE_DOUBLE = 5;
+
+ // Distribution cumulative measurement. The count and sum cannot decrease,
+ // if resets then the start_time should also be reset.
+ CUMULATIVE_DISTRIBUTION = 6;
+
+ // 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. This is not recommended, since it cannot be aggregated.
+ SUMMARY = 7;
+ }
+ Type type = 4;
+
+ // The label keys associated with the metric descriptor.
+ repeated LabelKey label_keys = 5;
+}
+
+// Defines a label key associated with a metric descriptor.
+message LabelKey {
+ // The key for the label.
+ string key = 1;
+
+ // A human-readable description of what this label key represents.
+ string description = 2;
+}
+
+// A collection of data points that describes the time-varying values
+// of a metric.
+message TimeSeries {
+ // Must be present for cumulative metrics. The time when the cumulative value
+ // was reset to zero. Exclusive. The cumulative value is over the time interval
+ // (start_timestamp, timestamp]. If not specified, the backend can use the
+ // previous recorded value.
+ google.protobuf.Timestamp start_timestamp = 1;
+
+ // The set of label values that uniquely identify this timeseries. Applies to
+ // all points. The order of label values must match that of label keys in the
+ // metric descriptor.
+ repeated LabelValue label_values = 2;
+
+ // The data points of this timeseries. Point.value type MUST match the
+ // MetricDescriptor.type.
+ repeated Point points = 3;
+}
+
+message LabelValue {
+ // The value for the label.
+ string value = 1;
+ // If false the value field is ignored and considered not set.
+ // This is used to differentiate a missing label from an empty string.
+ bool has_value = 2;
+}
+
+// A timestamped measurement.
+message Point {
+ // The moment when this point was recorded. Inclusive.
+ // If not specified, the timestamp will be decided by the backend.
+ google.protobuf.Timestamp timestamp = 1;
+
+ // The actual point value.
+ oneof value {
+ // A 64-bit integer.
+ int64 int64_value = 2;
+
+ // A 64-bit double-precision floating-point number.
+ double double_value = 3;
+
+ // A distribution value.
+ DistributionValue distribution_value = 4;
+
+ // A summary value. This is not recommended, since it cannot be aggregated.
+ SummaryValue summary_value = 5;
+ }
+}
+
+// Distribution contains summary statistics for a population of values. It
+// optionally contains a histogram representing the distribution of those
+// values across a set of buckets.
+message DistributionValue {
+ // The number of values in the population. Must be non-negative. This value
+ // must equal the sum of the values in bucket_counts if a histogram is
+ // provided.
+ int64 count = 1;
+
+ // The sum of the values in the population. If count is zero then this field
+ // must be zero.
+ double sum = 2;
+
+ // The sum of squared deviations from the mean of the values in the
+ // population. For values x_i this is:
+ //
+ // Sum[i=1..n]((x_i - mean)^2)
+ //
+ // Knuth, "The Art of Computer Programming", Vol. 2, page 323, 3rd edition
+ // describes Welford's method for accumulating this sum in one pass.
+ //
+ // If count is zero then this field must be zero.
+ double sum_of_squared_deviation = 3;
+
+ // A Distribution may optionally contain a histogram of the values in the
+ // population. The bucket boundaries for that histogram are described by
+ // BucketOptions.
+ //
+ // If bucket_options has no type, then there is no histogram associated with
+ // the Distribution.
+ message BucketOptions {
+ oneof type {
+ // Bucket with explicit bounds.
+ Explicit explicit = 1;
+ }
+
+ // Specifies a set of buckets with arbitrary upper-bounds.
+ // This defines size(bounds) + 1 (= N) buckets. The boundaries for bucket
+ // index i are:
+ //
+ // [0, bucket_bounds[i]) for i == 0
+ // [bucket_bounds[i-1], bucket_bounds[i]) for 0 < i < N-1
+ // [bucket_bounds[i], +infinity) for i == N-1
+ message Explicit {
+ // The values must be strictly increasing and > 0.
+ repeated double bounds = 1;
+ }
+
+ // TODO: If OpenMetrics decides to support (a, b] intervals we should add
+ // support for these by defining a boolean value here which decides what
+ // type of intervals to use.
+ }
+
+ // Don't change bucket boundaries within a TimeSeries if your backend doesn't
+ // support this.
+ // TODO(issue #152): consider not required to send bucket options for
+ // optimization.
+ BucketOptions bucket_options = 4;
+
+ message Bucket {
+ // The number of values in each bucket of the histogram, as described in
+ // bucket_bounds.
+ int64 count = 1;
+
+ // If the distribution does not have a histogram, then omit this field.
+ Exemplar exemplar = 2;
+ }
+
+ // If the distribution does not have a histogram, then omit this field.
+ // If there is a histogram, then the sum of the values in the Bucket counts
+ // must equal the value in the count field of the distribution.
+ repeated Bucket buckets = 5;
+
+ // Exemplars are example points that may be used to annotate aggregated
+ // Distribution values. They are metadata that gives information about a
+ // particular value added to a Distribution bucket.
+ message Exemplar {
+ // Value of the exemplar point. It determines which bucket the exemplar
+ // belongs to.
+ double value = 1;
+
+ // The observation (sampling) time of the above value.
+ google.protobuf.Timestamp timestamp = 2;
+
+ // Contextual information about the example value.
+ map<string, string> attachments = 3;
+ }
+}
+
+// The start_timestamp only applies to the count and sum in the SummaryValue.
+message SummaryValue {
+ // The total number of recorded values since start_time. Optional since
+ // some systems don't expose this.
+ google.protobuf.Int64Value count = 1;
+
+ // 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.
+ // This field must be unset if the sum is not available.
+ google.protobuf.DoubleValue sum = 2;
+
+ // The values in this message can be reset at arbitrary unknown times, with
+ // the requirement that all of them are reset at the same time.
+ message Snapshot {
+ // The number of values in the snapshot. Optional since some systems don't
+ // expose this.
+ google.protobuf.Int64Value count = 1;
+
+ // The sum of values in the snapshot. Optional since some systems don't
+ // expose this. If count is zero then this field must be zero or not set
+ // (if not supported).
+ google.protobuf.DoubleValue sum = 2;
+
+ // 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 = 3;
+ }
+
+ // Values calculated over an arbitrary time window.
+ Snapshot snapshot = 3;
+}
+
diff --git a/cpp/third_party/opencensus/proto/opencensus/proto/resource/v1/BUILD.bazel b/cpp/third_party/opencensus/proto/opencensus/proto/resource/v1/BUILD.bazel
new file mode 100644
index 0000000..d17f43a
--- /dev/null
+++ b/cpp/third_party/opencensus/proto/opencensus/proto/resource/v1/BUILD.bazel
@@ -0,0 +1,38 @@
+# Copyright 2018, OpenCensus 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("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
+
+proto_library(
+ name = "resource_proto",
+ srcs = ["resource.proto"],
+)
+
+cc_proto_library(
+ name = "resource_proto_cc",
+ deps = [":resource_proto"],
+)
+
+java_proto_library(
+ name = "resource_proto_java",
+ deps = [":resource_proto"],
+)
+
+go_proto_library(
+ name = "resource_proto_go",
+ proto = ":resource_proto",
+ importpath = "github.com/census-instrumentation/opencensus-proto/gen-go/resource/v1",
+)
diff --git a/cpp/third_party/opencensus/proto/opencensus/proto/resource/v1/resource.proto b/cpp/third_party/opencensus/proto/opencensus/proto/resource/v1/resource.proto
new file mode 100644
index 0000000..61e5983
--- /dev/null
+++ b/cpp/third_party/opencensus/proto/opencensus/proto/resource/v1/resource.proto
@@ -0,0 +1,33 @@
+// Copyright 2018, OpenCensus 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 opencensus.proto.resource.v1;
+
+option go_package = "github.com/census-instrumentation/opencensus-proto/gen-go/resource/v1";
+
+option java_multiple_files = true;
+option java_package = "io.opencensus.proto.resource.v1";
+option java_outer_classname = "ResourceProto";
+
+// Resource information.
+message Resource {
+
+ // Type identifier for the resource.
+ string type = 1;
+
+ // Set of labels that describe the resource.
+ map<string,string> labels = 2;
+}
diff --git a/cpp/third_party/opencensus/proto/opencensus/proto/stats/v1/BUILD.bazel b/cpp/third_party/opencensus/proto/opencensus/proto/stats/v1/BUILD.bazel
new file mode 100644
index 0000000..10c5ee5
--- /dev/null
+++ b/cpp/third_party/opencensus/proto/opencensus/proto/stats/v1/BUILD.bazel
@@ -0,0 +1,45 @@
+# Copyright 2017, OpenCensus 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("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
+
+proto_library(
+ name = "stats_proto",
+ srcs = ["stats.proto"],
+ deps = [
+ "@com_google_protobuf//:duration_proto",
+ "@com_google_protobuf//:timestamp_proto",
+ ],
+)
+
+cc_proto_library(
+ name = "stats_proto_cc",
+ deps = [":stats_proto"],
+)
+
+java_proto_library(
+ name = "stats_proto_java",
+ deps = [":stats_proto"],
+)
+
+go_proto_library(
+ name = "stats_proto_go",
+ proto = ":stats_proto",
+ importpath = "github.com/census-instrumentation/opencensus-proto/gen-go/stats/v1",
+ deps = [
+ "@com_github_golang_protobuf//ptypes/timestamp:go_default_library",
+ ],
+)
diff --git a/cpp/third_party/opencensus/proto/opencensus/proto/stats/v1/stats.proto b/cpp/third_party/opencensus/proto/opencensus/proto/stats/v1/stats.proto
new file mode 100644
index 0000000..4c3ab0e
--- /dev/null
+++ b/cpp/third_party/opencensus/proto/opencensus/proto/stats/v1/stats.proto
@@ -0,0 +1,136 @@
+// Copyright 2016-18, OpenCensus 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 opencensus.proto.stats.v1;
+
+import "google/protobuf/timestamp.proto";
+
+option go_package = "github.com/census-instrumentation/opencensus-proto/gen-go/stats/v1";
+
+option java_multiple_files = true;
+option java_package = "io.opencensus.proto.stats.v1";
+option java_outer_classname = "StatsProto";
+
+// TODO(bdrutu): Consider if this should be moved to a "tags" directory to match the API structure.
+message Tag {
+ string key = 1;
+ string value = 2;
+}
+
+// Measure .
+message Measure {
+ // A string by which the measure will be referred to, e.g. "rpc_server_latency". Names MUST be
+ // unique within the library.
+ string name = 1;
+
+ // Describes the measure, e.g. "RPC latency in seconds".
+ string description = 2;
+
+ // Describes the unit used for the Measure. Follows the format described by
+ // http://unitsofmeasure.org/ucum.html.
+ string unit = 3;
+
+ enum Type {
+ // Unknown type.
+ TYPE_UNSPECIFIED = 0;
+ // Indicates an int64 Measure.
+ INT64 = 1;
+ // Indicates a double Measure.
+ DOUBLE = 2;
+ }
+
+ // The type used for this Measure.
+ Type type = 4;
+}
+
+message View {
+ // A string by which the View will be referred to, e.g. "rpc_latency". Names MUST be unique
+ // within the library.
+ string name = 1;
+
+ // Describes the view, e.g. "RPC latency distribution"
+ string description = 2;
+
+ // The Measure to which this view is applied.
+ Measure measure = 3;
+
+ // An array of tag keys. These values associated with tags of this name form the basis by which
+ // individual stats will be aggregated (one aggregation per unique tag value). If none are
+ // provided, then all data is recorded in a single aggregation.
+ repeated string columns = 4;
+
+ // The description of the aggregation used for this view which describes how data collected are
+ // aggregated.
+ oneof aggregation {
+ // Counts the number of measurements recorded.
+ CountAggregation count_aggregation = 5;
+ // Indicates that data collected and aggregated with this Aggregation will be summed up.
+ SumAggregation sum_aggregation = 6;
+ // Indicates that data collected and aggregated with this Aggregation will represent the last
+ // recorded value. This is useful to support Gauges.
+ LastValueAggregation last_value_aggregation = 7;
+ // Indicates that the desired Aggregation is a histogram distribution. A distribution
+ // Aggregation may contain a histogram of the values in the population. User should define the
+ // bucket boundaries for that histogram (see DistributionAggregation).
+ DistributionAggregation distribution_aggregation = 8;
+ }
+}
+
+message CountAggregation {}
+
+message SumAggregation {}
+
+message LastValueAggregation {}
+
+message DistributionAggregation {
+ // A Distribution may optionally contain a histogram of the values in the
+ // population. The bucket boundaries for that histogram are described by
+ // `bucket_bounds`. This defines `size(bucket_bounds) + 1` (= N)
+ // buckets. The boundaries for bucket index i are:
+ //
+ // (-infinity, bucket_bounds[i]) for i == 0
+ // [bucket_bounds[i-1], bucket_bounds[i]) for 0 < i < N-2
+ // [bucket_bounds[i-1], +infinity) for i == N-1
+ //
+ // i.e. an underflow bucket (number 0), zero or more finite buckets (1
+ // through N - 2, and an overflow bucket (N - 1), with inclusive lower
+ // bounds and exclusive upper bounds.
+ //
+ // If `bucket_bounds` has no elements (zero size), then there is no
+ // histogram associated with the Distribution. If `bucket_bounds` has only
+ // one element, there are no finite buckets, and that single element is the
+ // common boundary of the overflow and underflow buckets. The values must
+ // be monotonically increasing.
+ repeated double bucket_bounds = 1;
+}
+
+// Describes a data point to be collected for a Measure.
+message Measurement {
+ repeated Tag tags = 1;
+
+ // The name of the measure to which the value is applied.
+ string measure_name = 2;
+
+ // The recorded value, MUST have the appropriate type to match the Measure.
+ oneof value {
+ double double_value = 3;
+ int64 int_value = 4;
+ }
+
+ // The time when this measurement was recorded. If the implementation uses a async buffer to
+ // record measurements this may be the time when the measurement was read from the buffer.
+ google.protobuf.Timestamp time = 5;
+}
diff --git a/cpp/third_party/opencensus/proto/opencensus/proto/trace/v1/BUILD.bazel b/cpp/third_party/opencensus/proto/opencensus/proto/trace/v1/BUILD.bazel
new file mode 100644
index 0000000..589d880
--- /dev/null
+++ b/cpp/third_party/opencensus/proto/opencensus/proto/trace/v1/BUILD.bazel
@@ -0,0 +1,83 @@
+# Copyright 2017, OpenCensus 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("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
+load("@io_bazel_rules_go//go:def.bzl", "go_library")
+
+proto_library(
+ name = "trace_proto",
+ srcs = ["trace.proto"],
+ deps = [
+ "@com_google_protobuf//:timestamp_proto",
+ "@com_google_protobuf//:wrappers_proto",
+ "//opencensus/proto/resource/v1:resource_proto",
+ ],
+)
+
+proto_library(
+ name = "trace_config_proto",
+ srcs = ["trace_config.proto"],
+)
+
+cc_proto_library(
+ name = "trace_proto_cc",
+ deps = [":trace_proto"],
+)
+
+cc_proto_library(
+ name = "trace_config_proto_cc",
+ deps = [":trace_config_proto"],
+)
+
+java_proto_library(
+ name = "trace_proto_java",
+ deps = [":trace_proto"],
+)
+
+java_proto_library(
+ name = "trace_config_proto_java",
+ deps = [":trace_config_proto"],
+)
+
+go_proto_library(
+ name = "trace_proto_go",
+ proto = ":trace_proto",
+ importpath = "github.com/census-instrumentation/opencensus-proto/gen-go/trace/v1",
+ deps = [
+ "@com_github_golang_protobuf//ptypes/timestamp:go_default_library",
+ "@com_github_golang_protobuf//ptypes/wrappers:go_default_library",
+ "//opencensus/proto/resource/v1:resource_proto_go",
+ ],
+)
+
+go_proto_library(
+ name = "trace_config_proto_go",
+ proto = ":trace_config_proto",
+ importpath = "github.com/census-instrumentation/opencensus-proto/gen-go/trace/v1",
+)
+
+# This a workaround because `trace_proto_go` and `trace_config_proto_go` have
+# the same importpath, and so cause a compile issue if both are depended on
+# directly by another `go_proto_library` (such as `trace_service_proto_go`).
+# See: https://github.com/bazelbuild/rules_go/issues/1841
+go_library(
+ name = "trace_and_config_proto_go",
+ srcs = [],
+ embed = [
+ ":trace_proto_go",
+ ":trace_config_proto_go",
+ ]
+)
diff --git a/cpp/third_party/opencensus/proto/opencensus/proto/trace/v1/trace.proto b/cpp/third_party/opencensus/proto/opencensus/proto/trace/v1/trace.proto
new file mode 100644
index 0000000..009ed64
--- /dev/null
+++ b/cpp/third_party/opencensus/proto/opencensus/proto/trace/v1/trace.proto
@@ -0,0 +1,417 @@
+// Copyright 2017, OpenCensus 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 opencensus.proto.trace.v1;
+
+import "opencensus/proto/resource/v1/resource.proto";
+import "google/protobuf/timestamp.proto";
+import "google/protobuf/wrappers.proto";
+
+option java_multiple_files = true;
+option java_package = "io.opencensus.proto.trace.v1";
+option java_outer_classname = "TraceProto";
+
+option go_package = "github.com/census-instrumentation/opencensus-proto/gen-go/trace/v1";
+
+// A 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 id is 17.
+// TODO(bdrutu): Add an example.
+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;
+
+ // This field conveys information about request position in multiple distributed tracing graphs.
+ // It is a list of Tracestate.Entry with a maximum of 32 members in the list.
+ //
+ // See the https://github.com/w3c/distributed-tracing for more details about this field.
+ message Tracestate {
+ message Entry {
+ // The key must begin with a lowercase letter, and can only contain
+ // lowercase letters 'a'-'z', digits '0'-'9', underscores '_', dashes
+ // '-', asterisks '*', and forward slashes '/'.
+ string key = 1;
+
+ // The value is opaque string up to 256 characters printable ASCII
+ // RFC0020 characters (i.e., the range 0x20 to 0x7E) except ',' and '='.
+ // Note that this also excludes tabs, newlines, carriage returns, etc.
+ string value = 2;
+ }
+
+ // A list of entries that represent the Tracestate.
+ repeated Entry entries = 1;
+ }
+
+ // The Tracestate on the span.
+ Tracestate tracestate = 15;
+
+ // 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 = 3;
+
+ // 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.
+ TruncatableString name = 4;
+
+ // Type of span. Can be used to specify additional relationships between spans
+ // in addition to a parent/child relationship.
+ enum SpanKind {
+ // Unspecified.
+ SPAN_KIND_UNSPECIFIED = 0;
+
+ // Indicates that the span covers server-side handling of an RPC or other
+ // remote network request.
+ SERVER = 1;
+
+ // Indicates that the span covers the client-side wrapper around an RPC or
+ // other remote request.
+ CLIENT = 2;
+ }
+
+ // 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 = 14;
+
+ // 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.
+ //
+ // This field is semantically required. When not set on receive -
+ // receiver should set it to the value of end_time field if it was
+ // set. Or to the current time if neither was set. It is important to
+ // keep end_time > start_time for consistency.
+ //
+ // This field is required.
+ google.protobuf.Timestamp start_time = 5;
+
+ // 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.
+ //
+ // This field is semantically required. When not set on receive -
+ // receiver should set it to start_time value. It is important to
+ // keep end_time > start_time for consistency.
+ //
+ // This field is required.
+ google.protobuf.Timestamp end_time = 6;
+
+ // A set of attributes, each with a key and a value.
+ message Attributes {
+ // The set of attributes. 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 as tags using 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
+ map<string, AttributeValue> attribute_map = 1;
+
+ // 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.
+ int32 dropped_attributes_count = 2;
+ }
+
+ // A set of attributes on the span.
+ Attributes attributes = 7;
+
+ // A stack trace captured at the start of the span.
+ StackTrace stack_trace = 8;
+
+ // A time-stamped annotation or message event in the Span.
+ message TimeEvent {
+ // The time the event occurred.
+ google.protobuf.Timestamp time = 1;
+
+ // A text annotation with a set of attributes.
+ message Annotation {
+ // A user-supplied message describing the event.
+ TruncatableString description = 1;
+
+ // A set of attributes on the annotation.
+ Attributes attributes = 2;
+ }
+
+ // An event describing a message sent/received between Spans.
+ message MessageEvent {
+ // Indicates whether the message was sent or received.
+ enum Type {
+ // Unknown event type.
+ TYPE_UNSPECIFIED = 0;
+ // Indicates a sent message.
+ SENT = 1;
+ // Indicates a received message.
+ RECEIVED = 2;
+ }
+
+ // The type of MessageEvent. Indicates whether the message was sent or
+ // received.
+ Type type = 1;
+
+ // An identifier for the MessageEvent's message that can be used to match
+ // SENT and RECEIVED MessageEvents. For example, this field could
+ // represent a sequence ID for a streaming RPC. It is recommended to be
+ // unique within a Span.
+ uint64 id = 2;
+
+ // The number of uncompressed bytes sent or received.
+ uint64 uncompressed_size = 3;
+
+ // The number of compressed bytes sent or received. If zero, assumed to
+ // be the same size as uncompressed.
+ uint64 compressed_size = 4;
+ }
+
+ // A `TimeEvent` can contain either an `Annotation` object or a
+ // `MessageEvent` object, but not both.
+ oneof value {
+ // A text annotation with a set of attributes.
+ Annotation annotation = 2;
+
+ // An event describing a message sent/received between Spans.
+ MessageEvent message_event = 3;
+ }
+ }
+
+ // A collection of `TimeEvent`s. A `TimeEvent` is a time-stamped annotation
+ // on the span, consisting of either user-supplied key-value pairs, or
+ // details of a message sent/received between Spans.
+ message TimeEvents {
+ // A collection of `TimeEvent`s.
+ repeated TimeEvent time_event = 1;
+
+ // The number of dropped annotations in all the included time events.
+ // If the value is 0, then no annotations were dropped.
+ int32 dropped_annotations_count = 2;
+
+ // The number of dropped message events in all the included time events.
+ // If the value is 0, then no message events were dropped.
+ int32 dropped_message_events_count = 3;
+ }
+
+ // The included time events.
+ TimeEvents time_events = 9;
+
+ // 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 relationship of the current span relative to the linked span: child,
+ // parent, or unspecified.
+ enum Type {
+ // The relationship of the two spans is unknown, or known but other
+ // than parent-child.
+ TYPE_UNSPECIFIED = 0;
+ // The linked span is a child of the current span.
+ CHILD_LINKED_SPAN = 1;
+ // The linked span is a parent of the current span.
+ PARENT_LINKED_SPAN = 2;
+ }
+
+ // The relationship of the current span relative to the linked span.
+ Type type = 3;
+
+ // A set of attributes on the link.
+ Attributes attributes = 4;
+ }
+
+ // A collection of links, which are references from this span to a span
+ // in the same or different trace.
+ message Links {
+ // A collection of links.
+ repeated Link link = 1;
+
+ // The number of dropped links after the maximum size was enforced. If
+ // this value is 0, then no links were dropped.
+ int32 dropped_links_count = 2;
+ }
+
+ // The included links.
+ Links links = 10;
+
+ // 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 = 11;
+
+ // An optional resource that is associated with this span. If not set, this span
+ // should be part of a batch that does include the resource information, unless resource
+ // information is unknown.
+ opencensus.proto.resource.v1.Resource resource = 16;
+
+ // A highly recommended but not required flag that identifies when a
+ // trace crosses a process boundary. True when the parent_span belongs
+ // to the same process as the current span. This flag is most commonly
+ // used to indicate the need to adjust time as clocks in different
+ // processes may not be synchronized.
+ google.protobuf.BoolValue same_process_as_parent_span = 12;
+
+ // An optional number of child spans that were generated while this span
+ // was active. If set, allows an implementation to detect missing child spans.
+ google.protobuf.UInt32Value child_span_count = 13;
+}
+
+// The `Status` type defines a logical error model that is suitable for different
+// programming environments, including REST APIs and RPC APIs. This proto's fields
+// are a subset of those of
+// [google.rpc.Status](https://github.com/googleapis/googleapis/blob/master/google/rpc/status.proto),
+// which is used by [gRPC](https://github.com/grpc).
+message Status {
+ // The status code. This is optional field. It is safe to assume 0 (OK)
+ // when not set.
+ int32 code = 1;
+
+ // A developer-facing error message, which should be in English.
+ string message = 2;
+}
+
+// The value of an Attribute.
+message AttributeValue {
+ // The type of the value.
+ oneof value {
+ // A string up to 256 bytes long.
+ TruncatableString string_value = 1;
+ // A 64-bit signed integer.
+ int64 int_value = 2;
+ // A Boolean value represented by `true` or `false`.
+ bool bool_value = 3;
+ // A double value.
+ double double_value = 4;
+ }
+}
+
+// The call stack which originated this span.
+message StackTrace {
+ // A single stack frame in a stack trace.
+ message StackFrame {
+ // The fully-qualified name that uniquely identifies the function or
+ // method that is active in this frame.
+ TruncatableString function_name = 1;
+ // An un-mangled function name, if `function_name` is
+ // [mangled](http://www.avabodh.com/cxxin/namemangling.html). The name can
+ // be fully qualified.
+ TruncatableString original_function_name = 2;
+ // The name of the source file where the function call appears.
+ TruncatableString file_name = 3;
+ // The line number in `file_name` where the function call appears.
+ int64 line_number = 4;
+ // The column number where the function call appears, if available.
+ // This is important in JavaScript because of its anonymous functions.
+ int64 column_number = 5;
+ // The binary module from where the code was loaded.
+ Module load_module = 6;
+ // The version of the deployed source code.
+ TruncatableString source_version = 7;
+ }
+
+ // A collection of stack frames, which can be truncated.
+ message StackFrames {
+ // Stack frames in this call stack.
+ repeated StackFrame frame = 1;
+ // The number of stack frames that were dropped because there
+ // were too many stack frames.
+ // If this value is 0, then no stack frames were dropped.
+ int32 dropped_frames_count = 2;
+ }
+
+ // Stack frames in this stack trace.
+ StackFrames stack_frames = 1;
+
+ // The hash ID is used to conserve network bandwidth for duplicate
+ // stack traces within a single trace.
+ //
+ // Often multiple spans will have identical stack traces.
+ // The first occurrence of a stack trace should contain both
+ // `stack_frames` and a value in `stack_trace_hash_id`.
+ //
+ // Subsequent spans within the same request can refer
+ // to that stack trace by setting only `stack_trace_hash_id`.
+ //
+ // TODO: describe how to deal with the case where stack_trace_hash_id is
+ // zero because it was not set.
+ uint64 stack_trace_hash_id = 2;
+}
+
+// A description of a binary module.
+message Module {
+ // TODO: document the meaning of this field.
+ // For example: main binary, kernel modules, and dynamic libraries
+ // such as libc.so, sharedlib.so.
+ TruncatableString module = 1;
+
+ // A unique identifier for the module, usually a hash of its
+ // contents.
+ TruncatableString build_id = 2;
+}
+
+// A string that might be shortened to a specified length.
+message TruncatableString {
+ // The shortened string. For example, if the original string was 500 bytes long and
+ // the limit of the string was 128 bytes, then this value contains the first 128
+ // bytes of the 500-byte string. Note that truncation always happens on a
+ // character boundary, to ensure that a truncated string is still valid UTF-8.
+ // Because it may contain multi-byte characters, the size of the truncated string
+ // may be less than the truncation limit.
+ string value = 1;
+
+ // The number of bytes removed from the original string. If this
+ // value is 0, then the string was not shortened.
+ int32 truncated_byte_count = 2;
+}
diff --git a/cpp/third_party/opencensus/proto/opencensus/proto/trace/v1/trace_config.proto b/cpp/third_party/opencensus/proto/opencensus/proto/trace/v1/trace_config.proto
new file mode 100644
index 0000000..0f9b5f3
--- /dev/null
+++ b/cpp/third_party/opencensus/proto/opencensus/proto/trace/v1/trace_config.proto
@@ -0,0 +1,79 @@
+// Copyright 2018, OpenCensus 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 opencensus.proto.trace.v1;
+
+option java_multiple_files = true;
+option java_package = "io.opencensus.proto.trace.v1";
+option java_outer_classname = "TraceConfigProto";
+
+option go_package = "github.com/census-instrumentation/opencensus-proto/gen-go/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 {
+ ProbabilitySampler probability_sampler = 1;
+
+ ConstantSampler constant_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_annotations = 5;
+
+ // The global default max number of message events per span.
+ int64 max_number_of_message_events = 6;
+
+ // The global default max number of link entries per span.
+ int64 max_number_of_links = 7;
+}
+
+// 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 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 sample with a rate per time window.
+message RateLimitingSampler {
+
+ // Rate per second.
+ int64 qps = 1;
+}