-
Notifications
You must be signed in to change notification settings - Fork 94
Add tags package based on the specs. #172
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Copyright 2019, 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 = "tags_proto", | ||
srcs = ["tags.proto"], | ||
) | ||
|
||
cc_proto_library( | ||
name = "tags_proto_cc", | ||
deps = [":tags_proto"], | ||
) | ||
|
||
java_proto_library( | ||
name = "tags_proto_java", | ||
deps = [":tags_proto"], | ||
) | ||
|
||
go_proto_library( | ||
name = "tags_proto_go", | ||
importpath = "github.com/census-instrumentation/opencensus-proto/gen-go/tags/v1", | ||
proto = ":tags_proto", | ||
deps = [ | ||
"@com_github_golang_protobuf//ptypes/timestamp:go_default_library", | ||
], | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// Copyright 2019, 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.tags.v1; | ||
|
||
option go_package = "github.com/census-instrumentation/opencensus-proto/gen-go/tags/v1"; | ||
|
||
option java_multiple_files = true; | ||
option java_package = "io.opencensus.proto.tags.v1"; | ||
option java_outer_classname = "TagsProto"; | ||
|
||
// TagScope is used to determine the scope of a Tag. | ||
// | ||
// | ||
enum TagScope { | ||
// Unknown type. | ||
TYPE_UNSPECIFIED = 0; | ||
// Tag with Local scope are used within the process it created. | ||
LOCAL_SCOPE = 1; | ||
// A tag is created with the Request scope then it is propagated across | ||
// process boundaries subject to outgoing and incoming (on remote side) | ||
// filter criteria. | ||
REQUEST_SCOPE = 2; | ||
} | ||
|
||
// TagKey is the name of the Tag. | ||
message TagKey { | ||
// Restrictions: | ||
// * MUST contain only printable ASCII (codes between 32 and 126 inclusive) | ||
// * MUST have length greater than zero and less than 256. | ||
// * MUST not be empty. | ||
// | ||
// This field is required. | ||
string value = 1; | ||
} | ||
|
||
// TagValue is the value associated with a Tag. | ||
message TagValue { | ||
// It MUST contain only printable ASCII (codes between 32 and 126) | ||
// | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It cannot be longer than 256 right? https://github.com/census-instrumentation/opencensus-java/blob/master/api/src/main/java/io/opencensus/tags/TagValue.java#L49 |
||
// This field is required. | ||
string value = 1; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not truncatable string? If it is not a truncatable string - what's the reason to have a message for it and not simply use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The reason to have a message:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I got why we need a message for |
||
} | ||
|
||
// A Tag consists of TagScope, TagKey, and TagValue. | ||
message Tag { | ||
// This field is required. | ||
TagKey key = 1; | ||
|
||
// This field is required. | ||
TagValue value = 2; | ||
|
||
// This field is optional, if not present the default scope is REQUEST_SCOPE | ||
// (the motivation is backwards compatibility). | ||
// | ||
// This field is only needed for data generation and tags defining cases, not | ||
// for exporting. | ||
TagScope scope = 3; | ||
} | ||
|
||
// TagMap is an abstract data type that represents collection of tags. i.e., | ||
// each key is associated with exactly one value. | ||
message TagMap { | ||
// The list of tags MUST contains unique TagKeys. | ||
// | ||
// Not a map becuase the proto3 map does not allow a message as the key. | ||
// https://developers.google.com/protocol-buffers/docs/proto3#maps | ||
repeated Tag tags = 1; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so tags with the same name is allowed, correct? Perhaps something should be said about it in comment There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The list should contains unique TagKeys. The proto3 map does not allow the map_key to be a proto message see https://developers.google.com/protocol-buffers/docs/proto3#maps. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The fact that the same key value is not allowed is not clear from the comment at all. As minimum I suggest to indicate this requirement in a comment. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From my perspective - compromising on data integrity by not forcing uniqueness of keys in favor of potential extensibility sounds a hard sell in this case. Do you see a scenario in which key will be typed? Any other information like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. BTW, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just to clarify - some misunderstanding may be coming from how you can read the sentence "each key is associated with exactly one value.". If you treat "each key" as unique string - it is already handled. But I read it as one key object maps to one value object. I see you already handled it, just clarifying what I meant, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The reason of using a TagKey instead of directly string is because few reasons:
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be like ->
string name = 1;