fix(tracing): Remove opentelemetry vendoring
We used to vendor the opentelemetry protobufs because we relied on a version of tonic that `opentelemetry-sdk` didn't support. Now that we've upgraded tonic, we can remove the vendoring and use the official APIs. Signed-off-by: Scott Fleener <scott@buoyant.io>
This commit is contained in:
parent
83373d6b89
commit
930da0d34e
27
Cargo.lock
27
Cargo.lock
|
|
@ -267,9 +267,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8"
|
|||
|
||||
[[package]]
|
||||
name = "base64"
|
||||
version = "0.22.0"
|
||||
version = "0.22.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51"
|
||||
checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
|
||||
|
||||
[[package]]
|
||||
name = "bindgen"
|
||||
|
|
@ -3142,9 +3142,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "opentelemetry"
|
||||
version = "0.30.0"
|
||||
version = "0.29.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aaf416e4cb72756655126f7dd7bb0af49c674f4c1b9903e80c009e0c37e552e6"
|
||||
checksum = "9e87237e2775f74896f9ad219d26a2081751187eb7c9f5c58dde20a23b95d16c"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-sink",
|
||||
|
|
@ -3156,27 +3156,34 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "opentelemetry-proto"
|
||||
version = "0.1.0"
|
||||
version = "0.29.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8c40da242381435e18570d5b9d50aca2a4f4f4d8e146231adb4e7768023309b3"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"hex",
|
||||
"opentelemetry",
|
||||
"opentelemetry_sdk",
|
||||
"prost 0.13.5",
|
||||
"serde",
|
||||
"tonic",
|
||||
"tonic-build",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "opentelemetry_sdk"
|
||||
version = "0.30.0"
|
||||
version = "0.29.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "11f644aa9e5e31d11896e024305d7e3c98a88884d9f8919dbf37a9991bc47a4b"
|
||||
checksum = "afdefb21d1d47394abc1ba6c57363ab141be19e27cc70d0e422b7f303e4d290b"
|
||||
dependencies = [
|
||||
"futures-channel",
|
||||
"futures-executor",
|
||||
"futures-util",
|
||||
"glob",
|
||||
"opentelemetry",
|
||||
"percent-encoding",
|
||||
"rand 0.9.2",
|
||||
"serde_json",
|
||||
"thiserror 2.0.12",
|
||||
]
|
||||
|
||||
|
|
@ -3215,7 +3222,7 @@ version = "3.0.5"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "38af38e8470ac9dee3ce1bae1af9c1671fffc44ddfd8bd1d0a3445bf349a8ef3"
|
||||
dependencies = [
|
||||
"base64 0.22.0",
|
||||
"base64 0.22.1",
|
||||
"serde",
|
||||
]
|
||||
|
||||
|
|
@ -4264,7 +4271,7 @@ dependencies = [
|
|||
"async-stream",
|
||||
"async-trait",
|
||||
"axum",
|
||||
"base64 0.22.0",
|
||||
"base64 0.22.1",
|
||||
"bytes",
|
||||
"h2",
|
||||
"http",
|
||||
|
|
|
|||
|
|
@ -87,7 +87,6 @@ members = [
|
|||
"linkerd/workers",
|
||||
"linkerd2-proxy",
|
||||
"opencensus-proto",
|
||||
"opentelemetry-proto",
|
||||
"spiffe-proto",
|
||||
"tools",
|
||||
]
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ use linkerd_app_core::{
|
|||
use linkerd_opentelemetry::{
|
||||
self as opentelemetry, metrics,
|
||||
proto::{
|
||||
proto::common::v1::{any_value, AnyValue, KeyValue},
|
||||
transform::common::ResourceAttributesWithSchema,
|
||||
tonic::common::v1::{any_value, AnyValue, KeyValue},
|
||||
transform::common::tonic::ResourceAttributesWithSchema,
|
||||
},
|
||||
};
|
||||
use std::{
|
||||
|
|
|
|||
|
|
@ -12,9 +12,9 @@ http-body = { workspace = true }
|
|||
linkerd-error = { path = "../error" }
|
||||
linkerd-metrics = { path = "../metrics" }
|
||||
linkerd-trace-context = { path = "../trace-context" }
|
||||
opentelemetry = { version = "0.30", default-features = false, features = ["trace"] }
|
||||
opentelemetry_sdk = { version = "0.30", default-features = false, features = ["trace"] }
|
||||
opentelemetry-proto = { path = "../../opentelemetry-proto" }
|
||||
opentelemetry = { version = "0.29.1", default-features = false, features = ["trace"] }
|
||||
opentelemetry_sdk = { version = "0.29.0", default-features = false, features = ["trace"] }
|
||||
opentelemetry-proto = { version = "0.29.0" }
|
||||
tonic = { workspace = true, default-features = false, features = [
|
||||
"prost",
|
||||
"codegen",
|
||||
|
|
|
|||
|
|
@ -15,16 +15,19 @@ use opentelemetry::{
|
|||
};
|
||||
pub use opentelemetry_proto as proto;
|
||||
use opentelemetry_proto::{
|
||||
proto::{
|
||||
tonic::{
|
||||
collector::trace::v1::{
|
||||
trace_service_client::TraceServiceClient, ExportTraceServiceRequest,
|
||||
},
|
||||
trace::v1::ResourceSpans,
|
||||
},
|
||||
transform::{common::ResourceAttributesWithSchema, trace::group_spans_by_resource_and_scope},
|
||||
transform::{
|
||||
common::tonic::ResourceAttributesWithSchema,
|
||||
trace::tonic::group_spans_by_resource_and_scope,
|
||||
},
|
||||
};
|
||||
use opentelemetry_sdk::trace::SpanLinks;
|
||||
pub use opentelemetry_sdk::{self as sdk, trace::SpanData};
|
||||
use opentelemetry_sdk::trace::{SpanData, SpanLinks};
|
||||
pub use opentelemetry_sdk::{self as sdk};
|
||||
use tokio::{sync::mpsc, time};
|
||||
use tonic::{self as grpc, body::BoxBody, client::GrpcService};
|
||||
use tracing::{debug, info, trace};
|
||||
|
|
|
|||
|
|
@ -1,25 +0,0 @@
|
|||
[package]
|
||||
name = "opentelemetry-proto"
|
||||
version = { workspace = true }
|
||||
authors = ["The OpenTelemetry Authors"]
|
||||
license = { workspace = true }
|
||||
edition = { workspace = true }
|
||||
publish = { workspace = true }
|
||||
description = """
|
||||
gRPC bindings for OpenTelemetry.
|
||||
|
||||
Vendored from https://github.com/open-telemetry/opentelemetry-rust/.
|
||||
"""
|
||||
|
||||
[dependencies]
|
||||
tonic = { workspace = true, features = ["codegen", "prost", "transport"] }
|
||||
prost = { workspace = true }
|
||||
opentelemetry = { version = "0.30", default-features = false, features = ["trace"] }
|
||||
opentelemetry_sdk = { version = "0.30", default-features = false, features = ["trace"] }
|
||||
|
||||
[dev-dependencies]
|
||||
opentelemetry = { version = "0.30", default-features = false, features = ["trace", "testing"] }
|
||||
tonic-build = { workspace = true, default-features = false, features = ["prost"] }
|
||||
|
||||
[lib]
|
||||
doctest = false
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
# opentelemetry-proto
|
||||
|
||||
This library mirrors parts of the
|
||||
[`opentelemetry-proto`](https://github.com/census-instrumentation/opencensus-proto/)
|
||||
repo, with the non-tracing and build-related components removed.
|
||||
|
||||
## License
|
||||
|
||||
Copyright 2024, OpenTelemetry 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.
|
||||
|
|
@ -1,79 +0,0 @@
|
|||
// Copyright 2019, OpenTelemetry 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 opentelemetry.proto.collector.trace.v1;
|
||||
|
||||
import "opentelemetry/proto/trace/v1/trace.proto";
|
||||
|
||||
option csharp_namespace = "OpenTelemetry.Proto.Collector.Trace.V1";
|
||||
option java_multiple_files = true;
|
||||
option java_package = "io.opentelemetry.proto.collector.trace.v1";
|
||||
option java_outer_classname = "TraceServiceProto";
|
||||
option go_package = "go.opentelemetry.io/proto/otlp/collector/trace/v1";
|
||||
|
||||
// Service that can be used to push spans between one Application instrumented with
|
||||
// OpenTelemetry and a collector, or between a collector and a central collector (in this
|
||||
// case spans are sent/received to/from multiple Applications).
|
||||
service TraceService {
|
||||
// For performance reasons, it is recommended to keep this RPC
|
||||
// alive for the entire life of the application.
|
||||
rpc Export(ExportTraceServiceRequest) returns (ExportTraceServiceResponse) {}
|
||||
}
|
||||
|
||||
message ExportTraceServiceRequest {
|
||||
// An array of ResourceSpans.
|
||||
// For data coming from a single resource this array will typically contain one
|
||||
// element. Intermediary nodes (such as OpenTelemetry Collector) that receive
|
||||
// data from multiple origins typically batch the data before forwarding further and
|
||||
// in that case this array will contain multiple elements.
|
||||
repeated opentelemetry.proto.trace.v1.ResourceSpans resource_spans = 1;
|
||||
}
|
||||
|
||||
message ExportTraceServiceResponse {
|
||||
// The details of a partially successful export request.
|
||||
//
|
||||
// If the request is only partially accepted
|
||||
// (i.e. when the server accepts only parts of the data and rejects the rest)
|
||||
// the server MUST initialize the `partial_success` field and MUST
|
||||
// set the `rejected_<signal>` with the number of items it rejected.
|
||||
//
|
||||
// Servers MAY also make use of the `partial_success` field to convey
|
||||
// warnings/suggestions to senders even when the request was fully accepted.
|
||||
// In such cases, the `rejected_<signal>` MUST have a value of `0` and
|
||||
// the `error_message` MUST be non-empty.
|
||||
//
|
||||
// A `partial_success` message with an empty value (rejected_<signal> = 0 and
|
||||
// `error_message` = "") is equivalent to it not being set/present. Senders
|
||||
// SHOULD interpret it the same way as in the full success case.
|
||||
ExportTracePartialSuccess partial_success = 1;
|
||||
}
|
||||
|
||||
message ExportTracePartialSuccess {
|
||||
// The number of rejected spans.
|
||||
//
|
||||
// A `rejected_<signal>` field holding a `0` value indicates that the
|
||||
// request was fully accepted.
|
||||
int64 rejected_spans = 1;
|
||||
|
||||
// A developer-facing human-readable message in English. It should be used
|
||||
// either to explain why the server rejected parts of the data during a partial
|
||||
// success or to convey warnings/suggestions during a full success. The message
|
||||
// should offer guidance on how users can address such issues.
|
||||
//
|
||||
// error_message is an optional field. An error_message with an empty value
|
||||
// is equivalent to it not being set.
|
||||
string error_message = 2;
|
||||
}
|
||||
|
|
@ -1,81 +0,0 @@
|
|||
// Copyright 2019, OpenTelemetry 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 opentelemetry.proto.common.v1;
|
||||
|
||||
option csharp_namespace = "OpenTelemetry.Proto.Common.V1";
|
||||
option java_multiple_files = true;
|
||||
option java_package = "io.opentelemetry.proto.common.v1";
|
||||
option java_outer_classname = "CommonProto";
|
||||
option go_package = "go.opentelemetry.io/proto/otlp/common/v1";
|
||||
|
||||
// AnyValue is used to represent any type of attribute value. AnyValue may contain a
|
||||
// primitive value such as a string or integer or it may contain an arbitrary nested
|
||||
// object containing arrays, key-value lists and primitives.
|
||||
message AnyValue {
|
||||
// The value is one of the listed fields. It is valid for all values to be unspecified
|
||||
// in which case this AnyValue is considered to be "empty".
|
||||
oneof value {
|
||||
string string_value = 1;
|
||||
bool bool_value = 2;
|
||||
int64 int_value = 3;
|
||||
double double_value = 4;
|
||||
ArrayValue array_value = 5;
|
||||
KeyValueList kvlist_value = 6;
|
||||
bytes bytes_value = 7;
|
||||
}
|
||||
}
|
||||
|
||||
// ArrayValue is a list of AnyValue messages. We need ArrayValue as a message
|
||||
// since oneof in AnyValue does not allow repeated fields.
|
||||
message ArrayValue {
|
||||
// Array of values. The array may be empty (contain 0 elements).
|
||||
repeated AnyValue values = 1;
|
||||
}
|
||||
|
||||
// KeyValueList is a list of KeyValue messages. We need KeyValueList as a message
|
||||
// since `oneof` in AnyValue does not allow repeated fields. Everywhere else where we need
|
||||
// a list of KeyValue messages (e.g. in Span) we use `repeated KeyValue` directly to
|
||||
// avoid unnecessary extra wrapping (which slows down the protocol). The 2 approaches
|
||||
// are semantically equivalent.
|
||||
message KeyValueList {
|
||||
// A collection of key/value pairs of key-value pairs. The list may be empty (may
|
||||
// contain 0 elements).
|
||||
// The keys MUST be unique (it is not allowed to have more than one
|
||||
// value with the same key).
|
||||
repeated KeyValue values = 1;
|
||||
}
|
||||
|
||||
// KeyValue is a key-value pair that is used to store Span attributes, Link
|
||||
// attributes, etc.
|
||||
message KeyValue {
|
||||
string key = 1;
|
||||
AnyValue value = 2;
|
||||
}
|
||||
|
||||
// InstrumentationScope is a message representing the instrumentation scope information
|
||||
// such as the fully qualified name and version.
|
||||
message InstrumentationScope {
|
||||
// An empty instrumentation scope name means the name is unknown.
|
||||
string name = 1;
|
||||
string version = 2;
|
||||
|
||||
// Additional attributes that describe the scope. [Optional].
|
||||
// Attribute keys MUST be unique (it is not allowed to have more than one
|
||||
// attribute with the same key).
|
||||
repeated KeyValue attributes = 3;
|
||||
uint32 dropped_attributes_count = 4;
|
||||
}
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
// Copyright 2019, OpenTelemetry 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 opentelemetry.proto.resource.v1;
|
||||
|
||||
import "opentelemetry/proto/common/v1/common.proto";
|
||||
|
||||
option csharp_namespace = "OpenTelemetry.Proto.Resource.V1";
|
||||
option java_multiple_files = true;
|
||||
option java_package = "io.opentelemetry.proto.resource.v1";
|
||||
option java_outer_classname = "ResourceProto";
|
||||
option go_package = "go.opentelemetry.io/proto/otlp/resource/v1";
|
||||
|
||||
// Resource information.
|
||||
message Resource {
|
||||
// Set of attributes that describe the resource.
|
||||
// Attribute keys MUST be unique (it is not allowed to have more than one
|
||||
// attribute with the same key).
|
||||
repeated opentelemetry.proto.common.v1.KeyValue attributes = 1;
|
||||
|
||||
// dropped_attributes_count is the number of dropped attributes. If the value is 0, then
|
||||
// no attributes were dropped.
|
||||
uint32 dropped_attributes_count = 2;
|
||||
}
|
||||
|
|
@ -1,355 +0,0 @@
|
|||
// Copyright 2019, OpenTelemetry 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 opentelemetry.proto.trace.v1;
|
||||
|
||||
import "opentelemetry/proto/common/v1/common.proto";
|
||||
import "opentelemetry/proto/resource/v1/resource.proto";
|
||||
|
||||
option csharp_namespace = "OpenTelemetry.Proto.Trace.V1";
|
||||
option java_multiple_files = true;
|
||||
option java_package = "io.opentelemetry.proto.trace.v1";
|
||||
option java_outer_classname = "TraceProto";
|
||||
option go_package = "go.opentelemetry.io/proto/otlp/trace/v1";
|
||||
|
||||
// TracesData represents the traces data that can be stored in a persistent storage,
|
||||
// OR can be embedded by other protocols that transfer OTLP traces data but do
|
||||
// not implement the OTLP protocol.
|
||||
//
|
||||
// The main difference between this message and collector protocol is that
|
||||
// in this message there will not be any "control" or "metadata" specific to
|
||||
// OTLP protocol.
|
||||
//
|
||||
// When new fields are added into this message, the OTLP request MUST be updated
|
||||
// as well.
|
||||
message TracesData {
|
||||
// An array of ResourceSpans.
|
||||
// For data coming from a single resource this array will typically contain
|
||||
// one element. Intermediary nodes that receive data from multiple origins
|
||||
// typically batch the data before forwarding further and in that case this
|
||||
// array will contain multiple elements.
|
||||
repeated ResourceSpans resource_spans = 1;
|
||||
}
|
||||
|
||||
// A collection of ScopeSpans from a Resource.
|
||||
message ResourceSpans {
|
||||
reserved 1000;
|
||||
|
||||
// The resource for the spans in this message.
|
||||
// If this field is not set then no resource info is known.
|
||||
opentelemetry.proto.resource.v1.Resource resource = 1;
|
||||
|
||||
// A list of ScopeSpans that originate from a resource.
|
||||
repeated ScopeSpans scope_spans = 2;
|
||||
|
||||
// The Schema URL, if known. This is the identifier of the Schema that the resource data
|
||||
// is recorded in. To learn more about Schema URL see
|
||||
// https://opentelemetry.io/docs/specs/otel/schemas/#schema-url
|
||||
// This schema_url applies to the data in the "resource" field. It does not apply
|
||||
// to the data in the "scope_spans" field which have their own schema_url field.
|
||||
string schema_url = 3;
|
||||
}
|
||||
|
||||
// A collection of Spans produced by an InstrumentationScope.
|
||||
message ScopeSpans {
|
||||
// The instrumentation scope information for the spans in this message.
|
||||
// Semantically when InstrumentationScope isn't set, it is equivalent with
|
||||
// an empty instrumentation scope name (unknown).
|
||||
opentelemetry.proto.common.v1.InstrumentationScope scope = 1;
|
||||
|
||||
// A list of Spans that originate from an instrumentation scope.
|
||||
repeated Span spans = 2;
|
||||
|
||||
// The Schema URL, if known. This is the identifier of the Schema that the span data
|
||||
// is recorded in. To learn more about Schema URL see
|
||||
// https://opentelemetry.io/docs/specs/otel/schemas/#schema-url
|
||||
// This schema_url applies to all spans and span events in the "spans" field.
|
||||
string schema_url = 3;
|
||||
}
|
||||
|
||||
// A Span represents a single operation performed by a single component of the system.
|
||||
//
|
||||
// The next available field id is 17.
|
||||
message Span {
|
||||
// A unique identifier for a trace. All spans from the same trace share
|
||||
// the same `trace_id`. The ID is a 16-byte array. An ID with all zeroes OR
|
||||
// of length other than 16 bytes is considered invalid (empty string in OTLP/JSON
|
||||
// is zero-length and thus is also invalid).
|
||||
//
|
||||
// This field is required.
|
||||
bytes trace_id = 1;
|
||||
|
||||
// A unique identifier for a span within a trace, assigned when the span
|
||||
// is created. The ID is an 8-byte array. An ID with all zeroes OR of length
|
||||
// other than 8 bytes is considered invalid (empty string in OTLP/JSON
|
||||
// is zero-length and thus is also invalid).
|
||||
//
|
||||
// This field is required.
|
||||
bytes span_id = 2;
|
||||
|
||||
// trace_state conveys information about request position in multiple distributed tracing graphs.
|
||||
// It is a trace_state in w3c-trace-context format: https://www.w3.org/TR/trace-context/#tracestate-header
|
||||
// See also https://github.com/w3c/distributed-tracing for more details about this field.
|
||||
string trace_state = 3;
|
||||
|
||||
// The `span_id` of this span's parent span. If this is a root span, then this
|
||||
// field must be empty. The ID is an 8-byte array.
|
||||
bytes parent_span_id = 4;
|
||||
|
||||
// Flags, a bit field.
|
||||
//
|
||||
// Bits 0-7 (8 least significant bits) are the trace flags as defined in W3C Trace
|
||||
// Context specification. To read the 8-bit W3C trace flag, use
|
||||
// `flags & SPAN_FLAGS_TRACE_FLAGS_MASK`.
|
||||
//
|
||||
// See https://www.w3.org/TR/trace-context-2/#trace-flags for the flag definitions.
|
||||
//
|
||||
// Bits 8 and 9 represent the 3 states of whether a span's parent
|
||||
// is remote. The states are (unknown, is not remote, is remote).
|
||||
// To read whether the value is known, use `(flags & SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE_MASK) != 0`.
|
||||
// To read whether the span is remote, use `(flags & SPAN_FLAGS_CONTEXT_IS_REMOTE_MASK) != 0`.
|
||||
//
|
||||
// When creating span messages, if the message is logically forwarded from another source
|
||||
// with an equivalent flags fields (i.e., usually another OTLP span message), the field SHOULD
|
||||
// be copied as-is. If creating from a source that does not have an equivalent flags field
|
||||
// (such as a runtime representation of an OpenTelemetry span), the high 22 bits MUST
|
||||
// be set to zero.
|
||||
// Readers MUST NOT assume that bits 10-31 (22 most significant bits) will be zero.
|
||||
//
|
||||
// [Optional].
|
||||
fixed32 flags = 16;
|
||||
|
||||
// A description of the span's operation.
|
||||
//
|
||||
// For example, the name can be a qualified method name or a file name
|
||||
// and a line number where the operation is called. A best practice is to use
|
||||
// the same display name at the same call point in an application.
|
||||
// This makes it easier to correlate spans in different traces.
|
||||
//
|
||||
// This field is semantically required to be set to non-empty string.
|
||||
// Empty value is equivalent to an unknown span name.
|
||||
//
|
||||
// This field is required.
|
||||
string name = 5;
|
||||
|
||||
// SpanKind is the type of span. Can be used to specify additional relationships between spans
|
||||
// in addition to a parent/child relationship.
|
||||
enum SpanKind {
|
||||
// Unspecified. Do NOT use as default.
|
||||
// Implementations MAY assume SpanKind to be INTERNAL when receiving UNSPECIFIED.
|
||||
SPAN_KIND_UNSPECIFIED = 0;
|
||||
|
||||
// Indicates that the span represents an internal operation within an application,
|
||||
// as opposed to an operation happening at the boundaries. Default value.
|
||||
SPAN_KIND_INTERNAL = 1;
|
||||
|
||||
// Indicates that the span covers server-side handling of an RPC or other
|
||||
// remote network request.
|
||||
SPAN_KIND_SERVER = 2;
|
||||
|
||||
// Indicates that the span describes a request to some remote service.
|
||||
SPAN_KIND_CLIENT = 3;
|
||||
|
||||
// Indicates that the span describes a producer sending a message to a broker.
|
||||
// Unlike CLIENT and SERVER, there is often no direct critical path latency relationship
|
||||
// between producer and consumer spans. A PRODUCER span ends when the message was accepted
|
||||
// by the broker while the logical processing of the message might span a much longer time.
|
||||
SPAN_KIND_PRODUCER = 4;
|
||||
|
||||
// Indicates that the span describes consumer receiving a message from a broker.
|
||||
// Like the PRODUCER kind, there is often no direct critical path latency relationship
|
||||
// between producer and consumer spans.
|
||||
SPAN_KIND_CONSUMER = 5;
|
||||
}
|
||||
|
||||
// Distinguishes between spans generated in a particular context. For example,
|
||||
// two spans with the same name may be distinguished using `CLIENT` (caller)
|
||||
// and `SERVER` (callee) to identify queueing latency associated with the span.
|
||||
SpanKind kind = 6;
|
||||
|
||||
// start_time_unix_nano is the start time of the span. On the client side, this is the time
|
||||
// kept by the local machine where the span execution starts. On the server side, this
|
||||
// is the time when the server's application handler starts running.
|
||||
// Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970.
|
||||
//
|
||||
// This field is semantically required and it is expected that end_time >= start_time.
|
||||
fixed64 start_time_unix_nano = 7;
|
||||
|
||||
// end_time_unix_nano is the end time of the span. On the client side, this is the time
|
||||
// kept by the local machine where the span execution ends. On the server side, this
|
||||
// is the time when the server application handler stops running.
|
||||
// Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970.
|
||||
//
|
||||
// This field is semantically required and it is expected that end_time >= start_time.
|
||||
fixed64 end_time_unix_nano = 8;
|
||||
|
||||
// attributes is a collection of key/value pairs. Note, global attributes
|
||||
// like server name can be set using the resource API. Examples of attributes:
|
||||
//
|
||||
// "/http/user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36"
|
||||
// "/http/server_latency": 300
|
||||
// "example.com/myattribute": true
|
||||
// "example.com/score": 10.239
|
||||
//
|
||||
// The OpenTelemetry API specification further restricts the allowed value types:
|
||||
// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/common/README.md#attribute
|
||||
// Attribute keys MUST be unique (it is not allowed to have more than one
|
||||
// attribute with the same key).
|
||||
repeated opentelemetry.proto.common.v1.KeyValue attributes = 9;
|
||||
|
||||
// dropped_attributes_count is the number of attributes that were discarded. Attributes
|
||||
// can be discarded because their keys are too long or because there are too many
|
||||
// attributes. If this value is 0, then no attributes were dropped.
|
||||
uint32 dropped_attributes_count = 10;
|
||||
|
||||
// Event is a time-stamped annotation of the span, consisting of user-supplied
|
||||
// text description and key-value pairs.
|
||||
message Event {
|
||||
// time_unix_nano is the time the event occurred.
|
||||
fixed64 time_unix_nano = 1;
|
||||
|
||||
// name of the event.
|
||||
// This field is semantically required to be set to non-empty string.
|
||||
string name = 2;
|
||||
|
||||
// attributes is a collection of attribute key/value pairs on the event.
|
||||
// Attribute keys MUST be unique (it is not allowed to have more than one
|
||||
// attribute with the same key).
|
||||
repeated opentelemetry.proto.common.v1.KeyValue attributes = 3;
|
||||
|
||||
// dropped_attributes_count is the number of dropped attributes. If the value is 0,
|
||||
// then no attributes were dropped.
|
||||
uint32 dropped_attributes_count = 4;
|
||||
}
|
||||
|
||||
// events is a collection of Event items.
|
||||
repeated Event events = 11;
|
||||
|
||||
// dropped_events_count is the number of dropped events. If the value is 0, then no
|
||||
// events were dropped.
|
||||
uint32 dropped_events_count = 12;
|
||||
|
||||
// A pointer from the current span to another span in the same trace or in a
|
||||
// different trace. For example, this can be used in batching operations,
|
||||
// where a single batch handler processes multiple requests from different
|
||||
// traces or when the handler receives a request from a different project.
|
||||
message Link {
|
||||
// A unique identifier of a trace that this linked span is part of. The ID is a
|
||||
// 16-byte array.
|
||||
bytes trace_id = 1;
|
||||
|
||||
// A unique identifier for the linked span. The ID is an 8-byte array.
|
||||
bytes span_id = 2;
|
||||
|
||||
// The trace_state associated with the link.
|
||||
string trace_state = 3;
|
||||
|
||||
// attributes is a collection of attribute key/value pairs on the link.
|
||||
// Attribute keys MUST be unique (it is not allowed to have more than one
|
||||
// attribute with the same key).
|
||||
repeated opentelemetry.proto.common.v1.KeyValue attributes = 4;
|
||||
|
||||
// dropped_attributes_count is the number of dropped attributes. If the value is 0,
|
||||
// then no attributes were dropped.
|
||||
uint32 dropped_attributes_count = 5;
|
||||
|
||||
// Flags, a bit field.
|
||||
//
|
||||
// Bits 0-7 (8 least significant bits) are the trace flags as defined in W3C Trace
|
||||
// Context specification. To read the 8-bit W3C trace flag, use
|
||||
// `flags & SPAN_FLAGS_TRACE_FLAGS_MASK`.
|
||||
//
|
||||
// See https://www.w3.org/TR/trace-context-2/#trace-flags for the flag definitions.
|
||||
//
|
||||
// Bits 8 and 9 represent the 3 states of whether the link is remote.
|
||||
// The states are (unknown, is not remote, is remote).
|
||||
// To read whether the value is known, use `(flags & SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE_MASK) != 0`.
|
||||
// To read whether the link is remote, use `(flags & SPAN_FLAGS_CONTEXT_IS_REMOTE_MASK) != 0`.
|
||||
//
|
||||
// Readers MUST NOT assume that bits 10-31 (22 most significant bits) will be zero.
|
||||
// When creating new spans, bits 10-31 (most-significant 22-bits) MUST be zero.
|
||||
//
|
||||
// [Optional].
|
||||
fixed32 flags = 6;
|
||||
}
|
||||
|
||||
// links is a collection of Links, which are references from this span to a span
|
||||
// in the same or different trace.
|
||||
repeated Link links = 13;
|
||||
|
||||
// dropped_links_count is the number of dropped links after the maximum size was
|
||||
// enforced. If this value is 0, then no links were dropped.
|
||||
uint32 dropped_links_count = 14;
|
||||
|
||||
// An optional final status for this span. Semantically when Status isn't set, it means
|
||||
// span's status code is unset, i.e. assume STATUS_CODE_UNSET (code = 0).
|
||||
Status status = 15;
|
||||
}
|
||||
|
||||
// The Status type defines a logical error model that is suitable for different
|
||||
// programming environments, including REST APIs and RPC APIs.
|
||||
message Status {
|
||||
reserved 1;
|
||||
|
||||
// A developer-facing human readable error message.
|
||||
string message = 2;
|
||||
|
||||
// For the semantics of status codes see
|
||||
// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/api.md#set-status
|
||||
enum StatusCode {
|
||||
// The default status.
|
||||
STATUS_CODE_UNSET = 0;
|
||||
// The Span has been validated by an Application developer or Operator to
|
||||
// have completed successfully.
|
||||
STATUS_CODE_OK = 1;
|
||||
// The Span contains an error.
|
||||
STATUS_CODE_ERROR = 2;
|
||||
};
|
||||
|
||||
// The status code.
|
||||
StatusCode code = 3;
|
||||
}
|
||||
|
||||
// SpanFlags represents constants used to interpret the
|
||||
// Span.flags field, which is protobuf 'fixed32' type and is to
|
||||
// be used as bit-fields. Each non-zero value defined in this enum is
|
||||
// a bit-mask. To extract the bit-field, for example, use an
|
||||
// expression like:
|
||||
//
|
||||
// (span.flags & SPAN_FLAGS_TRACE_FLAGS_MASK)
|
||||
//
|
||||
// See https://www.w3.org/TR/trace-context-2/#trace-flags for the flag definitions.
|
||||
//
|
||||
// Note that Span flags were introduced in version 1.1 of the
|
||||
// OpenTelemetry protocol. Older Span producers do not set this
|
||||
// field, consequently consumers should not rely on the absence of a
|
||||
// particular flag bit to indicate the presence of a particular feature.
|
||||
enum SpanFlags {
|
||||
// The zero value for the enum. Should not be used for comparisons.
|
||||
// Instead use bitwise "and" with the appropriate mask as shown above.
|
||||
SPAN_FLAGS_DO_NOT_USE = 0;
|
||||
|
||||
// Bits 0-7 are used for trace flags.
|
||||
SPAN_FLAGS_TRACE_FLAGS_MASK = 0x000000FF;
|
||||
|
||||
// Bits 8 and 9 are used to indicate that the parent span or link span is remote.
|
||||
// Bit 8 (`HAS_IS_REMOTE`) indicates whether the value is known.
|
||||
// Bit 9 (`IS_REMOTE`) indicates whether the span or link is remote.
|
||||
SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE_MASK = 0x00000100;
|
||||
SPAN_FLAGS_CONTEXT_IS_REMOTE_MASK = 0x00000200;
|
||||
|
||||
// Bits 10-31 are reserved for future use.
|
||||
}
|
||||
|
|
@ -1,167 +0,0 @@
|
|||
// This file is @generated by prost-build.
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct ExportTraceServiceRequest {
|
||||
/// An array of ResourceSpans.
|
||||
/// For data coming from a single resource this array will typically contain one
|
||||
/// element. Intermediary nodes (such as OpenTelemetry Collector) that receive
|
||||
/// data from multiple origins typically batch the data before forwarding further and
|
||||
/// in that case this array will contain multiple elements.
|
||||
#[prost(message, repeated, tag = "1")]
|
||||
pub resource_spans: ::prost::alloc::vec::Vec<
|
||||
super::super::super::trace::v1::ResourceSpans,
|
||||
>,
|
||||
}
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct ExportTraceServiceResponse {
|
||||
/// The details of a partially successful export request.
|
||||
///
|
||||
/// If the request is only partially accepted
|
||||
/// (i.e. when the server accepts only parts of the data and rejects the rest)
|
||||
/// the server MUST initialize the `partial_success` field and MUST
|
||||
/// set the `rejected_<signal>` with the number of items it rejected.
|
||||
///
|
||||
/// Servers MAY also make use of the `partial_success` field to convey
|
||||
/// warnings/suggestions to senders even when the request was fully accepted.
|
||||
/// In such cases, the `rejected_<signal>` MUST have a value of `0` and
|
||||
/// the `error_message` MUST be non-empty.
|
||||
///
|
||||
/// A `partial_success` message with an empty value (rejected_<signal> = 0 and
|
||||
/// `error_message` = "") is equivalent to it not being set/present. Senders
|
||||
/// SHOULD interpret it the same way as in the full success case.
|
||||
#[prost(message, optional, tag = "1")]
|
||||
pub partial_success: ::core::option::Option<ExportTracePartialSuccess>,
|
||||
}
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct ExportTracePartialSuccess {
|
||||
/// The number of rejected spans.
|
||||
///
|
||||
/// A `rejected_<signal>` field holding a `0` value indicates that the
|
||||
/// request was fully accepted.
|
||||
#[prost(int64, tag = "1")]
|
||||
pub rejected_spans: i64,
|
||||
/// A developer-facing human-readable message in English. It should be used
|
||||
/// either to explain why the server rejected parts of the data during a partial
|
||||
/// success or to convey warnings/suggestions during a full success. The message
|
||||
/// should offer guidance on how users can address such issues.
|
||||
///
|
||||
/// error_message is an optional field. An error_message with an empty value
|
||||
/// is equivalent to it not being set.
|
||||
#[prost(string, tag = "2")]
|
||||
pub error_message: ::prost::alloc::string::String,
|
||||
}
|
||||
/// Generated client implementations.
|
||||
pub mod trace_service_client {
|
||||
#![allow(
|
||||
unused_variables,
|
||||
dead_code,
|
||||
missing_docs,
|
||||
clippy::wildcard_imports,
|
||||
clippy::let_unit_value,
|
||||
)]
|
||||
use tonic::codegen::*;
|
||||
use tonic::codegen::http::Uri;
|
||||
/// Service that can be used to push spans between one Application instrumented with
|
||||
/// OpenTelemetry and a collector, or between a collector and a central collector (in this
|
||||
/// case spans are sent/received to/from multiple Applications).
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct TraceServiceClient<T> {
|
||||
inner: tonic::client::Grpc<T>,
|
||||
}
|
||||
impl<T> TraceServiceClient<T>
|
||||
where
|
||||
T: tonic::client::GrpcService<tonic::body::BoxBody>,
|
||||
T::Error: Into<StdError>,
|
||||
T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
|
||||
<T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
|
||||
{
|
||||
pub fn new(inner: T) -> Self {
|
||||
let inner = tonic::client::Grpc::new(inner);
|
||||
Self { inner }
|
||||
}
|
||||
pub fn with_origin(inner: T, origin: Uri) -> Self {
|
||||
let inner = tonic::client::Grpc::with_origin(inner, origin);
|
||||
Self { inner }
|
||||
}
|
||||
pub fn with_interceptor<F>(
|
||||
inner: T,
|
||||
interceptor: F,
|
||||
) -> TraceServiceClient<InterceptedService<T, F>>
|
||||
where
|
||||
F: tonic::service::Interceptor,
|
||||
T::ResponseBody: Default,
|
||||
T: tonic::codegen::Service<
|
||||
http::Request<tonic::body::BoxBody>,
|
||||
Response = http::Response<
|
||||
<T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
|
||||
>,
|
||||
>,
|
||||
<T as tonic::codegen::Service<
|
||||
http::Request<tonic::body::BoxBody>,
|
||||
>>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
|
||||
{
|
||||
TraceServiceClient::new(InterceptedService::new(inner, interceptor))
|
||||
}
|
||||
/// Compress requests with the given encoding.
|
||||
///
|
||||
/// This requires the server to support it otherwise it might respond with an
|
||||
/// error.
|
||||
#[must_use]
|
||||
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
|
||||
self.inner = self.inner.send_compressed(encoding);
|
||||
self
|
||||
}
|
||||
/// Enable decompressing responses.
|
||||
#[must_use]
|
||||
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
|
||||
self.inner = self.inner.accept_compressed(encoding);
|
||||
self
|
||||
}
|
||||
/// Limits the maximum size of a decoded message.
|
||||
///
|
||||
/// Default: `4MB`
|
||||
#[must_use]
|
||||
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
|
||||
self.inner = self.inner.max_decoding_message_size(limit);
|
||||
self
|
||||
}
|
||||
/// Limits the maximum size of an encoded message.
|
||||
///
|
||||
/// Default: `usize::MAX`
|
||||
#[must_use]
|
||||
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
|
||||
self.inner = self.inner.max_encoding_message_size(limit);
|
||||
self
|
||||
}
|
||||
/// For performance reasons, it is recommended to keep this RPC
|
||||
/// alive for the entire life of the application.
|
||||
pub async fn export(
|
||||
&mut self,
|
||||
request: impl tonic::IntoRequest<super::ExportTraceServiceRequest>,
|
||||
) -> std::result::Result<
|
||||
tonic::Response<super::ExportTraceServiceResponse>,
|
||||
tonic::Status,
|
||||
> {
|
||||
self.inner
|
||||
.ready()
|
||||
.await
|
||||
.map_err(|e| {
|
||||
tonic::Status::unknown(
|
||||
format!("Service was not ready: {}", e.into()),
|
||||
)
|
||||
})?;
|
||||
let codec = tonic::codec::ProstCodec::default();
|
||||
let path = http::uri::PathAndQuery::from_static(
|
||||
"/opentelemetry.proto.collector.trace.v1.TraceService/Export",
|
||||
);
|
||||
let mut req = request.into_request();
|
||||
req.extensions_mut()
|
||||
.insert(
|
||||
GrpcMethod::new(
|
||||
"opentelemetry.proto.collector.trace.v1.TraceService",
|
||||
"Export",
|
||||
),
|
||||
);
|
||||
self.inner.unary(req, path, codec).await
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,81 +0,0 @@
|
|||
// This file is @generated by prost-build.
|
||||
/// AnyValue is used to represent any type of attribute value. AnyValue may contain a
|
||||
/// primitive value such as a string or integer or it may contain an arbitrary nested
|
||||
/// object containing arrays, key-value lists and primitives.
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct AnyValue {
|
||||
/// The value is one of the listed fields. It is valid for all values to be unspecified
|
||||
/// in which case this AnyValue is considered to be "empty".
|
||||
#[prost(oneof = "any_value::Value", tags = "1, 2, 3, 4, 5, 6, 7")]
|
||||
pub value: ::core::option::Option<any_value::Value>,
|
||||
}
|
||||
/// Nested message and enum types in `AnyValue`.
|
||||
pub mod any_value {
|
||||
/// The value is one of the listed fields. It is valid for all values to be unspecified
|
||||
/// in which case this AnyValue is considered to be "empty".
|
||||
#[derive(Clone, PartialEq, ::prost::Oneof)]
|
||||
pub enum Value {
|
||||
#[prost(string, tag = "1")]
|
||||
StringValue(::prost::alloc::string::String),
|
||||
#[prost(bool, tag = "2")]
|
||||
BoolValue(bool),
|
||||
#[prost(int64, tag = "3")]
|
||||
IntValue(i64),
|
||||
#[prost(double, tag = "4")]
|
||||
DoubleValue(f64),
|
||||
#[prost(message, tag = "5")]
|
||||
ArrayValue(super::ArrayValue),
|
||||
#[prost(message, tag = "6")]
|
||||
KvlistValue(super::KeyValueList),
|
||||
#[prost(bytes, tag = "7")]
|
||||
BytesValue(::prost::alloc::vec::Vec<u8>),
|
||||
}
|
||||
}
|
||||
/// ArrayValue is a list of AnyValue messages. We need ArrayValue as a message
|
||||
/// since oneof in AnyValue does not allow repeated fields.
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct ArrayValue {
|
||||
/// Array of values. The array may be empty (contain 0 elements).
|
||||
#[prost(message, repeated, tag = "1")]
|
||||
pub values: ::prost::alloc::vec::Vec<AnyValue>,
|
||||
}
|
||||
/// KeyValueList is a list of KeyValue messages. We need KeyValueList as a message
|
||||
/// since `oneof` in AnyValue does not allow repeated fields. Everywhere else where we need
|
||||
/// a list of KeyValue messages (e.g. in Span) we use `repeated KeyValue` directly to
|
||||
/// avoid unnecessary extra wrapping (which slows down the protocol). The 2 approaches
|
||||
/// are semantically equivalent.
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct KeyValueList {
|
||||
/// A collection of key/value pairs of key-value pairs. The list may be empty (may
|
||||
/// contain 0 elements).
|
||||
/// The keys MUST be unique (it is not allowed to have more than one
|
||||
/// value with the same key).
|
||||
#[prost(message, repeated, tag = "1")]
|
||||
pub values: ::prost::alloc::vec::Vec<KeyValue>,
|
||||
}
|
||||
/// KeyValue is a key-value pair that is used to store Span attributes, Link
|
||||
/// attributes, etc.
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct KeyValue {
|
||||
#[prost(string, tag = "1")]
|
||||
pub key: ::prost::alloc::string::String,
|
||||
#[prost(message, optional, tag = "2")]
|
||||
pub value: ::core::option::Option<AnyValue>,
|
||||
}
|
||||
/// InstrumentationScope is a message representing the instrumentation scope information
|
||||
/// such as the fully qualified name and version.
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct InstrumentationScope {
|
||||
/// An empty instrumentation scope name means the name is unknown.
|
||||
#[prost(string, tag = "1")]
|
||||
pub name: ::prost::alloc::string::String,
|
||||
#[prost(string, tag = "2")]
|
||||
pub version: ::prost::alloc::string::String,
|
||||
/// Additional attributes that describe the scope. \[Optional\].
|
||||
/// Attribute keys MUST be unique (it is not allowed to have more than one
|
||||
/// attribute with the same key).
|
||||
#[prost(message, repeated, tag = "3")]
|
||||
pub attributes: ::prost::alloc::vec::Vec<KeyValue>,
|
||||
#[prost(uint32, tag = "4")]
|
||||
pub dropped_attributes_count: u32,
|
||||
}
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
// This file is @generated by prost-build.
|
||||
/// Resource information.
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct Resource {
|
||||
/// Set of attributes that describe the resource.
|
||||
/// Attribute keys MUST be unique (it is not allowed to have more than one
|
||||
/// attribute with the same key).
|
||||
#[prost(message, repeated, tag = "1")]
|
||||
pub attributes: ::prost::alloc::vec::Vec<super::super::common::v1::KeyValue>,
|
||||
/// dropped_attributes_count is the number of dropped attributes. If the value is 0, then
|
||||
/// no attributes were dropped.
|
||||
#[prost(uint32, tag = "2")]
|
||||
pub dropped_attributes_count: u32,
|
||||
}
|
||||
|
|
@ -1,431 +0,0 @@
|
|||
// This file is @generated by prost-build.
|
||||
/// TracesData represents the traces data that can be stored in a persistent storage,
|
||||
/// OR can be embedded by other protocols that transfer OTLP traces data but do
|
||||
/// not implement the OTLP protocol.
|
||||
///
|
||||
/// The main difference between this message and collector protocol is that
|
||||
/// in this message there will not be any "control" or "metadata" specific to
|
||||
/// OTLP protocol.
|
||||
///
|
||||
/// When new fields are added into this message, the OTLP request MUST be updated
|
||||
/// as well.
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct TracesData {
|
||||
/// An array of ResourceSpans.
|
||||
/// For data coming from a single resource this array will typically contain
|
||||
/// one element. Intermediary nodes that receive data from multiple origins
|
||||
/// typically batch the data before forwarding further and in that case this
|
||||
/// array will contain multiple elements.
|
||||
#[prost(message, repeated, tag = "1")]
|
||||
pub resource_spans: ::prost::alloc::vec::Vec<ResourceSpans>,
|
||||
}
|
||||
/// A collection of ScopeSpans from a Resource.
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct ResourceSpans {
|
||||
/// The resource for the spans in this message.
|
||||
/// If this field is not set then no resource info is known.
|
||||
#[prost(message, optional, tag = "1")]
|
||||
pub resource: ::core::option::Option<super::super::resource::v1::Resource>,
|
||||
/// A list of ScopeSpans that originate from a resource.
|
||||
#[prost(message, repeated, tag = "2")]
|
||||
pub scope_spans: ::prost::alloc::vec::Vec<ScopeSpans>,
|
||||
/// The Schema URL, if known. This is the identifier of the Schema that the resource data
|
||||
/// is recorded in. To learn more about Schema URL see
|
||||
/// <https://opentelemetry.io/docs/specs/otel/schemas/#schema-url>
|
||||
/// This schema_url applies to the data in the "resource" field. It does not apply
|
||||
/// to the data in the "scope_spans" field which have their own schema_url field.
|
||||
#[prost(string, tag = "3")]
|
||||
pub schema_url: ::prost::alloc::string::String,
|
||||
}
|
||||
/// A collection of Spans produced by an InstrumentationScope.
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct ScopeSpans {
|
||||
/// The instrumentation scope information for the spans in this message.
|
||||
/// Semantically when InstrumentationScope isn't set, it is equivalent with
|
||||
/// an empty instrumentation scope name (unknown).
|
||||
#[prost(message, optional, tag = "1")]
|
||||
pub scope: ::core::option::Option<super::super::common::v1::InstrumentationScope>,
|
||||
/// A list of Spans that originate from an instrumentation scope.
|
||||
#[prost(message, repeated, tag = "2")]
|
||||
pub spans: ::prost::alloc::vec::Vec<Span>,
|
||||
/// The Schema URL, if known. This is the identifier of the Schema that the span data
|
||||
/// is recorded in. To learn more about Schema URL see
|
||||
/// <https://opentelemetry.io/docs/specs/otel/schemas/#schema-url>
|
||||
/// This schema_url applies to all spans and span events in the "spans" field.
|
||||
#[prost(string, tag = "3")]
|
||||
pub schema_url: ::prost::alloc::string::String,
|
||||
}
|
||||
/// A Span represents a single operation performed by a single component of the system.
|
||||
///
|
||||
/// The next available field id is 17.
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct Span {
|
||||
/// A unique identifier for a trace. All spans from the same trace share
|
||||
/// the same `trace_id`. The ID is a 16-byte array. An ID with all zeroes OR
|
||||
/// of length other than 16 bytes is considered invalid (empty string in OTLP/JSON
|
||||
/// is zero-length and thus is also invalid).
|
||||
///
|
||||
/// This field is required.
|
||||
#[prost(bytes = "vec", tag = "1")]
|
||||
pub trace_id: ::prost::alloc::vec::Vec<u8>,
|
||||
/// A unique identifier for a span within a trace, assigned when the span
|
||||
/// is created. The ID is an 8-byte array. An ID with all zeroes OR of length
|
||||
/// other than 8 bytes is considered invalid (empty string in OTLP/JSON
|
||||
/// is zero-length and thus is also invalid).
|
||||
///
|
||||
/// This field is required.
|
||||
#[prost(bytes = "vec", tag = "2")]
|
||||
pub span_id: ::prost::alloc::vec::Vec<u8>,
|
||||
/// trace_state conveys information about request position in multiple distributed tracing graphs.
|
||||
/// It is a trace_state in w3c-trace-context format: <https://www.w3.org/TR/trace-context/#tracestate-header>
|
||||
/// See also <https://github.com/w3c/distributed-tracing> for more details about this field.
|
||||
#[prost(string, tag = "3")]
|
||||
pub trace_state: ::prost::alloc::string::String,
|
||||
/// The `span_id` of this span's parent span. If this is a root span, then this
|
||||
/// field must be empty. The ID is an 8-byte array.
|
||||
#[prost(bytes = "vec", tag = "4")]
|
||||
pub parent_span_id: ::prost::alloc::vec::Vec<u8>,
|
||||
/// Flags, a bit field.
|
||||
///
|
||||
/// Bits 0-7 (8 least significant bits) are the trace flags as defined in W3C Trace
|
||||
/// Context specification. To read the 8-bit W3C trace flag, use
|
||||
/// `flags & SPAN_FLAGS_TRACE_FLAGS_MASK`.
|
||||
///
|
||||
/// See <https://www.w3.org/TR/trace-context-2/#trace-flags> for the flag definitions.
|
||||
///
|
||||
/// Bits 8 and 9 represent the 3 states of whether a span's parent
|
||||
/// is remote. The states are (unknown, is not remote, is remote).
|
||||
/// To read whether the value is known, use `(flags & SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE_MASK) != 0`.
|
||||
/// To read whether the span is remote, use `(flags & SPAN_FLAGS_CONTEXT_IS_REMOTE_MASK) != 0`.
|
||||
///
|
||||
/// When creating span messages, if the message is logically forwarded from another source
|
||||
/// with an equivalent flags fields (i.e., usually another OTLP span message), the field SHOULD
|
||||
/// be copied as-is. If creating from a source that does not have an equivalent flags field
|
||||
/// (such as a runtime representation of an OpenTelemetry span), the high 22 bits MUST
|
||||
/// be set to zero.
|
||||
/// Readers MUST NOT assume that bits 10-31 (22 most significant bits) will be zero.
|
||||
///
|
||||
/// \[Optional\].
|
||||
#[prost(fixed32, tag = "16")]
|
||||
pub flags: u32,
|
||||
/// A description of the span's operation.
|
||||
///
|
||||
/// For example, the name can be a qualified method name or a file name
|
||||
/// and a line number where the operation is called. A best practice is to use
|
||||
/// the same display name at the same call point in an application.
|
||||
/// This makes it easier to correlate spans in different traces.
|
||||
///
|
||||
/// This field is semantically required to be set to non-empty string.
|
||||
/// Empty value is equivalent to an unknown span name.
|
||||
///
|
||||
/// This field is required.
|
||||
#[prost(string, tag = "5")]
|
||||
pub name: ::prost::alloc::string::String,
|
||||
/// Distinguishes between spans generated in a particular context. For example,
|
||||
/// two spans with the same name may be distinguished using `CLIENT` (caller)
|
||||
/// and `SERVER` (callee) to identify queueing latency associated with the span.
|
||||
#[prost(enumeration = "span::SpanKind", tag = "6")]
|
||||
pub kind: i32,
|
||||
/// start_time_unix_nano is the start time of the span. On the client side, this is the time
|
||||
/// kept by the local machine where the span execution starts. On the server side, this
|
||||
/// is the time when the server's application handler starts running.
|
||||
/// Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970.
|
||||
///
|
||||
/// This field is semantically required and it is expected that end_time >= start_time.
|
||||
#[prost(fixed64, tag = "7")]
|
||||
pub start_time_unix_nano: u64,
|
||||
/// end_time_unix_nano is the end time of the span. On the client side, this is the time
|
||||
/// kept by the local machine where the span execution ends. On the server side, this
|
||||
/// is the time when the server application handler stops running.
|
||||
/// Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970.
|
||||
///
|
||||
/// This field is semantically required and it is expected that end_time >= start_time.
|
||||
#[prost(fixed64, tag = "8")]
|
||||
pub end_time_unix_nano: u64,
|
||||
/// attributes is a collection of key/value pairs. Note, global attributes
|
||||
/// like server name can be set using the resource API. Examples of attributes:
|
||||
///
|
||||
/// "/http/user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36"
|
||||
/// "/http/server_latency": 300
|
||||
/// "example.com/myattribute": true
|
||||
/// "example.com/score": 10.239
|
||||
///
|
||||
/// The OpenTelemetry API specification further restricts the allowed value types:
|
||||
/// <https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/common/README.md#attribute>
|
||||
/// Attribute keys MUST be unique (it is not allowed to have more than one
|
||||
/// attribute with the same key).
|
||||
#[prost(message, repeated, tag = "9")]
|
||||
pub attributes: ::prost::alloc::vec::Vec<super::super::common::v1::KeyValue>,
|
||||
/// dropped_attributes_count is the number of attributes that were discarded. Attributes
|
||||
/// can be discarded because their keys are too long or because there are too many
|
||||
/// attributes. If this value is 0, then no attributes were dropped.
|
||||
#[prost(uint32, tag = "10")]
|
||||
pub dropped_attributes_count: u32,
|
||||
/// events is a collection of Event items.
|
||||
#[prost(message, repeated, tag = "11")]
|
||||
pub events: ::prost::alloc::vec::Vec<span::Event>,
|
||||
/// dropped_events_count is the number of dropped events. If the value is 0, then no
|
||||
/// events were dropped.
|
||||
#[prost(uint32, tag = "12")]
|
||||
pub dropped_events_count: u32,
|
||||
/// links is a collection of Links, which are references from this span to a span
|
||||
/// in the same or different trace.
|
||||
#[prost(message, repeated, tag = "13")]
|
||||
pub links: ::prost::alloc::vec::Vec<span::Link>,
|
||||
/// dropped_links_count is the number of dropped links after the maximum size was
|
||||
/// enforced. If this value is 0, then no links were dropped.
|
||||
#[prost(uint32, tag = "14")]
|
||||
pub dropped_links_count: u32,
|
||||
/// An optional final status for this span. Semantically when Status isn't set, it means
|
||||
/// span's status code is unset, i.e. assume STATUS_CODE_UNSET (code = 0).
|
||||
#[prost(message, optional, tag = "15")]
|
||||
pub status: ::core::option::Option<Status>,
|
||||
}
|
||||
/// Nested message and enum types in `Span`.
|
||||
pub mod span {
|
||||
/// Event is a time-stamped annotation of the span, consisting of user-supplied
|
||||
/// text description and key-value pairs.
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct Event {
|
||||
/// time_unix_nano is the time the event occurred.
|
||||
#[prost(fixed64, tag = "1")]
|
||||
pub time_unix_nano: u64,
|
||||
/// name of the event.
|
||||
/// This field is semantically required to be set to non-empty string.
|
||||
#[prost(string, tag = "2")]
|
||||
pub name: ::prost::alloc::string::String,
|
||||
/// attributes is a collection of attribute key/value pairs on the event.
|
||||
/// Attribute keys MUST be unique (it is not allowed to have more than one
|
||||
/// attribute with the same key).
|
||||
#[prost(message, repeated, tag = "3")]
|
||||
pub attributes: ::prost::alloc::vec::Vec<
|
||||
super::super::super::common::v1::KeyValue,
|
||||
>,
|
||||
/// dropped_attributes_count is the number of dropped attributes. If the value is 0,
|
||||
/// then no attributes were dropped.
|
||||
#[prost(uint32, tag = "4")]
|
||||
pub dropped_attributes_count: u32,
|
||||
}
|
||||
/// A pointer from the current span to another span in the same trace or in a
|
||||
/// different trace. For example, this can be used in batching operations,
|
||||
/// where a single batch handler processes multiple requests from different
|
||||
/// traces or when the handler receives a request from a different project.
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct Link {
|
||||
/// A unique identifier of a trace that this linked span is part of. The ID is a
|
||||
/// 16-byte array.
|
||||
#[prost(bytes = "vec", tag = "1")]
|
||||
pub trace_id: ::prost::alloc::vec::Vec<u8>,
|
||||
/// A unique identifier for the linked span. The ID is an 8-byte array.
|
||||
#[prost(bytes = "vec", tag = "2")]
|
||||
pub span_id: ::prost::alloc::vec::Vec<u8>,
|
||||
/// The trace_state associated with the link.
|
||||
#[prost(string, tag = "3")]
|
||||
pub trace_state: ::prost::alloc::string::String,
|
||||
/// attributes is a collection of attribute key/value pairs on the link.
|
||||
/// Attribute keys MUST be unique (it is not allowed to have more than one
|
||||
/// attribute with the same key).
|
||||
#[prost(message, repeated, tag = "4")]
|
||||
pub attributes: ::prost::alloc::vec::Vec<
|
||||
super::super::super::common::v1::KeyValue,
|
||||
>,
|
||||
/// dropped_attributes_count is the number of dropped attributes. If the value is 0,
|
||||
/// then no attributes were dropped.
|
||||
#[prost(uint32, tag = "5")]
|
||||
pub dropped_attributes_count: u32,
|
||||
/// Flags, a bit field.
|
||||
///
|
||||
/// Bits 0-7 (8 least significant bits) are the trace flags as defined in W3C Trace
|
||||
/// Context specification. To read the 8-bit W3C trace flag, use
|
||||
/// `flags & SPAN_FLAGS_TRACE_FLAGS_MASK`.
|
||||
///
|
||||
/// See <https://www.w3.org/TR/trace-context-2/#trace-flags> for the flag definitions.
|
||||
///
|
||||
/// Bits 8 and 9 represent the 3 states of whether the link is remote.
|
||||
/// The states are (unknown, is not remote, is remote).
|
||||
/// To read whether the value is known, use `(flags & SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE_MASK) != 0`.
|
||||
/// To read whether the link is remote, use `(flags & SPAN_FLAGS_CONTEXT_IS_REMOTE_MASK) != 0`.
|
||||
///
|
||||
/// Readers MUST NOT assume that bits 10-31 (22 most significant bits) will be zero.
|
||||
/// When creating new spans, bits 10-31 (most-significant 22-bits) MUST be zero.
|
||||
///
|
||||
/// \[Optional\].
|
||||
#[prost(fixed32, tag = "6")]
|
||||
pub flags: u32,
|
||||
}
|
||||
/// SpanKind is the type of span. Can be used to specify additional relationships between spans
|
||||
/// in addition to a parent/child relationship.
|
||||
#[derive(
|
||||
Clone,
|
||||
Copy,
|
||||
Debug,
|
||||
PartialEq,
|
||||
Eq,
|
||||
Hash,
|
||||
PartialOrd,
|
||||
Ord,
|
||||
::prost::Enumeration
|
||||
)]
|
||||
#[repr(i32)]
|
||||
pub enum SpanKind {
|
||||
/// Unspecified. Do NOT use as default.
|
||||
/// Implementations MAY assume SpanKind to be INTERNAL when receiving UNSPECIFIED.
|
||||
Unspecified = 0,
|
||||
/// Indicates that the span represents an internal operation within an application,
|
||||
/// as opposed to an operation happening at the boundaries. Default value.
|
||||
Internal = 1,
|
||||
/// Indicates that the span covers server-side handling of an RPC or other
|
||||
/// remote network request.
|
||||
Server = 2,
|
||||
/// Indicates that the span describes a request to some remote service.
|
||||
Client = 3,
|
||||
/// Indicates that the span describes a producer sending a message to a broker.
|
||||
/// Unlike CLIENT and SERVER, there is often no direct critical path latency relationship
|
||||
/// between producer and consumer spans. A PRODUCER span ends when the message was accepted
|
||||
/// by the broker while the logical processing of the message might span a much longer time.
|
||||
Producer = 4,
|
||||
/// Indicates that the span describes consumer receiving a message from a broker.
|
||||
/// Like the PRODUCER kind, there is often no direct critical path latency relationship
|
||||
/// between producer and consumer spans.
|
||||
Consumer = 5,
|
||||
}
|
||||
impl SpanKind {
|
||||
/// String value of the enum field names used in the ProtoBuf definition.
|
||||
///
|
||||
/// The values are not transformed in any way and thus are considered stable
|
||||
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
|
||||
pub fn as_str_name(&self) -> &'static str {
|
||||
match self {
|
||||
Self::Unspecified => "SPAN_KIND_UNSPECIFIED",
|
||||
Self::Internal => "SPAN_KIND_INTERNAL",
|
||||
Self::Server => "SPAN_KIND_SERVER",
|
||||
Self::Client => "SPAN_KIND_CLIENT",
|
||||
Self::Producer => "SPAN_KIND_PRODUCER",
|
||||
Self::Consumer => "SPAN_KIND_CONSUMER",
|
||||
}
|
||||
}
|
||||
/// Creates an enum from field names used in the ProtoBuf definition.
|
||||
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
|
||||
match value {
|
||||
"SPAN_KIND_UNSPECIFIED" => Some(Self::Unspecified),
|
||||
"SPAN_KIND_INTERNAL" => Some(Self::Internal),
|
||||
"SPAN_KIND_SERVER" => Some(Self::Server),
|
||||
"SPAN_KIND_CLIENT" => Some(Self::Client),
|
||||
"SPAN_KIND_PRODUCER" => Some(Self::Producer),
|
||||
"SPAN_KIND_CONSUMER" => Some(Self::Consumer),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/// The Status type defines a logical error model that is suitable for different
|
||||
/// programming environments, including REST APIs and RPC APIs.
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct Status {
|
||||
/// A developer-facing human readable error message.
|
||||
#[prost(string, tag = "2")]
|
||||
pub message: ::prost::alloc::string::String,
|
||||
/// The status code.
|
||||
#[prost(enumeration = "status::StatusCode", tag = "3")]
|
||||
pub code: i32,
|
||||
}
|
||||
/// Nested message and enum types in `Status`.
|
||||
pub mod status {
|
||||
/// For the semantics of status codes see
|
||||
/// <https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/api.md#set-status>
|
||||
#[derive(
|
||||
Clone,
|
||||
Copy,
|
||||
Debug,
|
||||
PartialEq,
|
||||
Eq,
|
||||
Hash,
|
||||
PartialOrd,
|
||||
Ord,
|
||||
::prost::Enumeration
|
||||
)]
|
||||
#[repr(i32)]
|
||||
pub enum StatusCode {
|
||||
/// The default status.
|
||||
Unset = 0,
|
||||
/// The Span has been validated by an Application developer or Operator to
|
||||
/// have completed successfully.
|
||||
Ok = 1,
|
||||
/// The Span contains an error.
|
||||
Error = 2,
|
||||
}
|
||||
impl StatusCode {
|
||||
/// String value of the enum field names used in the ProtoBuf definition.
|
||||
///
|
||||
/// The values are not transformed in any way and thus are considered stable
|
||||
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
|
||||
pub fn as_str_name(&self) -> &'static str {
|
||||
match self {
|
||||
Self::Unset => "STATUS_CODE_UNSET",
|
||||
Self::Ok => "STATUS_CODE_OK",
|
||||
Self::Error => "STATUS_CODE_ERROR",
|
||||
}
|
||||
}
|
||||
/// Creates an enum from field names used in the ProtoBuf definition.
|
||||
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
|
||||
match value {
|
||||
"STATUS_CODE_UNSET" => Some(Self::Unset),
|
||||
"STATUS_CODE_OK" => Some(Self::Ok),
|
||||
"STATUS_CODE_ERROR" => Some(Self::Error),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/// SpanFlags represents constants used to interpret the
|
||||
/// Span.flags field, which is protobuf 'fixed32' type and is to
|
||||
/// be used as bit-fields. Each non-zero value defined in this enum is
|
||||
/// a bit-mask. To extract the bit-field, for example, use an
|
||||
/// expression like:
|
||||
///
|
||||
/// (span.flags & SPAN_FLAGS_TRACE_FLAGS_MASK)
|
||||
///
|
||||
/// See <https://www.w3.org/TR/trace-context-2/#trace-flags> for the flag definitions.
|
||||
///
|
||||
/// Note that Span flags were introduced in version 1.1 of the
|
||||
/// OpenTelemetry protocol. Older Span producers do not set this
|
||||
/// field, consequently consumers should not rely on the absence of a
|
||||
/// particular flag bit to indicate the presence of a particular feature.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
|
||||
#[repr(i32)]
|
||||
pub enum SpanFlags {
|
||||
/// The zero value for the enum. Should not be used for comparisons.
|
||||
/// Instead use bitwise "and" with the appropriate mask as shown above.
|
||||
DoNotUse = 0,
|
||||
/// Bits 0-7 are used for trace flags.
|
||||
TraceFlagsMask = 255,
|
||||
/// Bits 8 and 9 are used to indicate that the parent span or link span is remote.
|
||||
/// Bit 8 (`HAS_IS_REMOTE`) indicates whether the value is known.
|
||||
/// Bit 9 (`IS_REMOTE`) indicates whether the span or link is remote.
|
||||
ContextHasIsRemoteMask = 256,
|
||||
ContextIsRemoteMask = 512,
|
||||
}
|
||||
impl SpanFlags {
|
||||
/// String value of the enum field names used in the ProtoBuf definition.
|
||||
///
|
||||
/// The values are not transformed in any way and thus are considered stable
|
||||
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
|
||||
pub fn as_str_name(&self) -> &'static str {
|
||||
match self {
|
||||
Self::DoNotUse => "SPAN_FLAGS_DO_NOT_USE",
|
||||
Self::TraceFlagsMask => "SPAN_FLAGS_TRACE_FLAGS_MASK",
|
||||
Self::ContextHasIsRemoteMask => "SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE_MASK",
|
||||
Self::ContextIsRemoteMask => "SPAN_FLAGS_CONTEXT_IS_REMOTE_MASK",
|
||||
}
|
||||
}
|
||||
/// Creates an enum from field names used in the ProtoBuf definition.
|
||||
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
|
||||
match value {
|
||||
"SPAN_FLAGS_DO_NOT_USE" => Some(Self::DoNotUse),
|
||||
"SPAN_FLAGS_TRACE_FLAGS_MASK" => Some(Self::TraceFlagsMask),
|
||||
"SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE_MASK" => Some(Self::ContextHasIsRemoteMask),
|
||||
"SPAN_FLAGS_CONTEXT_IS_REMOTE_MASK" => Some(Self::ContextIsRemoteMask),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
//! gRPC bindings for OpenTelemetry.
|
||||
//!
|
||||
//! Vendored from <https://github.com/open-telemetry/opentelemetry-proto/>.
|
||||
|
||||
// proto mod contains file generated by protobuf or other build tools.
|
||||
// we shouldn't manually change it. Thus skip format and lint check.
|
||||
#[rustfmt::skip]
|
||||
#[allow(warnings)]
|
||||
pub mod proto;
|
||||
|
||||
pub mod transform;
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
pub mod collector {
|
||||
pub mod trace {
|
||||
pub mod v1 {
|
||||
include!("gen/opentelemetry.proto.collector.trace.v1.rs");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub mod common {
|
||||
pub mod v1 {
|
||||
include!("gen/opentelemetry.proto.common.v1.rs");
|
||||
}
|
||||
}
|
||||
|
||||
pub mod trace {
|
||||
pub mod v1 {
|
||||
include!("gen/opentelemetry.proto.trace.v1.rs");
|
||||
}
|
||||
}
|
||||
|
||||
pub mod resource {
|
||||
pub mod v1 {
|
||||
include!("gen/opentelemetry.proto.resource.v1.rs");
|
||||
}
|
||||
}
|
||||
|
|
@ -1,150 +0,0 @@
|
|||
use std::time::{Duration, SystemTime, UNIX_EPOCH};
|
||||
|
||||
pub(crate) fn to_nanos(time: SystemTime) -> u64 {
|
||||
time.duration_since(UNIX_EPOCH)
|
||||
.unwrap_or_else(|_| Duration::from_secs(0))
|
||||
.as_nanos() as u64
|
||||
}
|
||||
|
||||
use crate::proto::common::v1::{any_value, AnyValue, ArrayValue, InstrumentationScope, KeyValue};
|
||||
use opentelemetry::{Array, Value};
|
||||
use std::borrow::Cow;
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct ResourceAttributesWithSchema {
|
||||
pub attributes: Attributes,
|
||||
pub schema_url: Option<String>,
|
||||
}
|
||||
|
||||
impl From<&opentelemetry_sdk::Resource> for ResourceAttributesWithSchema {
|
||||
fn from(resource: &opentelemetry_sdk::Resource) -> Self {
|
||||
ResourceAttributesWithSchema {
|
||||
attributes: resource_attributes(resource),
|
||||
schema_url: resource.schema_url().map(ToString::to_string),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl
|
||||
From<(
|
||||
opentelemetry::InstrumentationScope,
|
||||
Option<Cow<'static, str>>,
|
||||
)> for InstrumentationScope
|
||||
{
|
||||
fn from(
|
||||
data: (
|
||||
opentelemetry::InstrumentationScope,
|
||||
Option<Cow<'static, str>>,
|
||||
),
|
||||
) -> Self {
|
||||
let (scope, target) = data;
|
||||
if let Some(t) = target {
|
||||
InstrumentationScope {
|
||||
name: t.to_string(),
|
||||
version: String::new(),
|
||||
attributes: vec![],
|
||||
..Default::default()
|
||||
}
|
||||
} else {
|
||||
let Attributes(attributes) =
|
||||
Attributes::from(scope.attributes().cloned().collect::<Vec<_>>());
|
||||
InstrumentationScope {
|
||||
name: scope.name().to_string(),
|
||||
version: scope.version().map(ToString::to_string).unwrap_or_default(),
|
||||
attributes,
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl
|
||||
From<(
|
||||
&opentelemetry::InstrumentationScope,
|
||||
Option<Cow<'static, str>>,
|
||||
)> for InstrumentationScope
|
||||
{
|
||||
fn from(
|
||||
data: (
|
||||
&opentelemetry::InstrumentationScope,
|
||||
Option<Cow<'static, str>>,
|
||||
),
|
||||
) -> Self {
|
||||
let (scope, target) = data;
|
||||
if let Some(t) = target {
|
||||
InstrumentationScope {
|
||||
name: t.to_string(),
|
||||
version: String::new(),
|
||||
attributes: vec![],
|
||||
..Default::default()
|
||||
}
|
||||
} else {
|
||||
let Attributes(attributes) =
|
||||
Attributes::from(scope.attributes().cloned().collect::<Vec<_>>());
|
||||
InstrumentationScope {
|
||||
name: scope.name().to_string(),
|
||||
version: scope.version().map(ToString::to_string).unwrap_or_default(),
|
||||
attributes,
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Wrapper type for Vec<`KeyValue`>
|
||||
#[derive(Default, Debug)]
|
||||
pub struct Attributes(pub ::std::vec::Vec<crate::proto::common::v1::KeyValue>);
|
||||
|
||||
impl From<Vec<opentelemetry::KeyValue>> for Attributes {
|
||||
fn from(kvs: Vec<opentelemetry::KeyValue>) -> Self {
|
||||
Attributes(
|
||||
kvs.into_iter()
|
||||
.map(|api_kv| KeyValue {
|
||||
key: api_kv.key.as_str().to_string(),
|
||||
value: Some(api_kv.value.into()),
|
||||
})
|
||||
.collect(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Value> for AnyValue {
|
||||
fn from(value: Value) -> Self {
|
||||
AnyValue {
|
||||
value: match value {
|
||||
Value::Bool(val) => Some(any_value::Value::BoolValue(val)),
|
||||
Value::I64(val) => Some(any_value::Value::IntValue(val)),
|
||||
Value::F64(val) => Some(any_value::Value::DoubleValue(val)),
|
||||
Value::String(val) => Some(any_value::Value::StringValue(val.to_string())),
|
||||
Value::Array(array) => Some(any_value::Value::ArrayValue(match array {
|
||||
Array::Bool(vals) => array_into_proto(vals),
|
||||
Array::I64(vals) => array_into_proto(vals),
|
||||
Array::F64(vals) => array_into_proto(vals),
|
||||
Array::String(vals) => array_into_proto(vals),
|
||||
_ => ArrayValue::default(),
|
||||
})),
|
||||
_ => None,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn array_into_proto<T>(vals: Vec<T>) -> ArrayValue
|
||||
where
|
||||
Value: From<T>,
|
||||
{
|
||||
let values = vals
|
||||
.into_iter()
|
||||
.map(|val| AnyValue::from(Value::from(val)))
|
||||
.collect();
|
||||
|
||||
ArrayValue { values }
|
||||
}
|
||||
|
||||
pub(crate) fn resource_attributes(resource: &opentelemetry_sdk::Resource) -> Attributes {
|
||||
resource
|
||||
.iter()
|
||||
.map(|(k, v)| opentelemetry::KeyValue::new(k.clone(), v.clone()))
|
||||
.collect::<Vec<_>>()
|
||||
.into()
|
||||
}
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
pub mod common;
|
||||
pub mod trace;
|
||||
|
|
@ -1,355 +0,0 @@
|
|||
use crate::{
|
||||
proto::{
|
||||
resource::v1::Resource,
|
||||
trace::v1::{span, status, ResourceSpans, ScopeSpans, Span, Status},
|
||||
},
|
||||
transform::common::{to_nanos, Attributes, ResourceAttributesWithSchema},
|
||||
};
|
||||
use opentelemetry::{
|
||||
trace,
|
||||
trace::{Link, SpanId, SpanKind},
|
||||
};
|
||||
use opentelemetry_sdk::trace::SpanData;
|
||||
use std::collections::HashMap;
|
||||
|
||||
impl From<SpanKind> for span::SpanKind {
|
||||
fn from(span_kind: SpanKind) -> Self {
|
||||
match span_kind {
|
||||
SpanKind::Client => span::SpanKind::Client,
|
||||
SpanKind::Consumer => span::SpanKind::Consumer,
|
||||
SpanKind::Internal => span::SpanKind::Internal,
|
||||
SpanKind::Producer => span::SpanKind::Producer,
|
||||
SpanKind::Server => span::SpanKind::Server,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&trace::Status> for status::StatusCode {
|
||||
fn from(status: &trace::Status) -> Self {
|
||||
match status {
|
||||
trace::Status::Ok => status::StatusCode::Ok,
|
||||
trace::Status::Unset => status::StatusCode::Unset,
|
||||
trace::Status::Error { .. } => status::StatusCode::Error,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Link> for span::Link {
|
||||
fn from(link: Link) -> Self {
|
||||
span::Link {
|
||||
trace_id: link.span_context.trace_id().to_bytes().to_vec(),
|
||||
span_id: link.span_context.span_id().to_bytes().to_vec(),
|
||||
trace_state: link.span_context.trace_state().header(),
|
||||
attributes: Attributes::from(link.attributes).0,
|
||||
dropped_attributes_count: link.dropped_attributes_count,
|
||||
flags: link.span_context.trace_flags().to_u8() as u32,
|
||||
}
|
||||
}
|
||||
}
|
||||
impl From<opentelemetry_sdk::trace::SpanData> for Span {
|
||||
fn from(source_span: opentelemetry_sdk::trace::SpanData) -> Self {
|
||||
let span_kind: span::SpanKind = source_span.span_kind.into();
|
||||
Span {
|
||||
trace_id: source_span.span_context.trace_id().to_bytes().to_vec(),
|
||||
span_id: source_span.span_context.span_id().to_bytes().to_vec(),
|
||||
trace_state: source_span.span_context.trace_state().header(),
|
||||
parent_span_id: {
|
||||
if source_span.parent_span_id != SpanId::INVALID {
|
||||
source_span.parent_span_id.to_bytes().to_vec()
|
||||
} else {
|
||||
vec![]
|
||||
}
|
||||
},
|
||||
flags: source_span.span_context.trace_flags().to_u8() as u32,
|
||||
name: source_span.name.into_owned(),
|
||||
kind: span_kind as i32,
|
||||
start_time_unix_nano: to_nanos(source_span.start_time),
|
||||
end_time_unix_nano: to_nanos(source_span.end_time),
|
||||
dropped_attributes_count: source_span.dropped_attributes_count,
|
||||
attributes: Attributes::from(source_span.attributes).0,
|
||||
dropped_events_count: source_span.events.dropped_count,
|
||||
events: source_span
|
||||
.events
|
||||
.into_iter()
|
||||
.map(|event| span::Event {
|
||||
time_unix_nano: to_nanos(event.timestamp),
|
||||
name: event.name.into(),
|
||||
attributes: Attributes::from(event.attributes).0,
|
||||
dropped_attributes_count: event.dropped_attributes_count,
|
||||
})
|
||||
.collect(),
|
||||
dropped_links_count: source_span.links.dropped_count,
|
||||
links: source_span.links.into_iter().map(Into::into).collect(),
|
||||
status: Some(Status {
|
||||
code: status::StatusCode::from(&source_span.status).into(),
|
||||
message: match source_span.status {
|
||||
trace::Status::Error { description } => description.to_string(),
|
||||
_ => Default::default(),
|
||||
},
|
||||
}),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ResourceSpans {
|
||||
pub fn new(source_span: SpanData, resource: &ResourceAttributesWithSchema) -> Self {
|
||||
let span_kind: span::SpanKind = source_span.span_kind.into();
|
||||
ResourceSpans {
|
||||
resource: Some(Resource {
|
||||
attributes: resource.attributes.0.clone(),
|
||||
dropped_attributes_count: 0,
|
||||
}),
|
||||
schema_url: resource.schema_url.clone().unwrap_or_default(),
|
||||
scope_spans: vec![ScopeSpans {
|
||||
schema_url: source_span
|
||||
.instrumentation_scope
|
||||
.schema_url()
|
||||
.map(ToString::to_string)
|
||||
.unwrap_or_default(),
|
||||
scope: Some((source_span.instrumentation_scope, None).into()),
|
||||
spans: vec![Span {
|
||||
trace_id: source_span.span_context.trace_id().to_bytes().to_vec(),
|
||||
span_id: source_span.span_context.span_id().to_bytes().to_vec(),
|
||||
trace_state: source_span.span_context.trace_state().header(),
|
||||
parent_span_id: {
|
||||
if source_span.parent_span_id != SpanId::INVALID {
|
||||
source_span.parent_span_id.to_bytes().to_vec()
|
||||
} else {
|
||||
vec![]
|
||||
}
|
||||
},
|
||||
flags: source_span.span_context.trace_flags().to_u8() as u32,
|
||||
name: source_span.name.into_owned(),
|
||||
kind: span_kind as i32,
|
||||
start_time_unix_nano: to_nanos(source_span.start_time),
|
||||
end_time_unix_nano: to_nanos(source_span.end_time),
|
||||
dropped_attributes_count: source_span.dropped_attributes_count,
|
||||
attributes: Attributes::from(source_span.attributes).0,
|
||||
dropped_events_count: source_span.events.dropped_count,
|
||||
events: source_span
|
||||
.events
|
||||
.into_iter()
|
||||
.map(|event| span::Event {
|
||||
time_unix_nano: to_nanos(event.timestamp),
|
||||
name: event.name.into(),
|
||||
attributes: Attributes::from(event.attributes).0,
|
||||
dropped_attributes_count: event.dropped_attributes_count,
|
||||
})
|
||||
.collect(),
|
||||
dropped_links_count: source_span.links.dropped_count,
|
||||
links: source_span.links.into_iter().map(Into::into).collect(),
|
||||
status: Some(Status {
|
||||
code: status::StatusCode::from(&source_span.status).into(),
|
||||
message: match source_span.status {
|
||||
trace::Status::Error { description } => description.to_string(),
|
||||
_ => Default::default(),
|
||||
},
|
||||
}),
|
||||
}],
|
||||
}],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn group_spans_by_resource_and_scope(
|
||||
spans: Vec<SpanData>,
|
||||
resource: &ResourceAttributesWithSchema,
|
||||
) -> Vec<ResourceSpans> {
|
||||
// Group spans by their instrumentation library
|
||||
let scope_map = spans.iter().fold(
|
||||
HashMap::new(),
|
||||
|mut scope_map: HashMap<&opentelemetry::InstrumentationScope, Vec<&SpanData>>, span| {
|
||||
let instrumentation = &span.instrumentation_scope;
|
||||
scope_map.entry(instrumentation).or_default().push(span);
|
||||
scope_map
|
||||
},
|
||||
);
|
||||
|
||||
// Convert the grouped spans into ScopeSpans
|
||||
let scope_spans = scope_map
|
||||
.into_iter()
|
||||
.map(|(instrumentation, span_records)| ScopeSpans {
|
||||
scope: Some((instrumentation, None).into()),
|
||||
schema_url: resource.schema_url.clone().unwrap_or_default(),
|
||||
spans: span_records
|
||||
.into_iter()
|
||||
.map(|span_data| span_data.clone().into())
|
||||
.collect(),
|
||||
})
|
||||
.collect();
|
||||
|
||||
// Wrap ScopeSpans into a single ResourceSpans
|
||||
vec![ResourceSpans {
|
||||
resource: Some(Resource {
|
||||
attributes: resource.attributes.0.clone(),
|
||||
dropped_attributes_count: 0,
|
||||
}),
|
||||
scope_spans,
|
||||
schema_url: resource.schema_url.clone().unwrap_or_default(),
|
||||
}]
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{
|
||||
proto::common::v1::any_value::Value, transform::common::ResourceAttributesWithSchema,
|
||||
};
|
||||
use opentelemetry::{
|
||||
trace::{SpanContext, SpanId, SpanKind, Status, TraceFlags, TraceId, TraceState},
|
||||
InstrumentationScope, KeyValue,
|
||||
};
|
||||
use opentelemetry_sdk::{
|
||||
resource::Resource,
|
||||
trace::{SpanData, SpanEvents, SpanLinks},
|
||||
};
|
||||
use std::{
|
||||
borrow::Cow,
|
||||
time::{Duration, SystemTime},
|
||||
};
|
||||
|
||||
fn create_test_span_data(instrumentation_name: &'static str) -> SpanData {
|
||||
let span_context = SpanContext::new(
|
||||
TraceId::from_u128(123),
|
||||
SpanId::from_u64(456),
|
||||
TraceFlags::default(),
|
||||
false,
|
||||
TraceState::default(),
|
||||
);
|
||||
|
||||
SpanData {
|
||||
span_context,
|
||||
parent_span_id: SpanId::from_u64(0),
|
||||
span_kind: SpanKind::Internal,
|
||||
name: Cow::Borrowed("test_span"),
|
||||
start_time: SystemTime::now(),
|
||||
end_time: SystemTime::now() + Duration::from_secs(1),
|
||||
attributes: vec![KeyValue::new("key", "value")],
|
||||
dropped_attributes_count: 0,
|
||||
events: SpanEvents::default(),
|
||||
links: SpanLinks::default(),
|
||||
status: Status::Unset,
|
||||
instrumentation_scope: InstrumentationScope::builder(instrumentation_name).build(),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_group_spans_by_resource_and_scope_single_scope() {
|
||||
let resource = Resource::builder_empty()
|
||||
.with_attribute(KeyValue::new("resource_key", "resource_value"))
|
||||
.build();
|
||||
let span_data = create_test_span_data("lib1");
|
||||
|
||||
let spans = vec![span_data.clone()];
|
||||
let resource: ResourceAttributesWithSchema = (&resource).into(); // Convert Resource to ResourceAttributesWithSchema
|
||||
|
||||
let grouped_spans =
|
||||
crate::transform::trace::group_spans_by_resource_and_scope(spans, &resource);
|
||||
|
||||
assert_eq!(grouped_spans.len(), 1);
|
||||
|
||||
let resource_spans = &grouped_spans[0];
|
||||
assert_eq!(
|
||||
resource_spans.resource.as_ref().unwrap().attributes.len(),
|
||||
1
|
||||
);
|
||||
assert_eq!(
|
||||
resource_spans.resource.as_ref().unwrap().attributes[0].key,
|
||||
"resource_key"
|
||||
);
|
||||
assert_eq!(
|
||||
resource_spans.resource.as_ref().unwrap().attributes[0]
|
||||
.value
|
||||
.clone()
|
||||
.unwrap()
|
||||
.value
|
||||
.unwrap(),
|
||||
Value::StringValue("resource_value".to_string())
|
||||
);
|
||||
|
||||
let scope_spans = &resource_spans.scope_spans;
|
||||
assert_eq!(scope_spans.len(), 1);
|
||||
|
||||
let scope_span = &scope_spans[0];
|
||||
assert_eq!(scope_span.scope.as_ref().unwrap().name, "lib1");
|
||||
assert_eq!(scope_span.spans.len(), 1);
|
||||
|
||||
assert_eq!(
|
||||
scope_span.spans[0].trace_id,
|
||||
span_data.span_context.trace_id().to_bytes().to_vec()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_group_spans_by_resource_and_scope_multiple_scopes() {
|
||||
let resource = Resource::builder_empty()
|
||||
.with_attribute(KeyValue::new("resource_key", "resource_value"))
|
||||
.build();
|
||||
let span_data1 = create_test_span_data("lib1");
|
||||
let span_data2 = create_test_span_data("lib1");
|
||||
let span_data3 = create_test_span_data("lib2");
|
||||
|
||||
let spans = vec![span_data1.clone(), span_data2.clone(), span_data3.clone()];
|
||||
let resource: ResourceAttributesWithSchema = (&resource).into(); // Convert Resource to ResourceAttributesWithSchema
|
||||
|
||||
let grouped_spans =
|
||||
crate::transform::trace::group_spans_by_resource_and_scope(spans, &resource);
|
||||
|
||||
assert_eq!(grouped_spans.len(), 1);
|
||||
|
||||
let resource_spans = &grouped_spans[0];
|
||||
assert_eq!(
|
||||
resource_spans.resource.as_ref().unwrap().attributes.len(),
|
||||
1
|
||||
);
|
||||
assert_eq!(
|
||||
resource_spans.resource.as_ref().unwrap().attributes[0].key,
|
||||
"resource_key"
|
||||
);
|
||||
assert_eq!(
|
||||
resource_spans.resource.as_ref().unwrap().attributes[0]
|
||||
.value
|
||||
.clone()
|
||||
.unwrap()
|
||||
.value
|
||||
.unwrap(),
|
||||
Value::StringValue("resource_value".to_string())
|
||||
);
|
||||
|
||||
let scope_spans = &resource_spans.scope_spans;
|
||||
assert_eq!(scope_spans.len(), 2);
|
||||
|
||||
// Check the scope spans for both lib1 and lib2
|
||||
let mut lib1_scope_span = None;
|
||||
let mut lib2_scope_span = None;
|
||||
|
||||
for scope_span in scope_spans {
|
||||
match scope_span.scope.as_ref().unwrap().name.as_str() {
|
||||
"lib1" => lib1_scope_span = Some(scope_span),
|
||||
"lib2" => lib2_scope_span = Some(scope_span),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
let lib1_scope_span = lib1_scope_span.expect("lib1 scope span not found");
|
||||
let lib2_scope_span = lib2_scope_span.expect("lib2 scope span not found");
|
||||
|
||||
assert_eq!(lib1_scope_span.scope.as_ref().unwrap().name, "lib1");
|
||||
assert_eq!(lib2_scope_span.scope.as_ref().unwrap().name, "lib2");
|
||||
|
||||
assert_eq!(lib1_scope_span.spans.len(), 2);
|
||||
assert_eq!(lib2_scope_span.spans.len(), 1);
|
||||
|
||||
assert_eq!(
|
||||
lib1_scope_span.spans[0].trace_id,
|
||||
span_data1.span_context.trace_id().to_bytes().to_vec()
|
||||
);
|
||||
assert_eq!(
|
||||
lib1_scope_span.spans[1].trace_id,
|
||||
span_data2.span_context.trace_id().to_bytes().to_vec()
|
||||
);
|
||||
assert_eq!(
|
||||
lib2_scope_span.spans[0].trace_id,
|
||||
span_data3.span_context.trace_id().to_bytes().to_vec()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
//! A test that regenerates the Rust protobuf bindings.
|
||||
//!
|
||||
//! It can be run via:
|
||||
//!
|
||||
//! ```no_run
|
||||
//! cargo test -p opentelmetry-proto --test=bootstrap
|
||||
//! ```
|
||||
|
||||
/// Generates protobuf bindings into src/gen and fails if the generated files do
|
||||
/// not match those that are already checked into git
|
||||
#[test]
|
||||
fn bootstrap() {
|
||||
let out_dir = std::path::PathBuf::from(std::env!("CARGO_MANIFEST_DIR"))
|
||||
.join("src")
|
||||
.join("gen");
|
||||
generate(&out_dir);
|
||||
if changed(&out_dir) {
|
||||
panic!("protobuf interfaces do not match generated sources");
|
||||
}
|
||||
}
|
||||
|
||||
/// Generates protobuf bindings into the given directory
|
||||
fn generate(out_dir: &std::path::Path) {
|
||||
let iface_files = &[
|
||||
"opentelemetry/proto/collector/trace/v1/trace_service.proto",
|
||||
"opentelemetry/proto/common/v1/common.proto",
|
||||
"opentelemetry/proto/resource/v1/resource.proto",
|
||||
"opentelemetry/proto/trace/v1/trace.proto",
|
||||
];
|
||||
if let Err(error) = tonic_build::configure()
|
||||
.build_client(true)
|
||||
.build_server(false)
|
||||
.emit_rerun_if_changed(false)
|
||||
.out_dir(out_dir)
|
||||
.compile_protos(iface_files, &["."])
|
||||
{
|
||||
panic!("failed to compile protobuf: {error}")
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns true if the given path contains files that have changed since the
|
||||
/// last Git commit
|
||||
fn changed(path: &std::path::Path) -> bool {
|
||||
let status = std::process::Command::new("git")
|
||||
.arg("diff")
|
||||
.arg("--exit-code")
|
||||
.arg("--")
|
||||
.arg(path)
|
||||
.status()
|
||||
.expect("failed to run git");
|
||||
!status.success()
|
||||
}
|
||||
Loading…
Reference in New Issue