From fc93f641b09cb3f7fc15fd17e420ad65d99fc4fc Mon Sep 17 00:00:00 2001 From: Fabian Reinartz Date: Fri, 2 Nov 2018 01:53:00 +0100 Subject: [PATCH] Add resource to protocol (#137) Signed-off-by: Fabian Reinartz --- .../proto/agent/metrics/v1/BUILD.bazel | 2 + .../agent/metrics/v1/metrics_service.proto | 8 ++++ .../proto/agent/trace/v1/BUILD.bazel | 2 + .../proto/agent/trace/v1/trace_service.proto | 7 ++++ src/opencensus/proto/metrics/v1/BUILD.bazel | 4 ++ src/opencensus/proto/metrics/v1/metrics.proto | 5 +++ src/opencensus/proto/resource/v1/BUILD.bazel | 41 +++++++++++++++++++ .../proto/resource/v1/resource.proto | 33 +++++++++++++++ 8 files changed, 102 insertions(+) create mode 100644 src/opencensus/proto/resource/v1/BUILD.bazel create mode 100644 src/opencensus/proto/resource/v1/resource.proto diff --git a/src/opencensus/proto/agent/metrics/v1/BUILD.bazel b/src/opencensus/proto/agent/metrics/v1/BUILD.bazel index 0f31dfe..054474c 100644 --- a/src/opencensus/proto/agent/metrics/v1/BUILD.bazel +++ b/src/opencensus/proto/agent/metrics/v1/BUILD.bazel @@ -23,6 +23,7 @@ proto_library( deps = [ "//opencensus/proto/agent/common/v1:common_proto", "//opencensus/proto/metrics/v1:metrics_proto", + "//opencensus/proto/resource/v1:resource_proto", ], ) @@ -51,6 +52,7 @@ go_proto_library( proto_deps = [ "//opencensus/proto/agent/common/v1:common_proto_go", "//opencensus/proto/metrics/v1:metrics_proto_go", + "//opencensus/proto/resource/v1:resource_proto_go", ], pb_options = [ # omit the go_package declared in proto files to make bazel works as expect diff --git a/src/opencensus/proto/agent/metrics/v1/metrics_service.proto b/src/opencensus/proto/agent/metrics/v1/metrics_service.proto index a74c210..f2aac28 100644 --- a/src/opencensus/proto/agent/metrics/v1/metrics_service.proto +++ b/src/opencensus/proto/agent/metrics/v1/metrics_service.proto @@ -18,6 +18,7 @@ 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"; @@ -42,6 +43,13 @@ message ExportMetricsServiceRequest { // 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/src/opencensus/proto/agent/trace/v1/BUILD.bazel b/src/opencensus/proto/agent/trace/v1/BUILD.bazel index a17c8e1..c571d2b 100644 --- a/src/opencensus/proto/agent/trace/v1/BUILD.bazel +++ b/src/opencensus/proto/agent/trace/v1/BUILD.bazel @@ -22,6 +22,7 @@ proto_library( 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", ], @@ -51,6 +52,7 @@ go_proto_library( ], proto_deps = [ "//opencensus/proto/agent/common/v1:common_proto_go", + "//opencensus/proto/resource/v1:resource_proto_go", "//opencensus/proto/trace/v1:trace_proto_go", "//opencensus/proto/trace/v1:trace_config_proto_go", ], diff --git a/src/opencensus/proto/agent/trace/v1/trace_service.proto b/src/opencensus/proto/agent/trace/v1/trace_service.proto index a413ed2..ed564ac 100644 --- a/src/opencensus/proto/agent/trace/v1/trace_service.proto +++ b/src/opencensus/proto/agent/trace/v1/trace_service.proto @@ -20,6 +20,7 @@ syntax = "proto3"; 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"; @@ -72,6 +73,12 @@ message ExportTraceServiceRequest { // 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/src/opencensus/proto/metrics/v1/BUILD.bazel b/src/opencensus/proto/metrics/v1/BUILD.bazel index 9cbe63e..a46197d 100644 --- a/src/opencensus/proto/metrics/v1/BUILD.bazel +++ b/src/opencensus/proto/metrics/v1/BUILD.bazel @@ -22,6 +22,7 @@ proto_library( deps = [ "@com_google_protobuf//:timestamp_proto", "@com_google_protobuf//:wrappers_proto", + "//opencensus/proto/resource/v1:resource_proto", ], ) @@ -48,6 +49,9 @@ go_proto_library( # omit the go_package declared in proto files to make bazel works as expect "paths=source_relative", ], + proto_deps = [ + "//opencensus/proto/resource/v1:resource_proto_go", + ], deps = [ "@com_github_golang_protobuf//ptypes/timestamp:go_default_library", "@com_github_golang_protobuf//ptypes/wrappers:go_default_library", diff --git a/src/opencensus/proto/metrics/v1/metrics.proto b/src/opencensus/proto/metrics/v1/metrics.proto index dee16eb..3f1ca42 100644 --- a/src/opencensus/proto/metrics/v1/metrics.proto +++ b/src/opencensus/proto/metrics/v1/metrics.proto @@ -23,6 +23,7 @@ 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"; @@ -48,6 +49,10 @@ message Metric { // One or more timeseries for a single metric, where each timeseries has // one or more points. repeated TimeSeries timeseries = 3; + + // 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 = 4; } // Defines a metric type and its schema. diff --git a/src/opencensus/proto/resource/v1/BUILD.bazel b/src/opencensus/proto/resource/v1/BUILD.bazel new file mode 100644 index 0000000..b5da614 --- /dev/null +++ b/src/opencensus/proto/resource/v1/BUILD.bazel @@ -0,0 +1,41 @@ +# 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("@org_pubref_rules_protobuf//go:rules.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", + protos = ["resource.proto"], + pb_options = [ + # omit the go_package declared in proto files to make bazel works as expect + "paths=source_relative", + ], +) diff --git a/src/opencensus/proto/resource/v1/resource.proto b/src/opencensus/proto/resource/v1/resource.proto new file mode 100644 index 0000000..61e5983 --- /dev/null +++ b/src/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 labels = 2; +}