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

Commit ea7a781

Browse files
authored
Add gRPC plugin and Stackdriver exporters. (#24)
1 parent 323be24 commit ea7a781

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+5908
-3
lines changed

.travis.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ before_install:
99
- ./bazel-0.8.1-installer-linux-x86_64.sh --user
1010

1111
script:
12-
- bazel build --noshow_progress -k //...
13-
- bazel test --noshow_progress -k //...
12+
# We can't use --noshow_progress because Travis terminates the
13+
# build after 10 mins without output.
14+
- bazel build -k $(bazel query //... | grep -v :_)
15+
- bazel test -k $(bazel query //... | grep -v :_)
1416
- ./format.sh

WORKSPACE

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,30 @@ http_archive(
3535
urls = ["https://github.com/google/googletest/archive/master.zip"],
3636
)
3737

38+
# gRPC
39+
http_archive(
40+
name = "com_github_grpc_grpc",
41+
# TODO: Switch to master branch:
42+
#urls = ["https://github.com/grpc/grpc/archive/master.zip"],
43+
#strip_prefix = "grpc-master"
44+
urls = ["https://github.com/grpc/grpc/archive/v1.9.1.zip"],
45+
strip_prefix = "grpc-1.9.1",
46+
)
47+
48+
load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")
49+
grpc_deps()
50+
51+
# These bind()s are needed for the cc_grpc_library() rule to work.
52+
bind(
53+
name = "grpc++_codegen_proto",
54+
actual = "@com_github_grpc_grpc//:grpc++_codegen_proto",
55+
)
56+
57+
bind(
58+
name = "grpc_cpp_plugin",
59+
actual = "@com_github_grpc_grpc//:grpc_cpp_plugin",
60+
)
61+
3862
# Google Benchmark library.
3963
# Adapted from cctz's WORKSPACE.
4064
# Upstream support for bazel is tracked in

google/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
These proto files are copied from https://github.com/googleapis/googleapis
2+
3+
In the future, we will depend on `googleapis` directly.

google/api/BUILD

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
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+
licenses(["notice"]) # Apache License 2.0
16+
17+
package(default_visibility = [
18+
"//google:__subpackages__",
19+
"//opencensus:__subpackages__",
20+
])
21+
22+
load("@com_github_grpc_grpc//bazel:cc_grpc_library.bzl", "cc_grpc_library")
23+
24+
cc_grpc_library(
25+
name = "annotations",
26+
srcs = ["annotations.proto"],
27+
generate_mock = False,
28+
proto_only = False,
29+
use_external = True,
30+
well_known_protos = True,
31+
deps = [":http"],
32+
)
33+
34+
cc_grpc_library(
35+
name = "distribution",
36+
srcs = ["distribution.proto"],
37+
generate_mock = False,
38+
proto_only = False,
39+
use_external = True,
40+
well_known_protos = True,
41+
deps = [":annotations"],
42+
)
43+
44+
cc_grpc_library(
45+
name = "http",
46+
srcs = ["http.proto"],
47+
generate_mock = False,
48+
proto_only = False,
49+
use_external = True,
50+
well_known_protos = True,
51+
deps = [],
52+
)
53+
54+
cc_grpc_library(
55+
name = "label",
56+
srcs = ["label.proto"],
57+
generate_mock = False,
58+
proto_only = False,
59+
use_external = True,
60+
well_known_protos = True,
61+
deps = [],
62+
)
63+
64+
cc_grpc_library(
65+
name = "metric",
66+
srcs = ["metric.proto"],
67+
generate_mock = False,
68+
proto_only = False,
69+
use_external = True,
70+
well_known_protos = True,
71+
deps = [":label"],
72+
)
73+
74+
cc_grpc_library(
75+
name = "monitored_resource",
76+
srcs = ["monitored_resource.proto"],
77+
generate_mock = False,
78+
proto_only = False,
79+
use_external = True,
80+
well_known_protos = True,
81+
deps = [":label"],
82+
)

google/api/annotations.proto

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright (c) 2015, Google Inc.
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 google.api;
18+
19+
import "google/api/http.proto";
20+
import "google/protobuf/descriptor.proto";
21+
22+
option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations";
23+
option java_multiple_files = true;
24+
option java_outer_classname = "AnnotationsProto";
25+
option java_package = "com.google.api";
26+
option objc_class_prefix = "GAPI";
27+
28+
extend google.protobuf.MethodOptions {
29+
// See `HttpRule`.
30+
HttpRule http = 72295728;
31+
}

google/api/distribution.proto

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
// Copyright 2016 Google Inc.
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 google.api;
18+
19+
import "google/api/annotations.proto";
20+
import "google/protobuf/any.proto";
21+
import "google/protobuf/timestamp.proto";
22+
23+
option go_package = "google.golang.org/genproto/googleapis/api/distribution;distribution";
24+
option java_multiple_files = true;
25+
option java_outer_classname = "DistributionProto";
26+
option java_package = "com.google.api";
27+
28+
29+
// Distribution contains summary statistics for a population of values and,
30+
// optionally, a histogram representing the distribution of those values across
31+
// a specified set of histogram buckets.
32+
//
33+
// The summary statistics are the count, mean, sum of the squared deviation from
34+
// the mean, the minimum, and the maximum of the set of population of values.
35+
//
36+
// The histogram is based on a sequence of buckets and gives a count of values
37+
// that fall into each bucket. The boundaries of the buckets are given either
38+
// explicitly or by specifying parameters for a method of computing them
39+
// (buckets of fixed width or buckets of exponentially increasing width).
40+
//
41+
// Although it is not forbidden, it is generally a bad idea to include
42+
// non-finite values (infinities or NaNs) in the population of values, as this
43+
// will render the `mean` and `sum_of_squared_deviation` fields meaningless.
44+
message Distribution {
45+
// The range of the population values.
46+
message Range {
47+
// The minimum of the population values.
48+
double min = 1;
49+
50+
// The maximum of the population values.
51+
double max = 2;
52+
}
53+
54+
// A Distribution may optionally contain a histogram of the values in the
55+
// population. The histogram is given in `bucket_counts` as counts of values
56+
// that fall into one of a sequence of non-overlapping buckets. The sequence
57+
// of buckets is described by `bucket_options`.
58+
//
59+
// A bucket specifies an inclusive lower bound and exclusive upper bound for
60+
// the values that are counted for that bucket. The upper bound of a bucket
61+
// is strictly greater than the lower bound.
62+
//
63+
// The sequence of N buckets for a Distribution consists of an underflow
64+
// bucket (number 0), zero or more finite buckets (number 1 through N - 2) and
65+
// an overflow bucket (number N - 1). The buckets are contiguous: the lower
66+
// bound of bucket i (i > 0) is the same as the upper bound of bucket i - 1.
67+
// The buckets span the whole range of finite values: lower bound of the
68+
// underflow bucket is -infinity and the upper bound of the overflow bucket is
69+
// +infinity. The finite buckets are so-called because both bounds are
70+
// finite.
71+
//
72+
// `BucketOptions` describes bucket boundaries in one of three ways. Two
73+
// describe the boundaries by giving parameters for a formula to generate
74+
// boundaries and one gives the bucket boundaries explicitly.
75+
//
76+
// If `bucket_boundaries` is not given, then no `bucket_counts` may be given.
77+
message BucketOptions {
78+
// Specify a sequence of buckets that all have the same width (except
79+
// overflow and underflow). Each bucket represents a constant absolute
80+
// uncertainty on the specific value in the bucket.
81+
//
82+
// Defines `num_finite_buckets + 2` (= N) buckets with these boundaries for
83+
// bucket `i`:
84+
//
85+
// Upper bound (0 <= i < N-1): offset + (width * i).
86+
// Lower bound (1 <= i < N): offset + (width * (i - 1)).
87+
message Linear {
88+
// Must be greater than 0.
89+
int32 num_finite_buckets = 1;
90+
91+
// Must be greater than 0.
92+
double width = 2;
93+
94+
// Lower bound of the first bucket.
95+
double offset = 3;
96+
}
97+
98+
// Specify a sequence of buckets that have a width that is proportional to
99+
// the value of the lower bound. Each bucket represents a constant relative
100+
// uncertainty on a specific value in the bucket.
101+
//
102+
// Defines `num_finite_buckets + 2` (= N) buckets with these boundaries for
103+
// bucket i:
104+
//
105+
// Upper bound (0 <= i < N-1): scale * (growth_factor ^ i).
106+
// Lower bound (1 <= i < N): scale * (growth_factor ^ (i - 1)).
107+
message Exponential {
108+
// Must be greater than 0.
109+
int32 num_finite_buckets = 1;
110+
111+
// Must be greater than 1.
112+
double growth_factor = 2;
113+
114+
// Must be greater than 0.
115+
double scale = 3;
116+
}
117+
118+
// A set of buckets with arbitrary widths.
119+
//
120+
// Defines `size(bounds) + 1` (= N) buckets with these boundaries for
121+
// bucket i:
122+
//
123+
// Upper bound (0 <= i < N-1): bounds[i]
124+
// Lower bound (1 <= i < N); bounds[i - 1]
125+
//
126+
// There must be at least one element in `bounds`. If `bounds` has only one
127+
// element, there are no finite buckets, and that single element is the
128+
// common boundary of the overflow and underflow buckets.
129+
message Explicit {
130+
// The values must be monotonically increasing.
131+
repeated double bounds = 1;
132+
}
133+
134+
// Exactly one of these three fields must be set.
135+
oneof options {
136+
// The linear bucket.
137+
Linear linear_buckets = 1;
138+
139+
// The exponential buckets.
140+
Exponential exponential_buckets = 2;
141+
142+
// The explicit buckets.
143+
Explicit explicit_buckets = 3;
144+
}
145+
}
146+
147+
// The number of values in the population. Must be non-negative.
148+
int64 count = 1;
149+
150+
// The arithmetic mean of the values in the population. If `count` is zero
151+
// then this field must be zero.
152+
double mean = 2;
153+
154+
// The sum of squared deviations from the mean of the values in the
155+
// population. For values x_i this is:
156+
//
157+
// Sum[i=1..n]((x_i - mean)^2)
158+
//
159+
// Knuth, "The Art of Computer Programming", Vol. 2, page 323, 3rd edition
160+
// describes Welford's method for accumulating this sum in one pass.
161+
//
162+
// If `count` is zero then this field must be zero.
163+
double sum_of_squared_deviation = 3;
164+
165+
// If specified, contains the range of the population values. The field
166+
// must not be present if the `count` is zero.
167+
Range range = 4;
168+
169+
// Defines the histogram bucket boundaries.
170+
BucketOptions bucket_options = 6;
171+
172+
// If `bucket_options` is given, then the sum of the values in `bucket_counts`
173+
// must equal the value in `count`. If `bucket_options` is not given, no
174+
// `bucket_counts` fields may be given.
175+
//
176+
// Bucket counts are given in order under the numbering scheme described
177+
// above (the underflow bucket has number 0; the finite buckets, if any,
178+
// have numbers 1 through N-2; the overflow bucket has number N-1).
179+
//
180+
// The size of `bucket_counts` must be no greater than N as defined in
181+
// `bucket_options`.
182+
//
183+
// Any suffix of trailing zero bucket_count fields may be omitted.
184+
repeated int64 bucket_counts = 7;
185+
}

0 commit comments

Comments
 (0)