Skip to content

Commit 60a4c17

Browse files
committed
Vendor OpenTelemetry protocol
In preparation for supporting the OpenTelemetry protocol for the proxy's traces, this vendors the relevant protobufs as well as some convenience helpers here. This works around the fact that the existing `opentelemetry` crates do not support the version of tonic that we currently use (0.10), and this vendoring can be removed once we update. [#10111](linkerd/linkerd2#10111) Signed-off-by: Scott Fleener <scott@buoyant.io>
1 parent d025cf9 commit 60a4c17

File tree

18 files changed

+2010
-0
lines changed

18 files changed

+2010
-0
lines changed

Cargo.lock

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,12 @@ dependencies = [
288288
"fslock",
289289
]
290290

291+
[[package]]
292+
name = "bumpalo"
293+
version = "3.16.0"
294+
source = "registry+https://github.com/rust-lang/crates.io-index"
295+
checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c"
296+
291297
[[package]]
292298
name = "byteorder"
293299
version = "1.5.0"
@@ -1032,6 +1038,15 @@ dependencies = [
10321038
"libc",
10331039
]
10341040

1041+
[[package]]
1042+
name = "js-sys"
1043+
version = "0.3.70"
1044+
source = "registry+https://github.com/rust-lang/crates.io-index"
1045+
checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a"
1046+
dependencies = [
1047+
"wasm-bindgen",
1048+
]
1049+
10351050
[[package]]
10361051
name = "kubert-prometheus-tokio"
10371052
version = "0.1.0"
@@ -2577,6 +2592,59 @@ dependencies = [
25772592
"tonic-build",
25782593
]
25792594

2595+
[[package]]
2596+
name = "opentelemetry"
2597+
version = "0.23.0"
2598+
source = "registry+https://github.com/rust-lang/crates.io-index"
2599+
checksum = "1b69a91d4893e713e06f724597ad630f1fa76057a5e1026c0ca67054a9032a76"
2600+
dependencies = [
2601+
"futures-core",
2602+
"futures-sink",
2603+
"js-sys",
2604+
"once_cell",
2605+
"pin-project-lite",
2606+
"thiserror",
2607+
]
2608+
2609+
[[package]]
2610+
name = "opentelemetry-proto"
2611+
version = "0.1.0"
2612+
dependencies = [
2613+
"opentelemetry",
2614+
"opentelemetry_sdk",
2615+
"prost",
2616+
"tonic",
2617+
"tonic-build",
2618+
]
2619+
2620+
[[package]]
2621+
name = "opentelemetry_sdk"
2622+
version = "0.23.0"
2623+
source = "registry+https://github.com/rust-lang/crates.io-index"
2624+
checksum = "ae312d58eaa90a82d2e627fd86e075cf5230b3f11794e2ed74199ebbe572d4fd"
2625+
dependencies = [
2626+
"async-trait",
2627+
"futures-channel",
2628+
"futures-executor",
2629+
"futures-util",
2630+
"lazy_static",
2631+
"once_cell",
2632+
"opentelemetry",
2633+
"ordered-float",
2634+
"percent-encoding",
2635+
"rand",
2636+
"thiserror",
2637+
]
2638+
2639+
[[package]]
2640+
name = "ordered-float"
2641+
version = "4.2.2"
2642+
source = "registry+https://github.com/rust-lang/crates.io-index"
2643+
checksum = "4a91171844676f8c7990ce64959210cd2eaef32c2612c50f9fae9f8aaa6065a6"
2644+
dependencies = [
2645+
"num-traits",
2646+
]
2647+
25802648
[[package]]
25812649
name = "overload"
25822650
version = "0.1.1"
@@ -3715,6 +3783,61 @@ version = "0.11.0+wasi-snapshot-preview1"
37153783
source = "registry+https://github.com/rust-lang/crates.io-index"
37163784
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
37173785

