Skip to content
This repository was archived by the owner on Oct 3, 2023. It is now read-only.

Commit fc93f64

Browse files
fabxcsongy23
authored andcommitted
Add resource to protocol (#137)
Signed-off-by: Fabian Reinartz <freinartz@google.com>
1 parent 61f8bc7 commit fc93f64

File tree

8 files changed

+102
-0
lines changed

8 files changed

+102
-0
lines changed

src/opencensus/proto/agent/metrics/v1/BUILD.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ proto_library(
2323
deps = [
2424
"//opencensus/proto/agent/common/v1:common_proto",
2525
"//opencensus/proto/metrics/v1:metrics_proto",
26+
"//opencensus/proto/resource/v1:resource_proto",
2627
],
2728
)
2829

@@ -51,6 +52,7 @@ go_proto_library(
5152
proto_deps = [
5253
"//opencensus/proto/agent/common/v1:common_proto_go",
5354
"//opencensus/proto/metrics/v1:metrics_proto_go",
55+
"//opencensus/proto/resource/v1:resource_proto_go",
5456
],
5557
pb_options = [
5658
# omit the go_package declared in proto files to make bazel works as expect

src/opencensus/proto/agent/metrics/v1/metrics_service.proto

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package opencensus.proto.agent.metrics.v1;
1818

1919
import "opencensus/proto/agent/common/v1/common.proto";
2020
import "opencensus/proto/metrics/v1/metrics.proto";
21+
import "opencensus/proto/resource/v1/resource.proto";
2122

2223
option java_multiple_files = true;
2324
option java_package = "io.opencensus.proto.agent.metrics.v1";
@@ -42,6 +43,13 @@ message ExportMetricsServiceRequest {
4243

4344
// A list of metrics that belong to the last received Node.
4445
repeated opencensus.proto.metrics.v1.Metric metrics = 2;
46+
47+
// The resource for the metrics in this message that do not have an explicit
48+
// resource set.
49+
// If unset, the most recently set resource in the RPC stream applies. It is
50+
// valid to never be set within a stream, e.g. when no resource info is known
51+
// at all or when all sent metrics have an explicit resource set.
52+
opencensus.proto.resource.v1.Resource resource = 3;
4553
}
4654

4755
message ExportMetricsServiceResponse {

src/opencensus/proto/agent/trace/v1/BUILD.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ proto_library(
2222
srcs = ["trace_service.proto"],
2323
deps = [
2424
"//opencensus/proto/agent/common/v1:common_proto",
25+
"//opencensus/proto/resource/v1:resource_proto",
2526
"//opencensus/proto/trace/v1:trace_proto",
2627
"//opencensus/proto/trace/v1:trace_config_proto",
2728
],
@@ -51,6 +52,7 @@ go_proto_library(
5152
],
5253
proto_deps = [
5354
"//opencensus/proto/agent/common/v1:common_proto_go",
55+
"//opencensus/proto/resource/v1:resource_proto_go",
5456
"//opencensus/proto/trace/v1:trace_proto_go",
5557
"//opencensus/proto/trace/v1:trace_config_proto_go",
5658
],

src/opencensus/proto/agent/trace/v1/trace_service.proto

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ syntax = "proto3";
2020
package opencensus.proto.agent.trace.v1;
2121

2222
import "opencensus/proto/agent/common/v1/common.proto";
23+
import "opencensus/proto/resource/v1/resource.proto";
2324
import "opencensus/proto/trace/v1/trace.proto";
2425
import "opencensus/proto/trace/v1/trace_config.proto";
2526

@@ -72,6 +73,12 @@ message ExportTraceServiceRequest {
7273

7374
// A list of Spans that belong to the last received Node.
7475
repeated opencensus.proto.trace.v1.Span spans = 2;
76+
77+
// The resource for the spans in this message that do not have an explicit
78+
// resource set.
79+
// If unset, the most recently set resource in the RPC stream applies. It is
80+
// valid to never be set within a stream, e.g. when no resource info is known.
81+
opencensus.proto.resource.v1.Resource resource = 3;
7582
}
7683

7784
message ExportTraceServiceResponse {

src/opencensus/proto/metrics/v1/BUILD.bazel

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ proto_library(
2222
deps = [
2323
"@com_google_protobuf//:timestamp_proto",
2424
"@com_google_protobuf//:wrappers_proto",
25+
"//opencensus/proto/resource/v1:resource_proto",
2526
],
2627
)
2728

@@ -48,6 +49,9 @@ go_proto_library(
4849
# omit the go_package declared in proto files to make bazel works as expect
4950
"paths=source_relative",
5051
],
52+
proto_deps = [
53+
"//opencensus/proto/resource/v1:resource_proto_go",
54+
],
5155
deps = [
5256
"@com_github_golang_protobuf//ptypes/timestamp:go_default_library",
5357
"@com_github_golang_protobuf//ptypes/wrappers:go_default_library",

src/opencensus/proto/metrics/v1/metrics.proto

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ package opencensus.proto.metrics.v1;
2323

2424
import "google/protobuf/timestamp.proto";
2525
import "google/protobuf/wrappers.proto";
26+
import "opencensus/proto/resource/v1/resource.proto";
2627

2728
option go_package = "github.com/census-instrumentation/opencensus-proto/gen-go/metrics/v1";
2829

@@ -48,6 +49,10 @@ message Metric {
4849
// One or more timeseries for a single metric, where each timeseries has
4950
// one or more points.
5051
repeated TimeSeries timeseries = 3;
52+
53+
// The resource for the metric. If unset, it may be set to a default value
54+
// provided for a sequence of messages in an RPC stream.
55+
opencensus.proto.resource.v1.Resource resource = 4;
5156
}
5257

5358
// Defines a metric type and its schema.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Copyright 2018, OpenCensus Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
package(default_visibility = ["//visibility:public"])
16+
17+
load("@org_pubref_rules_protobuf//go:rules.bzl", "go_proto_library")
18+
19+
proto_library(
20+
name = "resource_proto",
21+
srcs = ["resource.proto"],
22+
)
23+
24+
cc_proto_library(
25+
name = "resource_proto_cc",
26+
deps = [":resource_proto"],
27+
)
28+
29+
java_proto_library(
30+
name = "resource_proto_java",
31+
deps = [":resource_proto"],
32+
)
33+
34+
go_proto_library(
35+
name = "resource_proto_go",
36+
protos = ["resource.proto"],
37+
pb_options = [
38+
# omit the go_package declared in proto files to make bazel works as expect
39+
"paths=source_relative",
40+
],
41+
)
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright 2018, OpenCensus Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
syntax = "proto3";
16+
17+
package opencensus.proto.resource.v1;
18+
19+
option go_package = "github.com/census-instrumentation/opencensus-proto/gen-go/resource/v1";
20+
21+
option java_multiple_files = true;
22+
option java_package = "io.opencensus.proto.resource.v1";
23+
option java_outer_classname = "ResourceProto";
24+
25+
// Resource information.
26+
message Resource {
27+
28+
// Type identifier for the resource.
29+
string type = 1;
30+
31+
// Set of labels that describe the resource.
32+
map<string,string> labels = 2;
33+
}

0 commit comments

Comments
 (0)