3786+
[[package]]
3787+
name = "wasm-bindgen"
3788+
version = "0.2.93"
3789+
source = "registry+https://github.com/rust-lang/crates.io-index"
3790+
checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5"
3791+
dependencies = [
3792+
"cfg-if",
3793+
"once_cell",
3794+
"wasm-bindgen-macro",
3795+
]
3796+
3797+
[[package]]
3798+
name = "wasm-bindgen-backend"
3799+
version = "0.2.93"
3800+
source = "registry+https://github.com/rust-lang/crates.io-index"
3801+
checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b"
3802+
dependencies = [
3803+
"bumpalo",
3804+
"log",
3805+
"once_cell",
3806+
"proc-macro2",
3807+
"quote",
3808+
"syn",
3809+
"wasm-bindgen-shared",
3810+
]
3811+
3812+
[[package]]
3813+
name = "wasm-bindgen-macro"
3814+
version = "0.2.93"
3815+
source = "registry+https://github.com/rust-lang/crates.io-index"
3816+
checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf"
3817+
dependencies = [
3818+
"quote",
3819+
"wasm-bindgen-macro-support",
3820+
]
3821+
3822+
[[package]]
3823+
name = "wasm-bindgen-macro-support"
3824+
version = "0.2.93"
3825+
source = "registry+https://github.com/rust-lang/crates.io-index"
3826+
checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836"
3827+
dependencies = [
3828+
"proc-macro2",
3829+
"quote",
3830+
"syn",
3831+
"wasm-bindgen-backend",
3832+
"wasm-bindgen-shared",
3833+
]
3834+
3835+
[[package]]
3836+
name = "wasm-bindgen-shared"
3837+
version = "0.2.93"
3838+
source = "registry+https://github.com/rust-lang/crates.io-index"
3839+
checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484"
3840+
37183841
[[package]]
37193842
name = "widestring"
37203843
version = "1.1.0"

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ members = [
7777
"linkerd/transport-metrics",
7878
"linkerd2-proxy",
7979
"opencensus-proto",
80+
"opentelemetry-proto",
8081
"spiffe-proto",
8182
"tools",
8283
]

opentelemetry-proto/Cargo.toml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[package]
2+
name = "opentelemetry-proto"
3+
version = "0.1.0"
4+
authors = ["The OpenTelemetry Authors"]
5+
license = "Apache-2.0"
6+
edition = "2021"
7+
publish = false
8+
description = """
9+
gRPC bindings for OpenTelemetry.
10+
11+
Vendored from https://github.com/open-telemetry/opentelemetry-rust/.
12+
"""
13+
14+
[dependencies]
15+
tonic = { version = "0.10", features = ["codegen", "prost", "transport"] }
16+
prost = "0.12"
17+
opentelemetry = { version = "0.23", default-features = false, features = ["trace"] }
18+
opentelemetry_sdk = { version = "0.23", default-features = false, features = ["trace"] }
19+
20+
[dev-dependencies]
21+
opentelemetry = { version = "0.23", default-features = false, features = ["trace", "testing"] }
22+
tonic-build = { version = "0.10", default-features = false, features = ["prost"] }
23+
24+
[lib]
25+
doctest = false

opentelemetry-proto/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# opentelemetry-proto
2+
3+
This library mirrors parts of the
4+
[`opentelemetry-proto`](https://github.com/census-instrumentation/opencensus-proto/)
5+
repo, with the non-tracing and build-related components removed.
6+
7+
## License
8+
9+
Copyright 2024, OpenTelemetry Authors
10+
11+
Licensed under the Apache License, Version 2.0 (the "License");
12+
you may not use this file except in compliance with the License.
13+
You may obtain a copy of the License at
14+
15+
http://www.apache.org/licenses/LICENSE-2.0
16+
17+
Unless required by applicable law or agreed to in writing, software
18+
distributed under the License is distributed on an "AS IS" BASIS,
19+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20+
See the License for the specific language governing permissions and
21+
limitations under the License.
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
// Copyright 2019, OpenTelemetry 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 opentelemetry.proto.collector.trace.v1;
18+
19+
import "opentelemetry/proto/trace/v1/trace.proto";
20+
21+
option csharp_namespace = "OpenTelemetry.Proto.Collector.Trace.V1";
22+
option java_multiple_files = true;
23+
option java_package = "io.opentelemetry.proto.collector.trace.v1";
24+
option java_outer_classname = "TraceServiceProto";
25+
option go_package = "go.opentelemetry.io/proto/otlp/collector/trace/v1";
26+
27+
// Service that can be used to push spans between one Application instrumented with
28+
// OpenTelemetry and a collector, or between a collector and a central collector (in this
29+
// case spans are sent/received to/from multiple Applications).
30+
service TraceService {
31+
// For performance reasons, it is recommended to keep this RPC
32+
// alive for the entire life of the application.
33+
rpc Export(ExportTraceServiceRequest) returns (ExportTraceServiceResponse) {}
34+
}
35+
36+
message ExportTraceServiceRequest {
37+
// An array of ResourceSpans.
38+
// For data coming from a single resource this array will typically contain one
39+
// element. Intermediary nodes (such as OpenTelemetry Collector) that receive
40+
// data from multiple origins typically batch the data before forwarding further and
41+
// in that case this array will contain multiple elements.
42+
repeated opentelemetry.proto.trace.v1.ResourceSpans resource_spans = 1;
43+
}
44+
45+
message ExportTraceServiceResponse {
46+
// The details of a partially successful export request.
47+
//
48+
// If the request is only partially accepted
49+
// (i.e. when the server accepts only parts of the data and rejects the rest)
50+
// the server MUST initialize the `partial_success` field and MUST
51+
// set the `rejected_<signal>` with the number of items it rejected.
52+
//
53+
// Servers MAY also make use of the `partial_success` field to convey
54+
// warnings/suggestions to senders even when the request was fully accepted.
55+
// In such cases, the `rejected_<signal>` MUST have a value of `0` and
56+
// the `error_message` MUST be non-empty.
57+
//
58+
// A `partial_success` message with an empty value (rejected_<signal> = 0 and
59+
// `error_message` = "") is equivalent to it not being set/present. Senders
60+
// SHOULD interpret it the same way as in the full success case.
61+
ExportTracePartialSuccess partial_success = 1;
62+
}
63+
64+
message ExportTracePartialSuccess {
65+
// The number of rejected spans.
66+
//
67+
// A `rejected_<signal>` field holding a `0` value indicates that the
68+
// request was fully accepted.
69+
int64 rejected_spans = 1;
70+
71+
// A developer-facing human-readable message in English. It should be used
72+
// either to explain why the server rejected parts of the data during a partial
73+
// success or to convey warnings/suggestions during a full success. The message
74+
// should offer guidance on how users can address such issues.
75+
//
76+
// error_message is an optional field. An error_message with an empty value
77+
// is equivalent to it not being set.
78+
string error_message = 2;
79+
}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
// Copyright 2019, OpenTelemetry 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 opentelemetry.proto.common.v1;
18+
19+
option csharp_namespace = "OpenTelemetry.Proto.Common.V1";
20+
option java_multiple_files = true;
21+
option java_package = "io.opentelemetry.proto.common.v1";
22+
option java_outer_classname = "CommonProto";
23+
option go_package = "go.opentelemetry.io/proto/otlp/common/v1";
24+
25+
// AnyValue is used to represent any type of attribute value. AnyValue may contain a
26+
// primitive value such as a string or integer or it may contain an arbitrary nested
27+
// object containing arrays, key-value lists and primitives.
28+
message AnyValue {
29+
// The value is one of the listed fields. It is valid for all values to be unspecified
30+
// in which case this AnyValue is considered to be "empty".
31+
oneof value {
32+
string string_value = 1;
33+
bool bool_value = 2;
34+
int64 int_value = 3;
35+
double double_value = 4;
36+
ArrayValue array_value = 5;
37+
KeyValueList kvlist_value = 6;
38+
bytes bytes_value = 7;
39+
}
40+
}
41+
42+
// ArrayValue is a list of AnyValue messages. We need ArrayValue as a message
43+
// since oneof in AnyValue does not allow repeated fields.
44+
message ArrayValue {
45+
// Array of values. The array may be empty (contain 0 elements).
46+
repeated AnyValue values = 1;
47+
}
48+
49+
// KeyValueList is a list of KeyValue messages. We need KeyValueList as a message
50+
// since `oneof` in AnyValue does not allow repeated fields. Everywhere else where we need
51+
// a list of KeyValue messages (e.g. in Span) we use `repeated KeyValue` directly to
52+
// avoid unnecessary extra wrapping (which slows down the protocol). The 2 approaches
53+
// are semantically equivalent.
54+
message KeyValueList {
55+
// A collection of key/value pairs of key-value pairs. The list may be empty (may
56+
// contain 0 elements).
57+
// The keys MUST be unique (it is not allowed to have more than one
58+
// value with the same key).
59+
repeated KeyValue values = 1;
60+
}
61+
62+
// KeyValue is a key-value pair that is used to store Span attributes, Link
63+
// attributes, etc.
64+
message KeyValue {
65+
string key = 1;
66+
AnyValue value = 2;
67+
}
68+
69+
// InstrumentationScope is a message representing the instrumentation scope information
70+
// such as the fully qualified name and version.
71+
message InstrumentationScope {
72+
// An empty instrumentation scope name means the name is unknown.
73+
string name = 1;
74+
string version = 2;
75+
76+
// Additional attributes that describe the scope. [Optional].
77+
// Attribute keys MUST be unique (it is not allowed to have more than one
78+
// attribute with the same key).
79+
repeated KeyValue attributes = 3;
80+
uint32 dropped_attributes_count = 4;
81+
}

0 commit comments

Comments
 (0)