diff --git a/.codecov.yml b/.codecov.yml index 80779752c8..09533d0322 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -2,7 +2,6 @@ coverage: ignore: - "linkerd/app/integration/src/**" - "**/src/gen/**" - - "tools/**" precision: 2 round: down @@ -18,7 +17,6 @@ coverage: paths: - "!linkerd/app/integration/src/**" - "!**/src/gen/**" - - "!tools/**" patch: default: diff --git a/.gitattributes b/.gitattributes index 97978789da..bcadc6d5d2 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,2 @@ Cargo.lock linguist-generated=false linkerd/transport-header/src/gen/* linguist-generated=true -opencensus-proto/src/gen/* linguist-generated=true diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 5e64509c0b..e83d3df318 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -50,8 +50,8 @@ jobs: steps: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 - uses: Swatinem/rust-cache@98c8021b550208e191a6a3145459bfc9fb29c4c0 - - run: cargo tarpaulin --locked --workspace --exclude=linkerd2-proxy --exclude=linkerd-transport-header --exclude=opencensus-proto --exclude=spire-proto --no-run - - run: cargo tarpaulin --locked --workspace --exclude=linkerd2-proxy --exclude=linkerd-transport-header --exclude=opencensus-proto --exclude=spire-proto --skip-clean --ignore-tests --no-fail-fast --out=Xml + - run: cargo tarpaulin --locked --workspace --exclude=linkerd2-proxy --exclude=linkerd-transport-header --exclude=spire-proto --no-run + - run: cargo tarpaulin --locked --workspace --exclude=linkerd2-proxy --exclude=linkerd-transport-header --exclude=spire-proto --skip-clean --ignore-tests --no-fail-fast --out=Xml # Some tests are especially flakey in coverage tests. That's fine. We # only really care to measure how much of our codebase is covered. continue-on-error: true diff --git a/Cargo.lock b/Cargo.lock index becbe5e717..69a6e6a89b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1374,7 +1374,6 @@ dependencies = [ "linkerd-app-inbound", "linkerd-app-outbound", "linkerd-error", - "linkerd-opencensus", "linkerd-opentelemetry", "linkerd-tonic-stream", "linkerd-workers", @@ -1436,7 +1435,6 @@ dependencies = [ "linkerd-meshtls", "linkerd-metrics", "linkerd-mock-http-body", - "linkerd-opencensus", "linkerd-opentelemetry", "linkerd-proxy-api-resolve", "linkerd-proxy-balance", @@ -2061,22 +2059,6 @@ dependencies = [ name = "linkerd-opaq-route" version = "0.1.0" -[[package]] -name = "linkerd-opencensus" -version = "0.1.0" -dependencies = [ - "futures", - "http-body", - "linkerd-error", - "linkerd-metrics", - "linkerd-trace-context", - "opencensus-proto", - "tokio", - "tokio-stream", - "tonic", - "tracing", -] - [[package]] name = "linkerd-opentelemetry" version = "0.1.0" @@ -2930,16 +2912,6 @@ dependencies = [ "portable-atomic", ] -[[package]] -name = "opencensus-proto" -version = "0.1.0" -dependencies = [ - "prost 0.13.5", - "prost-types 0.13.5", - "tonic", - "tonic-build", -] - [[package]] name = "opentelemetry" version = "0.30.0" diff --git a/Cargo.toml b/Cargo.toml index 3e748aa3d7..96a9ef6665 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,6 @@ members = [ "linkerd/metrics", "linkerd/mock/http-body", "linkerd/opaq-route", - "linkerd/opencensus", "linkerd/opentelemetry", "linkerd/pool", "linkerd/pool/mock", @@ -85,9 +84,7 @@ members = [ "linkerd/transport-metrics", "linkerd/workers", "linkerd2-proxy", - "opencensus-proto", "spiffe-proto", - "tools", ] [profile.release] diff --git a/linkerd/app/Cargo.toml b/linkerd/app/Cargo.toml index 7be77901c7..be665b1a66 100644 --- a/linkerd/app/Cargo.toml +++ b/linkerd/app/Cargo.toml @@ -25,7 +25,6 @@ linkerd-app-gateway = { path = "./gateway" } linkerd-app-inbound = { path = "./inbound" } linkerd-app-outbound = { path = "./outbound" } linkerd-error = { path = "../error" } -linkerd-opencensus = { path = "../opencensus" } linkerd-opentelemetry = { path = "../opentelemetry" } linkerd-tonic-stream = { path = "../tonic-stream" } linkerd-workers = { path = "../workers" } diff --git a/linkerd/app/core/Cargo.toml b/linkerd/app/core/Cargo.toml index 1feb89d482..f4e65a2980 100644 --- a/linkerd/app/core/Cargo.toml +++ b/linkerd/app/core/Cargo.toml @@ -39,7 +39,6 @@ linkerd-idle-cache = { path = "../../idle-cache" } linkerd-io = { path = "../../io" } linkerd-meshtls = { path = "../../meshtls", default-features = false } linkerd-metrics = { path = "../../metrics", features = ["process", "stack"] } -linkerd-opencensus = { path = "../../opencensus" } linkerd-opentelemetry = { path = "../../opentelemetry" } linkerd-proxy-api-resolve = { path = "../../proxy/api-resolve" } linkerd-proxy-balance = { path = "../../proxy/balance" } diff --git a/linkerd/app/core/src/http_tracing.rs b/linkerd/app/core/src/http_tracing.rs index b0ddb05ce5..ba9629d4cc 100644 --- a/linkerd/app/core/src/http_tracing.rs +++ b/linkerd/app/core/src/http_tracing.rs @@ -11,7 +11,6 @@ use tokio::sync::mpsc; #[derive(Debug, Copy, Clone, Default)] pub enum CollectorProtocol { #[default] - OpenCensus, OpenTelemetry, } @@ -19,9 +18,7 @@ impl FromStr for CollectorProtocol { type Err = (); fn from_str(s: &str) -> Result { - if s.eq_ignore_ascii_case("opencensus") { - Ok(Self::OpenCensus) - } else if s.eq_ignore_ascii_case("opentelemetry") { + if s.eq_ignore_ascii_case("opentelemetry") { Ok(Self::OpenTelemetry) } else { Err(()) diff --git a/linkerd/app/core/src/lib.rs b/linkerd/app/core/src/lib.rs index 03a107d32a..2cc487bae8 100644 --- a/linkerd/app/core/src/lib.rs +++ b/linkerd/app/core/src/lib.rs @@ -39,7 +39,6 @@ pub use linkerd_exp_backoff as exp_backoff; pub use linkerd_http_metrics as http_metrics; pub use linkerd_idle_cache as idle_cache; pub use linkerd_io as io; -pub use linkerd_opencensus as opencensus; pub use linkerd_opentelemetry as opentelemetry; pub use linkerd_service_profiles as profiles; pub use linkerd_stack_metrics as stack_metrics; diff --git a/linkerd/app/core/src/metrics.rs b/linkerd/app/core/src/metrics.rs index 5e55f3dea1..41b4e8d715 100644 --- a/linkerd/app/core/src/metrics.rs +++ b/linkerd/app/core/src/metrics.rs @@ -9,7 +9,7 @@ pub use crate::transport::labels::{TargetAddr, TlsAccept}; use crate::{ classify::Class, - control, http_metrics, opencensus, opentelemetry, profiles, proxy, stack_metrics, svc, tls, + control, http_metrics, opentelemetry, profiles, proxy, stack_metrics, svc, tls, transport::{self, labels::TlsConnect}, }; use linkerd_addr::Addr; @@ -37,7 +37,6 @@ pub type Stack = stack_metrics::Registry; pub struct Metrics { pub proxy: Proxy, pub control: ControlHttp, - pub opencensus: opencensus::metrics::Registry, pub opentelemetry: opentelemetry::metrics::Registry, } @@ -213,13 +212,11 @@ impl Metrics { transport, }; - let (opencensus, opencensus_report) = opencensus::metrics::new(); let (opentelemetry, opentelemetry_report) = opentelemetry::metrics::new(); let metrics = Metrics { proxy, control, - opencensus, opentelemetry, }; @@ -230,7 +227,6 @@ impl Metrics { .and_report(actual_report) .and_report(control_report) .and_report(transport_report) - .and_report(opencensus_report) .and_report(opentelemetry_report) .and_report(stack); diff --git a/linkerd/app/src/lib.rs b/linkerd/app/src/lib.rs index 963b5326ba..cf607e95c1 100644 --- a/linkerd/app/src/lib.rs +++ b/linkerd/app/src/lib.rs @@ -206,16 +206,8 @@ impl Config { let dns = dns.resolver("trace_collector"); let client_metrics = metrics.control.clone(); let otel_metrics = metrics.opentelemetry; - let oc_metrics = metrics.opencensus; info_span!("tracing").in_scope(|| { - trace_collector.build( - identity, - dns, - oc_metrics, - otel_metrics, - control_metrics, - client_metrics, - ) + trace_collector.build(identity, dns, otel_metrics, control_metrics, client_metrics) }) }?; diff --git a/linkerd/app/src/trace_collector.rs b/linkerd/app/src/trace_collector.rs index b173848c61..61e01d5397 100644 --- a/linkerd/app/src/trace_collector.rs +++ b/linkerd/app/src/trace_collector.rs @@ -3,14 +3,13 @@ use linkerd_app_core::{ http_tracing::{CollectorProtocol, SpanSink}, identity, metrics::ControlHttp as HttpMetrics, - opencensus, opentelemetry, + opentelemetry, svc::NewService, }; use linkerd_error::Error; use otel_collector::OtelCollectorAttributes; use std::{collections::HashMap, future::Future, pin::Pin}; -pub mod oc_collector; pub mod otel_collector; const SPAN_BUFFER_CAPACITY: usize = 100; @@ -59,7 +58,6 @@ impl Config { match self { Config::Disabled => None, Config::Enabled(config) => match config.kind { - CollectorProtocol::OpenCensus => Some("opencensus"), CollectorProtocol::OpenTelemetry => Some("opentelemetry"), }, } @@ -69,7 +67,6 @@ impl Config { self, identity: identity::NewClient, dns: dns::Resolver, - legacy_oc_metrics: opencensus::metrics::Registry, legacy_otel_metrics: opentelemetry::metrics::Registry, control_metrics: control::Metrics, client_metrics: HttpMetrics, @@ -87,14 +84,6 @@ impl Config { .unwrap_or_else(|| SERVICE_NAME.to_string()); let collector = match inner.kind { - CollectorProtocol::OpenCensus => oc_collector::create_collector( - addr.clone(), - inner.hostname, - svc_name, - inner.attributes, - svc, - legacy_oc_metrics, - ), CollectorProtocol::OpenTelemetry => { let attributes = OtelCollectorAttributes { hostname: inner.hostname, diff --git a/linkerd/app/src/trace_collector/oc_collector.rs b/linkerd/app/src/trace_collector/oc_collector.rs deleted file mode 100644 index d9afd0a063..0000000000 --- a/linkerd/app/src/trace_collector/oc_collector.rs +++ /dev/null @@ -1,57 +0,0 @@ -use crate::trace_collector::EnabledCollector; -use linkerd_app_core::{ - control::ControlAddr, http_tracing::CollectorProtocol, proxy::http::Body, Error, -}; -use linkerd_opencensus::{self as opencensus, metrics, proto}; -use std::{collections::HashMap, time::SystemTime}; -use tokio::sync::mpsc; -use tokio_stream::wrappers::ReceiverStream; -use tonic::{body::Body as TonicBody, client::GrpcService}; -use tracing::Instrument; - -pub(super) fn create_collector( - addr: ControlAddr, - hostname: Option, - service_name: String, - attributes: HashMap, - svc: S, - legacy_metrics: metrics::Registry, -) -> EnabledCollector -where - S: GrpcService + Clone + Send + 'static, - S::Error: Into, - S::Future: Send, - S::ResponseBody: Body + Send + 'static, - ::Error: Into + Send, -{ - let (span_sink, spans_rx) = mpsc::channel(crate::trace_collector::SPAN_BUFFER_CAPACITY); - let spans_rx = ReceiverStream::new(spans_rx); - - let task = { - use self::proto::agent::common::v1 as oc; - - let node = oc::Node { - identifier: Some(oc::ProcessIdentifier { - host_name: hostname.unwrap_or_default(), - pid: std::process::id(), - start_timestamp: Some(SystemTime::now().into()), - }), - service_info: Some(oc::ServiceInfo { name: service_name }), - attributes, - ..oc::Node::default() - }; - - let addr = addr.clone(); - Box::pin( - opencensus::export_spans(svc, node, spans_rx, legacy_metrics) - .instrument(tracing::debug_span!("opencensus", peer.addr = %addr).or_current()), - ) - }; - - EnabledCollector { - addr, - task, - span_sink, - kind: CollectorProtocol::OpenCensus, - } -} diff --git a/linkerd/opencensus/Cargo.toml b/linkerd/opencensus/Cargo.toml deleted file mode 100644 index feb89f7076..0000000000 --- a/linkerd/opencensus/Cargo.toml +++ /dev/null @@ -1,22 +0,0 @@ -[package] -name = "linkerd-opencensus" -version = { workspace = true } -authors = { workspace = true } -license = { workspace = true } -edition = { workspace = true } -publish = { workspace = true } - -[dependencies] -futures = { version = "0.3", default-features = false } -http-body = { workspace = true } -linkerd-error = { path = "../error" } -linkerd-metrics = { path = "../metrics" } -linkerd-trace-context = { path = "../trace-context" } -opencensus-proto = { path = "../../opencensus-proto" } -tonic = { workspace = true, default-features = false, features = [ - "prost", - "codegen", -] } -tokio = { version = "1", features = ["macros", "sync", "time"] } -tokio-stream = { version = "0.1", features = ["sync"] } -tracing = { workspace = true } diff --git a/linkerd/opencensus/src/lib.rs b/linkerd/opencensus/src/lib.rs deleted file mode 100644 index 894e9dd9c2..0000000000 --- a/linkerd/opencensus/src/lib.rs +++ /dev/null @@ -1,263 +0,0 @@ -#![deny(rust_2018_idioms, clippy::disallowed_methods, clippy::disallowed_types)] -#![forbid(unsafe_code)] - -pub mod metrics; - -use self::metrics::Registry; -use futures::stream::{Stream, StreamExt}; -use http_body::Body; -use linkerd_error::Error; -use linkerd_trace_context::export::{ExportSpan, SpanKind}; -pub use opencensus_proto as proto; -use opencensus_proto::{ - agent::{ - common::v1::Node, - trace::v1::{trace_service_client::TraceServiceClient, ExportTraceServiceRequest}, - }, - trace::v1::{Span, TruncatableString}, -}; -use std::collections::HashMap; -use tokio::{sync::mpsc, time}; -use tokio_stream::wrappers::ReceiverStream; -use tonic::{self as grpc, body::Body as TonicBody, client::GrpcService}; -use tracing::{debug, info, trace}; - -pub async fn export_spans(client: T, node: Node, spans: S, metrics: Registry) -where - T: GrpcService + Clone, - T::Error: Into, - T::ResponseBody: Body + Send + 'static, - ::Error: Into + Send, - S: Stream + Unpin, -{ - debug!("Span exporter running"); - SpanExporter::new(client, node, spans, metrics).run().await -} - -/// SpanExporter sends a Stream of spans to the given TraceService gRPC service. -struct SpanExporter { - client: T, - node: Node, - spans: S, - metrics: Registry, -} - -#[derive(Debug)] -struct SpanRxClosed; - -// === impl SpanExporter === - -impl SpanExporter -where - T: GrpcService, - T::Error: Into, - T::ResponseBody: Body + Send + 'static, - ::Error: Into + Send, - S: Stream + Unpin, -{ - const MAX_BATCH_SIZE: usize = 1000; - const MAX_BATCH_IDLE: time::Duration = time::Duration::from_secs(10); - - fn new(client: T, node: Node, spans: S, metrics: Registry) -> Self { - Self { - client, - node, - spans, - metrics, - } - } - - async fn run(self) { - let Self { - client, - node, - mut spans, - mut metrics, - } = self; - - // Holds the batch of pending spans. Cleared as the spans are flushed. - // Contains no more than MAX_BATCH_SIZE spans. - let mut accum = Vec::new(); - - let mut svc = TraceServiceClient::new(client); - loop { - trace!("Establishing new TraceService::export request"); - metrics.start_stream(); - let (tx, rx) = mpsc::channel(1); - - // The node is only transmitted on the first message of each stream. - let mut node = Some(node.clone()); - - // Drive both the response future and the export stream - // simultaneously. - tokio::select! { - res = svc.export(grpc::Request::new(ReceiverStream::new(rx))) => match res { - Ok(_rsp) => { - // The response future completed. Continue exporting spans until the - // stream stops accepting them. - if let Err(SpanRxClosed) = Self::export(&tx, &mut spans, &mut accum, &mut node).await { - // No more spans. - return; - } - } - Err(error) => { - debug!(%error, "Response future failed; restarting"); - } - }, - res = Self::export(&tx, &mut spans, &mut accum, &mut node) => match res { - // The export stream closed; reconnect. - Ok(()) => {}, - // No more spans. - Err(SpanRxClosed) => return, - }, - } - } - } - - /// Accumulate spans and send them on the export stream. - /// - /// Returns an error when the proxy has closed the span stream. - async fn export( - tx: &mpsc::Sender, - spans: &mut S, - accum: &mut Vec, - node: &mut Option, - ) -> Result<(), SpanRxClosed> { - loop { - // Collect spans into a batch. - let collect = Self::collect_batch(spans, accum).await; - - // If we collected spans, flush them. - if !accum.is_empty() { - // Once a batch has been accumulated, ensure that the - // request stream is ready to accept the batch. - match tx.reserve().await { - Ok(tx) => { - let msg = ExportTraceServiceRequest { - spans: std::mem::take(accum), - node: node.take(), - ..Default::default() - }; - trace!( - node = msg.node.is_some(), - spans = msg.spans.len(), - "Sending batch" - ); - tx.send(msg); - } - Err(error) => { - // If the channel isn't open, start a new stream - // and retry sending the batch. - debug!(%error, "Request stream lost; restarting"); - return Ok(()); - } - } - } - - // If the span source was closed, end the task. - if let Err(closed) = collect { - debug!("Span channel lost"); - return Err(closed); - } - } - } - - /// Collects spans from the proxy into `accum`. - /// - /// Returns an error when the span sream has completed. An error may be - /// returned after accumulating spans. - async fn collect_batch(spans: &mut S, accum: &mut Vec) -> Result<(), SpanRxClosed> { - loop { - if accum.len() == Self::MAX_BATCH_SIZE { - trace!(capacity = Self::MAX_BATCH_SIZE, "Batch capacity reached"); - return Ok(()); - } - - tokio::select! { - biased; - - res = spans.next() => match res { - Some(span) => { - trace!(?span, "Adding to batch"); - let span = match convert_span(span) { - Ok(span) => span, - Err(error) => { - info!(%error, "Span dropped"); - continue; - } - }; - accum.push(span); - } - None => return Err(SpanRxClosed), - }, - - // Don't hold spans indefinitely. Return if we hit an idle - // timeout and spans have been collected. - _ = time::sleep(Self::MAX_BATCH_IDLE) => { - if !accum.is_empty() { - trace!(spans = accum.len(), "Flushing spans due to inactivitiy"); - return Ok(()); - } - } - } - } - } -} - -fn convert_span(span: ExportSpan) -> Result { - use proto::trace::v1 as oc; - - let ExportSpan { - mut span, - kind, - labels, - } = span; - - let mut attributes = HashMap::::new(); - for (k, v) in labels.iter() { - attributes.insert( - k.clone(), - oc::AttributeValue { - value: Some(oc::attribute_value::Value::StringValue(truncatable( - v.clone(), - ))), - }, - ); - } - for (k, v) in span.labels.drain() { - attributes.insert( - k.to_string(), - oc::AttributeValue { - value: Some(oc::attribute_value::Value::StringValue(truncatable(v))), - }, - ); - } - Ok(Span { - trace_id: span.trace_id.into_bytes::<16>()?.to_vec(), - span_id: span.span_id.into_bytes::<8>()?.to_vec(), - tracestate: None, - parent_span_id: span.parent_id.into_bytes::<8>()?.to_vec(), - name: Some(truncatable(span.span_name)), - kind: kind as i32, - start_time: Some(span.start.into()), - end_time: Some(span.end.into()), - attributes: Some(oc::span::Attributes { - attribute_map: attributes, - dropped_attributes_count: 0, - }), - stack_trace: None, - time_events: None, - links: None, - status: None, // TODO: this is gRPC status; we must read response trailers to populate this - resource: None, - same_process_as_parent_span: Some(kind == SpanKind::Client), - child_span_count: None, - }) -} - -fn truncatable(value: String) -> TruncatableString { - TruncatableString { - value, - truncated_byte_count: 0, - } -} diff --git a/linkerd/opencensus/src/metrics.rs b/linkerd/opencensus/src/metrics.rs deleted file mode 100644 index c2af2061d4..0000000000 --- a/linkerd/opencensus/src/metrics.rs +++ /dev/null @@ -1,61 +0,0 @@ -use linkerd_metrics::{ - legacy::{Counter, FmtMetrics}, - metrics, -}; -use std::fmt; -use std::sync::Arc; - -metrics! { - opencensus_span_export_streams: Counter { "Total count of opened span export streams" }, - opencensus_span_export_requests: Counter { "Total count of span export request messages" }, - opencensus_span_exports: Counter { "Total count of spans exported" } -} - -#[derive(Debug)] -struct Metrics { - streams: Counter, - requests: Counter, - spans: Counter, -} - -#[derive(Clone, Debug)] -pub struct Registry(Arc); - -#[derive(Clone, Debug)] -pub struct Report(Arc); - -pub fn new() -> (Registry, Report) { - let metrics = Metrics { - streams: Counter::default(), - requests: Counter::default(), - spans: Counter::default(), - }; - let shared = Arc::new(metrics); - (Registry(shared.clone()), Report(shared)) -} - -impl Registry { - pub fn start_stream(&mut self) { - self.0.streams.incr() - } - - pub fn send(&mut self, spans: u64) { - self.0.requests.incr(); - self.0.spans.add(spans); - } -} - -impl FmtMetrics for Report { - fn fmt_metrics(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - opencensus_span_export_streams.fmt_help(f)?; - opencensus_span_export_streams.fmt_metric(f, &self.0.streams)?; - - opencensus_span_export_requests.fmt_help(f)?; - opencensus_span_export_requests.fmt_metric(f, &self.0.requests)?; - - opencensus_span_exports.fmt_help(f)?; - opencensus_span_exports.fmt_metric(f, &self.0.spans)?; - - Ok(()) - } -} diff --git a/opencensus-proto/Cargo.toml b/opencensus-proto/Cargo.toml deleted file mode 100644 index fd6f58d5fb..0000000000 --- a/opencensus-proto/Cargo.toml +++ /dev/null @@ -1,29 +0,0 @@ -[package] -name = "opencensus-proto" -version = { workspace = true } -authors = ["The OpenCensus Authors"] -license = { workspace = true } -edition = { workspace = true } -publish = { workspace = true } -description = """ -gRPC bindings for OpenCensus. - -Vendored from https://github.com/census-instrumentation/opencensus-proto/. -""" - -[dependencies] -prost = { workspace = true } -prost-types = { workspace = true } - -[dependencies.tonic] -workspace = true -default-features = false -features = ["prost", "codegen"] - -[dev-dependencies.tonic-build] -workspace = true -default-features = false -features = ["prost"] - -[lib] -doctest = false diff --git a/opencensus-proto/README.md b/opencensus-proto/README.md deleted file mode 100644 index ecc0df994c..0000000000 --- a/opencensus-proto/README.md +++ /dev/null @@ -1,21 +0,0 @@ -# opencensus-proto - -This library mirrors parts of the -[`opencensus-proto`](https://github.com/census-instrumentation/opencensus-proto/) -repo, with the non-tracing and build-related components removed. - -## License - - Copyright 2019, OpenCensus Authors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/opencensus-proto/opencensus/proto/agent/common/v1/common.proto b/opencensus-proto/opencensus/proto/agent/common/v1/common.proto deleted file mode 100644 index 7684f61cd1..0000000000 --- a/opencensus-proto/opencensus/proto/agent/common/v1/common.proto +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright 2018, OpenCensus Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -// NOTE: This proto is experimental and is subject to change at this point. -// Please do not use it at the moment. - -package opencensus.proto.agent.common.v1; - -import "google/protobuf/timestamp.proto"; - -option java_multiple_files = true; -option java_package = "io.opencensus.proto.agent.common.v1"; -option java_outer_classname = "CommonProto"; - -option go_package = "github.com/census-instrumentation/opencensus-proto/gen-go/agent/common/v1"; - -option ruby_package = "OpenCensus.Proto.Agent.Common.V1"; - -// Identifier metadata of the Node that produces the span or tracing data. -// Note, this is not the metadata about the Node or service that is described by associated spans. -// In the future we plan to extend the identifier proto definition to support -// additional information (e.g cloud id, etc.) -message Node { - // Identifier that uniquely identifies a process within a VM/container. - ProcessIdentifier identifier = 1; - - // Information on the OpenCensus Library that initiates the stream. - LibraryInfo library_info = 2; - - // Additional information on service. - ServiceInfo service_info = 3; - - // Additional attributes. - map attributes = 4; - - // TODO(songya): Add more identifiers in the future as needed, like cloud - // identifiers. -} - -// Identifier that uniquely identifies a process within a VM/container. -message ProcessIdentifier { - - // The host name. Usually refers to the machine/container name. - // For example: os.Hostname() in Go, socket.gethostname() in Python. - string host_name = 1; - - // Process id. - uint32 pid = 2; - - // Start time of this ProcessIdentifier. Represented in epoch time. - google.protobuf.Timestamp start_timestamp = 3; -} - -// Information on OpenCensus Library. -message LibraryInfo { - - enum Language { - LANGUAGE_UNSPECIFIED = 0; - CPP = 1; - C_SHARP = 2; - ERLANG = 3; - GO_LANG = 4; - JAVA = 5; - NODE_JS = 6; - PHP = 7; - PYTHON = 8; - RUBY = 9; - WEB_JS = 10; - } - - // Language of OpenCensus Library. - Language language = 1; - - // Version of Agent exporter of Library. - string exporter_version = 2; - - // Version of OpenCensus Library. - string core_library_version = 3; -} - -// Additional service information. -message ServiceInfo { - - // Name of the service. - string name = 1; - - // TODO(songya): add more fields as needed. -} diff --git a/opencensus-proto/opencensus/proto/agent/trace/v1/trace_service.proto b/opencensus-proto/opencensus/proto/agent/trace/v1/trace_service.proto deleted file mode 100644 index 6d2dfd94f8..0000000000 --- a/opencensus-proto/opencensus/proto/agent/trace/v1/trace_service.proto +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright 2018, OpenCensus Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -// NOTE: This proto is experimental and is subject to change at this point. -// Please do not use it at the moment. - -package opencensus.proto.agent.trace.v1; - -import "opencensus/proto/agent/common/v1/common.proto"; -import "opencensus/proto/resource/v1/resource.proto"; -import "opencensus/proto/trace/v1/trace.proto"; -import "opencensus/proto/trace/v1/trace_config.proto"; - -option java_multiple_files = true; -option java_package = "io.opencensus.proto.agent.trace.v1"; -option java_outer_classname = "TraceServiceProto"; - -option go_package = "github.com/census-instrumentation/opencensus-proto/gen-go/agent/trace/v1"; - -option ruby_package = "OpenCensus.Proto.Agent.Trace.V1"; - -// Service that can be used to push spans and configs between one Application -// instrumented with OpenCensus and an agent, or between an agent and a -// central collector or config service (in this case spans and configs are -// sent/received to/from multiple Applications). -service TraceService { - // After initialization, this RPC must be kept alive for the entire life of - // the application. The agent pushes configs down to applications via a - // stream. - rpc Config(stream CurrentLibraryConfig) returns (stream UpdatedLibraryConfig) {} - - // For performance reasons, it is recommended to keep this RPC - // alive for the entire life of the application. - rpc Export(stream ExportTraceServiceRequest) returns (stream ExportTraceServiceResponse) {} -} - -message CurrentLibraryConfig { - // This is required only in the first message on the stream or if the - // previous sent CurrentLibraryConfig message has a different Node (e.g. - // when the same RPC is used to configure multiple Applications). - opencensus.proto.agent.common.v1.Node node = 1; - - // Current configuration. - opencensus.proto.trace.v1.TraceConfig config = 2; -} - -message UpdatedLibraryConfig { - // This field is ignored when the RPC is used to configure only one Application. - // This is required only in the first message on the stream or if the - // previous sent UpdatedLibraryConfig message has a different Node. - opencensus.proto.agent.common.v1.Node node = 1; - - // Requested updated configuration. - opencensus.proto.trace.v1.TraceConfig config = 2; -} - -message ExportTraceServiceRequest { - // This is required only in the first message on the stream or if the - // previous sent ExportTraceServiceRequest message has a different Node (e.g. - // when the same RPC is used to send Spans from multiple Applications). - opencensus.proto.agent.common.v1.Node node = 1; - - // A list of Spans that belong to the last received Node. - repeated opencensus.proto.trace.v1.Span spans = 2; - - // The resource for the spans in this message that do not have an explicit - // resource set. - // If unset, the most recently set resource in the RPC stream applies. It is - // valid to never be set within a stream, e.g. when no resource info is known. - opencensus.proto.resource.v1.Resource resource = 3; -} - -message ExportTraceServiceResponse { -} diff --git a/opencensus-proto/opencensus/proto/agent/trace/v1/trace_service_http.yaml b/opencensus-proto/opencensus/proto/agent/trace/v1/trace_service_http.yaml deleted file mode 100644 index f2f254a05c..0000000000 --- a/opencensus-proto/opencensus/proto/agent/trace/v1/trace_service_http.yaml +++ /dev/null @@ -1,9 +0,0 @@ -# This is an API configuration to generate an HTTP/JSON -> gRPC gateway for the -# OpenCensus service using github.com/grpc-ecosystem/grpc-gateway. -type: google.api.Service -config_version: 3 -http: - rules: - - selector: opencensus.proto.agent.trace.v1.TraceService.Export - post: /v1/trace - body: "*" diff --git a/opencensus-proto/opencensus/proto/resource/v1/resource.proto b/opencensus-proto/opencensus/proto/resource/v1/resource.proto deleted file mode 100644 index 3303db7384..0000000000 --- a/opencensus-proto/opencensus/proto/resource/v1/resource.proto +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2018, OpenCensus Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package opencensus.proto.resource.v1; - -option go_package = "github.com/census-instrumentation/opencensus-proto/gen-go/resource/v1"; - -option java_multiple_files = true; -option java_package = "io.opencensus.proto.resource.v1"; -option java_outer_classname = "ResourceProto"; - -option ruby_package = "OpenCensus.Proto.Resource.V1"; - -// Resource information. -message Resource { - - // Type identifier for the resource. - string type = 1; - - // Set of labels that describe the resource. - map labels = 2; -} diff --git a/opencensus-proto/opencensus/proto/trace/v1/trace.proto b/opencensus-proto/opencensus/proto/trace/v1/trace.proto deleted file mode 100644 index 078d13a8ab..0000000000 --- a/opencensus-proto/opencensus/proto/trace/v1/trace.proto +++ /dev/null @@ -1,422 +0,0 @@ -// Copyright 2017, OpenCensus Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package opencensus.proto.trace.v1; - -import "opencensus/proto/resource/v1/resource.proto"; -import "google/protobuf/timestamp.proto"; -import "google/protobuf/wrappers.proto"; - -option java_multiple_files = true; -option java_package = "io.opencensus.proto.trace.v1"; -option java_outer_classname = "TraceProto"; - -option go_package = "github.com/census-instrumentation/opencensus-proto/gen-go/trace/v1"; - -option ruby_package = "OpenCensus.Proto.Trace.V1"; - -// A span represents a single operation within a trace. Spans can be -// nested to form a trace tree. Spans may also be linked to other spans -// from the same or different trace. And form graphs. Often, a trace -// contains a root span that describes the end-to-end latency, and one -// or more subspans for its sub-operations. A trace can also contain -// multiple root spans, or none at all. Spans do not need to be -// contiguous - there may be gaps or overlaps between spans in a trace. -// -// The next id is 17. -// TODO(bdrutu): Add an example. -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 - // is considered invalid. - // - // This field is semantically required. Receiver should generate new - // random trace_id if empty or invalid trace_id was received. - // - // 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 is considered - // invalid. - // - // This field is semantically required. Receiver should generate new - // random span_id if empty or invalid span_id was received. - // - // This field is required. - bytes span_id = 2; - - // This field conveys information about request position in multiple distributed tracing graphs. - // It is a list of Tracestate.Entry with a maximum of 32 members in the list. - // - // See the https://github.com/w3c/distributed-tracing for more details about this field. - message Tracestate { - message Entry { - // The key must begin with a lowercase letter, and can only contain - // lowercase letters 'a'-'z', digits '0'-'9', underscores '_', dashes - // '-', asterisks '*', and forward slashes '/'. - string key = 1; - - // The value is opaque string up to 256 characters printable ASCII - // RFC0020 characters (i.e., the range 0x20 to 0x7E) except ',' and '='. - // Note that this also excludes tabs, newlines, carriage returns, etc. - string value = 2; - } - - // A list of entries that represent the Tracestate. - repeated Entry entries = 1; - } - - // The Tracestate on the span. - Tracestate tracestate = 15; - - // 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 = 3; - - // 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. - // When null or empty string received - receiver may use string "name" - // as a replacement. There might be smarted algorithms implemented by - // receiver to fix the empty span name. - // - // This field is required. - TruncatableString name = 4; - - // Type of span. Can be used to specify additional relationships between spans - // in addition to a parent/child relationship. - enum SpanKind { - // Unspecified. - SPAN_KIND_UNSPECIFIED = 0; - - // Indicates that the span covers server-side handling of an RPC or other - // remote network request. - SERVER = 1; - - // Indicates that the span covers the client-side wrapper around an RPC or - // other remote request. - CLIENT = 2; - } - - // 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 = 14; - - // 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. - // - // This field is semantically required. When not set on receive - - // receiver should set it to the value of end_time field if it was - // set. Or to the current time if neither was set. It is important to - // keep end_time > start_time for consistency. - // - // This field is required. - google.protobuf.Timestamp start_time = 5; - - // 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. - // - // This field is semantically required. When not set on receive - - // receiver should set it to start_time value. It is important to - // keep end_time > start_time for consistency. - // - // This field is required. - google.protobuf.Timestamp end_time = 6; - - // A set of attributes, each with a key and a value. - message Attributes { - // The set of attributes. The value can be a string, an integer, a double - // or the Boolean values `true` or `false`. Note, global attributes like - // server name can be set as tags using 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 - // "abc.com/myattribute": true - // "abc.com/score": 10.239 - map attribute_map = 1; - - // 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. - int32 dropped_attributes_count = 2; - } - - // A set of attributes on the span. - Attributes attributes = 7; - - // A stack trace captured at the start of the span. - StackTrace stack_trace = 8; - - // A time-stamped annotation or message event in the Span. - message TimeEvent { - // The time the event occurred. - google.protobuf.Timestamp time = 1; - - // A text annotation with a set of attributes. - message Annotation { - // A user-supplied message describing the event. - TruncatableString description = 1; - - // A set of attributes on the annotation. - Attributes attributes = 2; - } - - // An event describing a message sent/received between Spans. - message MessageEvent { - // Indicates whether the message was sent or received. - enum Type { - // Unknown event type. - TYPE_UNSPECIFIED = 0; - // Indicates a sent message. - SENT = 1; - // Indicates a received message. - RECEIVED = 2; - } - - // The type of MessageEvent. Indicates whether the message was sent or - // received. - Type type = 1; - - // An identifier for the MessageEvent's message that can be used to match - // SENT and RECEIVED MessageEvents. For example, this field could - // represent a sequence ID for a streaming RPC. It is recommended to be - // unique within a Span. - uint64 id = 2; - - // The number of uncompressed bytes sent or received. - uint64 uncompressed_size = 3; - - // The number of compressed bytes sent or received. If zero, assumed to - // be the same size as uncompressed. - uint64 compressed_size = 4; - } - - // A `TimeEvent` can contain either an `Annotation` object or a - // `MessageEvent` object, but not both. - oneof value { - // A text annotation with a set of attributes. - Annotation annotation = 2; - - // An event describing a message sent/received between Spans. - MessageEvent message_event = 3; - } - } - - // A collection of `TimeEvent`s. A `TimeEvent` is a time-stamped annotation - // on the span, consisting of either user-supplied key-value pairs, or - // details of a message sent/received between Spans. - message TimeEvents { - // A collection of `TimeEvent`s. - repeated TimeEvent time_event = 1; - - // The number of dropped annotations in all the included time events. - // If the value is 0, then no annotations were dropped. - int32 dropped_annotations_count = 2; - - // The number of dropped message events in all the included time events. - // If the value is 0, then no message events were dropped. - int32 dropped_message_events_count = 3; - } - - // The included time events. - TimeEvents time_events = 9; - - // 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 relationship of the current span relative to the linked span: child, - // parent, or unspecified. - enum Type { - // The relationship of the two spans is unknown, or known but other - // than parent-child. - TYPE_UNSPECIFIED = 0; - // The linked span is a child of the current span. - CHILD_LINKED_SPAN = 1; - // The linked span is a parent of the current span. - PARENT_LINKED_SPAN = 2; - } - - // The relationship of the current span relative to the linked span. - Type type = 3; - - // A set of attributes on the link. - Attributes attributes = 4; - - // The Tracestate associated with the link. - Tracestate tracestate = 5; - } - - // A collection of links, which are references from this span to a span - // in the same or different trace. - message Links { - // A collection of links. - repeated Link link = 1; - - // The number of dropped links after the maximum size was enforced. If - // this value is 0, then no links were dropped. - int32 dropped_links_count = 2; - } - - // The included links. - Links links = 10; - - // An optional final status for this span. Semantically when Status - // wasn't set it is means span ended without errors and assume - // Status.Ok (code = 0). - Status status = 11; - - // An optional resource that is associated with this span. If not set, this span - // should be part of a batch that does include the resource information, unless resource - // information is unknown. - opencensus.proto.resource.v1.Resource resource = 16; - - // A highly recommended but not required flag that identifies when a - // trace crosses a process boundary. True when the parent_span belongs - // to the same process as the current span. This flag is most commonly - // used to indicate the need to adjust time as clocks in different - // processes may not be synchronized. - google.protobuf.BoolValue same_process_as_parent_span = 12; - - // An optional number of child spans that were generated while this span - // was active. If set, allows an implementation to detect missing child spans. - google.protobuf.UInt32Value child_span_count = 13; -} - -// The `Status` type defines a logical error model that is suitable for different -// programming environments, including REST APIs and RPC APIs. This proto's fields -// are a subset of those of -// [google.rpc.Status](https://github.com/googleapis/googleapis/blob/master/google/rpc/status.proto), -// which is used by [gRPC](https://github.com/grpc). -message Status { - // The status code. This is optional field. It is safe to assume 0 (OK) - // when not set. - int32 code = 1; - - // A developer-facing error message, which should be in English. - string message = 2; -} - -// The value of an Attribute. -message AttributeValue { - // The type of the value. - oneof value { - // A string up to 256 bytes long. - TruncatableString string_value = 1; - // A 64-bit signed integer. - int64 int_value = 2; - // A Boolean value represented by `true` or `false`. - bool bool_value = 3; - // A double value. - double double_value = 4; - } -} - -// The call stack which originated this span. -message StackTrace { - // A single stack frame in a stack trace. - message StackFrame { - // The fully-qualified name that uniquely identifies the function or - // method that is active in this frame. - TruncatableString function_name = 1; - // An un-mangled function name, if `function_name` is - // [mangled](http://www.avabodh.com/cxxin/namemangling.html). The name can - // be fully qualified. - TruncatableString original_function_name = 2; - // The name of the source file where the function call appears. - TruncatableString file_name = 3; - // The line number in `file_name` where the function call appears. - int64 line_number = 4; - // The column number where the function call appears, if available. - // This is important in JavaScript because of its anonymous functions. - int64 column_number = 5; - // The binary module from where the code was loaded. - Module load_module = 6; - // The version of the deployed source code. - TruncatableString source_version = 7; - } - - // A collection of stack frames, which can be truncated. - message StackFrames { - // Stack frames in this call stack. - repeated StackFrame frame = 1; - // The number of stack frames that were dropped because there - // were too many stack frames. - // If this value is 0, then no stack frames were dropped. - int32 dropped_frames_count = 2; - } - - // Stack frames in this stack trace. - StackFrames stack_frames = 1; - - // The hash ID is used to conserve network bandwidth for duplicate - // stack traces within a single trace. - // - // Often multiple spans will have identical stack traces. - // The first occurrence of a stack trace should contain both - // `stack_frames` and a value in `stack_trace_hash_id`. - // - // Subsequent spans within the same request can refer - // to that stack trace by setting only `stack_trace_hash_id`. - // - // TODO: describe how to deal with the case where stack_trace_hash_id is - // zero because it was not set. - uint64 stack_trace_hash_id = 2; -} - -// A description of a binary module. -message Module { - // TODO: document the meaning of this field. - // For example: main binary, kernel modules, and dynamic libraries - // such as libc.so, sharedlib.so. - TruncatableString module = 1; - - // A unique identifier for the module, usually a hash of its - // contents. - TruncatableString build_id = 2; -} - -// A string that might be shortened to a specified length. -message TruncatableString { - // The shortened string. For example, if the original string was 500 bytes long and - // the limit of the string was 128 bytes, then this value contains the first 128 - // bytes of the 500-byte string. Note that truncation always happens on a - // character boundary, to ensure that a truncated string is still valid UTF-8. - // Because it may contain multi-byte characters, the size of the truncated string - // may be less than the truncation limit. - string value = 1; - - // The number of bytes removed from the original string. If this - // value is 0, then the string was not shortened. - int32 truncated_byte_count = 2; -} diff --git a/opencensus-proto/opencensus/proto/trace/v1/trace_config.proto b/opencensus-proto/opencensus/proto/trace/v1/trace_config.proto deleted file mode 100644 index cb6ccb916d..0000000000 --- a/opencensus-proto/opencensus/proto/trace/v1/trace_config.proto +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2018, OpenCensus Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package opencensus.proto.trace.v1; - -option java_multiple_files = true; -option java_package = "io.opencensus.proto.trace.v1"; -option java_outer_classname = "TraceConfigProto"; - -option go_package = "github.com/census-instrumentation/opencensus-proto/gen-go/trace/v1"; - -option ruby_package = "OpenCensus.Proto.Trace.V1"; - -// Global configuration of the trace service. All fields must be specified, or -// the default (zero) values will be used for each type. -message TraceConfig { - - // The global default sampler used to make decisions on span sampling. - oneof sampler { - ProbabilitySampler probability_sampler = 1; - - ConstantSampler constant_sampler = 2; - - RateLimitingSampler rate_limiting_sampler = 3; - } - - // The global default max number of attributes per span. - int64 max_number_of_attributes = 4; - - // The global default max number of annotation events per span. - int64 max_number_of_annotations = 5; - - // The global default max number of message events per span. - int64 max_number_of_message_events = 6; - - // The global default max number of link entries per span. - int64 max_number_of_links = 7; -} - -// Sampler that tries to uniformly sample traces with a given probability. -// The probability of sampling a trace is equal to that of the specified probability. -message ProbabilitySampler { - - // The desired probability of sampling. Must be within [0.0, 1.0]. - double samplingProbability = 1; -} - -// Sampler that always makes a constant decision on span sampling. -message ConstantSampler { - - // How spans should be sampled: - // - Always off - // - Always on - // - Always follow the parent Span's decision (off if no parent). - enum ConstantDecision { - ALWAYS_OFF = 0; - ALWAYS_ON = 1; - ALWAYS_PARENT = 2; - } - ConstantDecision decision = 1; -} - -// Sampler that tries to sample with a rate per time window. -message RateLimitingSampler { - - // Rate per second. - int64 qps = 1; -} diff --git a/opencensus-proto/src/gen/google.protobuf.rs b/opencensus-proto/src/gen/google.protobuf.rs deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/opencensus-proto/src/gen/opencensus.proto.agent.common.v1.rs b/opencensus-proto/src/gen/opencensus.proto.agent.common.v1.rs deleted file mode 100644 index 879a28bc1b..0000000000 --- a/opencensus-proto/src/gen/opencensus.proto.agent.common.v1.rs +++ /dev/null @@ -1,123 +0,0 @@ -// This file is @generated by prost-build. -/// Identifier metadata of the Node that produces the span or tracing data. -/// Note, this is not the metadata about the Node or service that is described by associated spans. -/// In the future we plan to extend the identifier proto definition to support -/// additional information (e.g cloud id, etc.) -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Node { - /// Identifier that uniquely identifies a process within a VM/container. - #[prost(message, optional, tag = "1")] - pub identifier: ::core::option::Option, - /// Information on the OpenCensus Library that initiates the stream. - #[prost(message, optional, tag = "2")] - pub library_info: ::core::option::Option, - /// Additional information on service. - #[prost(message, optional, tag = "3")] - pub service_info: ::core::option::Option, - /// Additional attributes. - #[prost(map = "string, string", tag = "4")] - pub attributes: ::std::collections::HashMap< - ::prost::alloc::string::String, - ::prost::alloc::string::String, - >, -} -/// Identifier that uniquely identifies a process within a VM/container. -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ProcessIdentifier { - /// The host name. Usually refers to the machine/container name. - /// For example: os.Hostname() in Go, socket.gethostname() in Python. - #[prost(string, tag = "1")] - pub host_name: ::prost::alloc::string::String, - /// Process id. - #[prost(uint32, tag = "2")] - pub pid: u32, - /// Start time of this ProcessIdentifier. Represented in epoch time. - #[prost(message, optional, tag = "3")] - pub start_timestamp: ::core::option::Option<::prost_types::Timestamp>, -} -/// Information on OpenCensus Library. -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct LibraryInfo { - /// Language of OpenCensus Library. - #[prost(enumeration = "library_info::Language", tag = "1")] - pub language: i32, - /// Version of Agent exporter of Library. - #[prost(string, tag = "2")] - pub exporter_version: ::prost::alloc::string::String, - /// Version of OpenCensus Library. - #[prost(string, tag = "3")] - pub core_library_version: ::prost::alloc::string::String, -} -/// Nested message and enum types in `LibraryInfo`. -pub mod library_info { - #[derive( - Clone, - Copy, - Debug, - PartialEq, - Eq, - Hash, - PartialOrd, - Ord, - ::prost::Enumeration - )] - #[repr(i32)] - pub enum Language { - Unspecified = 0, - Cpp = 1, - CSharp = 2, - Erlang = 3, - GoLang = 4, - Java = 5, - NodeJs = 6, - Php = 7, - Python = 8, - Ruby = 9, - WebJs = 10, - } - impl Language { - /// 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 => "LANGUAGE_UNSPECIFIED", - Self::Cpp => "CPP", - Self::CSharp => "C_SHARP", - Self::Erlang => "ERLANG", - Self::GoLang => "GO_LANG", - Self::Java => "JAVA", - Self::NodeJs => "NODE_JS", - Self::Php => "PHP", - Self::Python => "PYTHON", - Self::Ruby => "RUBY", - Self::WebJs => "WEB_JS", - } - } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "LANGUAGE_UNSPECIFIED" => Some(Self::Unspecified), - "CPP" => Some(Self::Cpp), - "C_SHARP" => Some(Self::CSharp), - "ERLANG" => Some(Self::Erlang), - "GO_LANG" => Some(Self::GoLang), - "JAVA" => Some(Self::Java), - "NODE_JS" => Some(Self::NodeJs), - "PHP" => Some(Self::Php), - "PYTHON" => Some(Self::Python), - "RUBY" => Some(Self::Ruby), - "WEB_JS" => Some(Self::WebJs), - _ => None, - } - } - } -} -/// Additional service information. -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ServiceInfo { - /// Name of the service. - #[prost(string, tag = "1")] - pub name: ::prost::alloc::string::String, -} diff --git a/opencensus-proto/src/gen/opencensus.proto.agent.trace.v1.rs b/opencensus-proto/src/gen/opencensus.proto.agent.trace.v1.rs deleted file mode 100644 index 1b0294e700..0000000000 --- a/opencensus-proto/src/gen/opencensus.proto.agent.trace.v1.rs +++ /dev/null @@ -1,195 +0,0 @@ -// This file is @generated by prost-build. -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct CurrentLibraryConfig { - /// This is required only in the first message on the stream or if the - /// previous sent CurrentLibraryConfig message has a different Node (e.g. - /// when the same RPC is used to configure multiple Applications). - #[prost(message, optional, tag = "1")] - pub node: ::core::option::Option, - /// Current configuration. - #[prost(message, optional, tag = "2")] - pub config: ::core::option::Option, -} -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct UpdatedLibraryConfig { - /// This field is ignored when the RPC is used to configure only one Application. - /// This is required only in the first message on the stream or if the - /// previous sent UpdatedLibraryConfig message has a different Node. - #[prost(message, optional, tag = "1")] - pub node: ::core::option::Option, - /// Requested updated configuration. - #[prost(message, optional, tag = "2")] - pub config: ::core::option::Option, -} -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ExportTraceServiceRequest { - /// This is required only in the first message on the stream or if the - /// previous sent ExportTraceServiceRequest message has a different Node (e.g. - /// when the same RPC is used to send Spans from multiple Applications). - #[prost(message, optional, tag = "1")] - pub node: ::core::option::Option, - /// A list of Spans that belong to the last received Node. - #[prost(message, repeated, tag = "2")] - pub spans: ::prost::alloc::vec::Vec, - /// The resource for the spans in this message that do not have an explicit - /// resource set. - /// If unset, the most recently set resource in the RPC stream applies. It is - /// valid to never be set within a stream, e.g. when no resource info is known. - #[prost(message, optional, tag = "3")] - pub resource: ::core::option::Option, -} -#[derive(Clone, Copy, PartialEq, ::prost::Message)] -pub struct ExportTraceServiceResponse {} -/// 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 and configs between one Application - /// instrumented with OpenCensus and an agent, or between an agent and a - /// central collector or config service (in this case spans and configs are - /// sent/received to/from multiple Applications). - #[derive(Debug, Clone)] - pub struct TraceServiceClient { - inner: tonic::client::Grpc, - } - impl TraceServiceClient - where - T: tonic::client::GrpcService, - T::Error: Into, - T::ResponseBody: Body + std::marker::Send + 'static, - ::Error: Into + 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( - inner: T, - interceptor: F, - ) -> TraceServiceClient> - where - F: tonic::service::Interceptor, - T::ResponseBody: Default, - T: tonic::codegen::Service< - http::Request, - Response = http::Response< - >::ResponseBody, - >, - >, - , - >>::Error: Into + 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 - } - /// After initialization, this RPC must be kept alive for the entire life of - /// the application. The agent pushes configs down to applications via a - /// stream. - pub async fn config( - &mut self, - request: impl tonic::IntoStreamingRequest< - Message = super::CurrentLibraryConfig, - >, - ) -> std::result::Result< - tonic::Response>, - 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( - "/opencensus.proto.agent.trace.v1.TraceService/Config", - ); - let mut req = request.into_streaming_request(); - req.extensions_mut() - .insert( - GrpcMethod::new( - "opencensus.proto.agent.trace.v1.TraceService", - "Config", - ), - ); - self.inner.streaming(req, path, codec).await - } - /// 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::IntoStreamingRequest< - Message = super::ExportTraceServiceRequest, - >, - ) -> std::result::Result< - tonic::Response>, - 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( - "/opencensus.proto.agent.trace.v1.TraceService/Export", - ); - let mut req = request.into_streaming_request(); - req.extensions_mut() - .insert( - GrpcMethod::new( - "opencensus.proto.agent.trace.v1.TraceService", - "Export", - ), - ); - self.inner.streaming(req, path, codec).await - } - } -} diff --git a/opencensus-proto/src/gen/opencensus.proto.resource.v1.rs b/opencensus-proto/src/gen/opencensus.proto.resource.v1.rs deleted file mode 100644 index fb57bed51e..0000000000 --- a/opencensus-proto/src/gen/opencensus.proto.resource.v1.rs +++ /dev/null @@ -1,14 +0,0 @@ -// This file is @generated by prost-build. -/// Resource information. -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Resource { - /// Type identifier for the resource. - #[prost(string, tag = "1")] - pub r#type: ::prost::alloc::string::String, - /// Set of labels that describe the resource. - #[prost(map = "string, string", tag = "2")] - pub labels: ::std::collections::HashMap< - ::prost::alloc::string::String, - ::prost::alloc::string::String, - >, -} diff --git a/opencensus-proto/src/gen/opencensus.proto.trace.v1.rs b/opencensus-proto/src/gen/opencensus.proto.trace.v1.rs deleted file mode 100644 index e52c2e86cc..0000000000 --- a/opencensus-proto/src/gen/opencensus.proto.trace.v1.rs +++ /dev/null @@ -1,651 +0,0 @@ -// This file is @generated by prost-build. -/// A span represents a single operation within a trace. Spans can be -/// nested to form a trace tree. Spans may also be linked to other spans -/// from the same or different trace. And form graphs. Often, a trace -/// contains a root span that describes the end-to-end latency, and one -/// or more subspans for its sub-operations. A trace can also contain -/// multiple root spans, or none at all. Spans do not need to be -/// contiguous - there may be gaps or overlaps between spans in a trace. -/// -/// The next id is 17. -/// TODO(bdrutu): Add an example. -#[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 - /// is considered invalid. - /// - /// This field is semantically required. Receiver should generate new - /// random trace_id if empty or invalid trace_id was received. - /// - /// This field is required. - #[prost(bytes = "vec", tag = "1")] - pub trace_id: ::prost::alloc::vec::Vec, - /// 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 is considered - /// invalid. - /// - /// This field is semantically required. Receiver should generate new - /// random span_id if empty or invalid span_id was received. - /// - /// This field is required. - #[prost(bytes = "vec", tag = "2")] - pub span_id: ::prost::alloc::vec::Vec, - /// The Tracestate on the span. - #[prost(message, optional, tag = "15")] - pub tracestate: ::core::option::Option, - /// 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 = "3")] - pub parent_span_id: ::prost::alloc::vec::Vec, - /// 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. - /// When null or empty string received - receiver may use string "name" - /// as a replacement. There might be smarted algorithms implemented by - /// receiver to fix the empty span name. - /// - /// This field is required. - #[prost(message, optional, tag = "4")] - pub name: ::core::option::Option, - /// 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 = "14")] - pub kind: i32, - /// 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. - /// - /// This field is semantically required. When not set on receive - - /// receiver should set it to the value of end_time field if it was - /// set. Or to the current time if neither was set. It is important to - /// keep end_time > start_time for consistency. - /// - /// This field is required. - #[prost(message, optional, tag = "5")] - pub start_time: ::core::option::Option<::prost_types::Timestamp>, - /// 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. - /// - /// This field is semantically required. When not set on receive - - /// receiver should set it to start_time value. It is important to - /// keep end_time > start_time for consistency. - /// - /// This field is required. - #[prost(message, optional, tag = "6")] - pub end_time: ::core::option::Option<::prost_types::Timestamp>, - /// A set of attributes on the span. - #[prost(message, optional, tag = "7")] - pub attributes: ::core::option::Option, - /// A stack trace captured at the start of the span. - #[prost(message, optional, tag = "8")] - pub stack_trace: ::core::option::Option, - /// The included time events. - #[prost(message, optional, tag = "9")] - pub time_events: ::core::option::Option, - /// The included links. - #[prost(message, optional, tag = "10")] - pub links: ::core::option::Option, - /// An optional final status for this span. Semantically when Status - /// wasn't set it is means span ended without errors and assume - /// Status.Ok (code = 0). - #[prost(message, optional, tag = "11")] - pub status: ::core::option::Option, - /// An optional resource that is associated with this span. If not set, this span - /// should be part of a batch that does include the resource information, unless resource - /// information is unknown. - #[prost(message, optional, tag = "16")] - pub resource: ::core::option::Option, - /// A highly recommended but not required flag that identifies when a - /// trace crosses a process boundary. True when the parent_span belongs - /// to the same process as the current span. This flag is most commonly - /// used to indicate the need to adjust time as clocks in different - /// processes may not be synchronized. - #[prost(message, optional, tag = "12")] - pub same_process_as_parent_span: ::core::option::Option, - /// An optional number of child spans that were generated while this span - /// was active. If set, allows an implementation to detect missing child spans. - #[prost(message, optional, tag = "13")] - pub child_span_count: ::core::option::Option, -} -/// Nested message and enum types in `Span`. -pub mod span { - /// This field conveys information about request position in multiple distributed tracing graphs. - /// It is a list of Tracestate.Entry with a maximum of 32 members in the list. - /// - /// See the for more details about this field. - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct Tracestate { - /// A list of entries that represent the Tracestate. - #[prost(message, repeated, tag = "1")] - pub entries: ::prost::alloc::vec::Vec, - } - /// Nested message and enum types in `Tracestate`. - pub mod tracestate { - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct Entry { - /// The key must begin with a lowercase letter, and can only contain - /// lowercase letters 'a'-'z', digits '0'-'9', underscores '_', dashes - /// '-', asterisks '*', and forward slashes '/'. - #[prost(string, tag = "1")] - pub key: ::prost::alloc::string::String, - /// The value is opaque string up to 256 characters printable ASCII - /// RFC0020 characters (i.e., the range 0x20 to 0x7E) except ',' and '='. - /// Note that this also excludes tabs, newlines, carriage returns, etc. - #[prost(string, tag = "2")] - pub value: ::prost::alloc::string::String, - } - } - /// A set of attributes, each with a key and a value. - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct Attributes { - /// The set of attributes. The value can be a string, an integer, a double - /// or the Boolean values `true` or `false`. Note, global attributes like - /// server name can be set as tags using 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 - /// "abc.com/myattribute": true - /// "abc.com/score": 10.239 - #[prost(map = "string, message", tag = "1")] - pub attribute_map: ::std::collections::HashMap< - ::prost::alloc::string::String, - super::AttributeValue, - >, - /// 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(int32, tag = "2")] - pub dropped_attributes_count: i32, - } - /// A time-stamped annotation or message event in the Span. - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct TimeEvent { - /// The time the event occurred. - #[prost(message, optional, tag = "1")] - pub time: ::core::option::Option<::prost_types::Timestamp>, - /// A `TimeEvent` can contain either an `Annotation` object or a - /// `MessageEvent` object, but not both. - #[prost(oneof = "time_event::Value", tags = "2, 3")] - pub value: ::core::option::Option, - } - /// Nested message and enum types in `TimeEvent`. - pub mod time_event { - /// A text annotation with a set of attributes. - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct Annotation { - /// A user-supplied message describing the event. - #[prost(message, optional, tag = "1")] - pub description: ::core::option::Option, - /// A set of attributes on the annotation. - #[prost(message, optional, tag = "2")] - pub attributes: ::core::option::Option, - } - /// An event describing a message sent/received between Spans. - #[derive(Clone, Copy, PartialEq, ::prost::Message)] - pub struct MessageEvent { - /// The type of MessageEvent. Indicates whether the message was sent or - /// received. - #[prost(enumeration = "message_event::Type", tag = "1")] - pub r#type: i32, - /// An identifier for the MessageEvent's message that can be used to match - /// SENT and RECEIVED MessageEvents. For example, this field could - /// represent a sequence ID for a streaming RPC. It is recommended to be - /// unique within a Span. - #[prost(uint64, tag = "2")] - pub id: u64, - /// The number of uncompressed bytes sent or received. - #[prost(uint64, tag = "3")] - pub uncompressed_size: u64, - /// The number of compressed bytes sent or received. If zero, assumed to - /// be the same size as uncompressed. - #[prost(uint64, tag = "4")] - pub compressed_size: u64, - } - /// Nested message and enum types in `MessageEvent`. - pub mod message_event { - /// Indicates whether the message was sent or received. - #[derive( - Clone, - Copy, - Debug, - PartialEq, - Eq, - Hash, - PartialOrd, - Ord, - ::prost::Enumeration - )] - #[repr(i32)] - pub enum Type { - /// Unknown event type. - Unspecified = 0, - /// Indicates a sent message. - Sent = 1, - /// Indicates a received message. - Received = 2, - } - impl Type { - /// 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 => "TYPE_UNSPECIFIED", - Self::Sent => "SENT", - Self::Received => "RECEIVED", - } - } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "TYPE_UNSPECIFIED" => Some(Self::Unspecified), - "SENT" => Some(Self::Sent), - "RECEIVED" => Some(Self::Received), - _ => None, - } - } - } - } - /// A `TimeEvent` can contain either an `Annotation` object or a - /// `MessageEvent` object, but not both. - #[derive(Clone, PartialEq, ::prost::Oneof)] - pub enum Value { - /// A text annotation with a set of attributes. - #[prost(message, tag = "2")] - Annotation(Annotation), - /// An event describing a message sent/received between Spans. - #[prost(message, tag = "3")] - MessageEvent(MessageEvent), - } - } - /// A collection of `TimeEvent`s. A `TimeEvent` is a time-stamped annotation - /// on the span, consisting of either user-supplied key-value pairs, or - /// details of a message sent/received between Spans. - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct TimeEvents { - /// A collection of `TimeEvent`s. - #[prost(message, repeated, tag = "1")] - pub time_event: ::prost::alloc::vec::Vec, - /// The number of dropped annotations in all the included time events. - /// If the value is 0, then no annotations were dropped. - #[prost(int32, tag = "2")] - pub dropped_annotations_count: i32, - /// The number of dropped message events in all the included time events. - /// If the value is 0, then no message events were dropped. - #[prost(int32, tag = "3")] - pub dropped_message_events_count: i32, - } - /// 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, - /// 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, - /// The relationship of the current span relative to the linked span. - #[prost(enumeration = "link::Type", tag = "3")] - pub r#type: i32, - /// A set of attributes on the link. - #[prost(message, optional, tag = "4")] - pub attributes: ::core::option::Option, - /// The Tracestate associated with the link. - #[prost(message, optional, tag = "5")] - pub tracestate: ::core::option::Option, - } - /// Nested message and enum types in `Link`. - pub mod link { - /// The relationship of the current span relative to the linked span: child, - /// parent, or unspecified. - #[derive( - Clone, - Copy, - Debug, - PartialEq, - Eq, - Hash, - PartialOrd, - Ord, - ::prost::Enumeration - )] - #[repr(i32)] - pub enum Type { - /// The relationship of the two spans is unknown, or known but other - /// than parent-child. - Unspecified = 0, - /// The linked span is a child of the current span. - ChildLinkedSpan = 1, - /// The linked span is a parent of the current span. - ParentLinkedSpan = 2, - } - impl Type { - /// 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 => "TYPE_UNSPECIFIED", - Self::ChildLinkedSpan => "CHILD_LINKED_SPAN", - Self::ParentLinkedSpan => "PARENT_LINKED_SPAN", - } - } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "TYPE_UNSPECIFIED" => Some(Self::Unspecified), - "CHILD_LINKED_SPAN" => Some(Self::ChildLinkedSpan), - "PARENT_LINKED_SPAN" => Some(Self::ParentLinkedSpan), - _ => None, - } - } - } - } - /// A collection of links, which are references from this span to a span - /// in the same or different trace. - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct Links { - /// A collection of links. - #[prost(message, repeated, tag = "1")] - pub link: ::prost::alloc::vec::Vec, - /// The number of dropped links after the maximum size was enforced. If - /// this value is 0, then no links were dropped. - #[prost(int32, tag = "2")] - pub dropped_links_count: i32, - } - /// 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. - Unspecified = 0, - /// Indicates that the span covers server-side handling of an RPC or other - /// remote network request. - Server = 1, - /// Indicates that the span covers the client-side wrapper around an RPC or - /// other remote request. - Client = 2, - } - 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::Server => "SERVER", - Self::Client => "CLIENT", - } - } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "SPAN_KIND_UNSPECIFIED" => Some(Self::Unspecified), - "SERVER" => Some(Self::Server), - "CLIENT" => Some(Self::Client), - _ => None, - } - } - } -} -/// The `Status` type defines a logical error model that is suitable for different -/// programming environments, including REST APIs and RPC APIs. This proto's fields -/// are a subset of those of -/// [google.rpc.Status](), -/// which is used by [gRPC](). -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Status { - /// The status code. This is optional field. It is safe to assume 0 (OK) - /// when not set. - #[prost(int32, tag = "1")] - pub code: i32, - /// A developer-facing error message, which should be in English. - #[prost(string, tag = "2")] - pub message: ::prost::alloc::string::String, -} -/// The value of an Attribute. -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct AttributeValue { - /// The type of the value. - #[prost(oneof = "attribute_value::Value", tags = "1, 2, 3, 4")] - pub value: ::core::option::Option, -} -/// Nested message and enum types in `AttributeValue`. -pub mod attribute_value { - /// The type of the value. - #[derive(Clone, PartialEq, ::prost::Oneof)] - pub enum Value { - /// A string up to 256 bytes long. - #[prost(message, tag = "1")] - StringValue(super::TruncatableString), - /// A 64-bit signed integer. - #[prost(int64, tag = "2")] - IntValue(i64), - /// A Boolean value represented by `true` or `false`. - #[prost(bool, tag = "3")] - BoolValue(bool), - /// A double value. - #[prost(double, tag = "4")] - DoubleValue(f64), - } -} -/// The call stack which originated this span. -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct StackTrace { - /// Stack frames in this stack trace. - #[prost(message, optional, tag = "1")] - pub stack_frames: ::core::option::Option, - /// The hash ID is used to conserve network bandwidth for duplicate - /// stack traces within a single trace. - /// - /// Often multiple spans will have identical stack traces. - /// The first occurrence of a stack trace should contain both - /// `stack_frames` and a value in `stack_trace_hash_id`. - /// - /// Subsequent spans within the same request can refer - /// to that stack trace by setting only `stack_trace_hash_id`. - /// - /// TODO: describe how to deal with the case where stack_trace_hash_id is - /// zero because it was not set. - #[prost(uint64, tag = "2")] - pub stack_trace_hash_id: u64, -} -/// Nested message and enum types in `StackTrace`. -pub mod stack_trace { - /// A single stack frame in a stack trace. - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct StackFrame { - /// The fully-qualified name that uniquely identifies the function or - /// method that is active in this frame. - #[prost(message, optional, tag = "1")] - pub function_name: ::core::option::Option, - /// An un-mangled function name, if `function_name` is - /// [mangled](). The name can - /// be fully qualified. - #[prost(message, optional, tag = "2")] - pub original_function_name: ::core::option::Option, - /// The name of the source file where the function call appears. - #[prost(message, optional, tag = "3")] - pub file_name: ::core::option::Option, - /// The line number in `file_name` where the function call appears. - #[prost(int64, tag = "4")] - pub line_number: i64, - /// The column number where the function call appears, if available. - /// This is important in JavaScript because of its anonymous functions. - #[prost(int64, tag = "5")] - pub column_number: i64, - /// The binary module from where the code was loaded. - #[prost(message, optional, tag = "6")] - pub load_module: ::core::option::Option, - /// The version of the deployed source code. - #[prost(message, optional, tag = "7")] - pub source_version: ::core::option::Option, - } - /// A collection of stack frames, which can be truncated. - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct StackFrames { - /// Stack frames in this call stack. - #[prost(message, repeated, tag = "1")] - pub frame: ::prost::alloc::vec::Vec, - /// The number of stack frames that were dropped because there - /// were too many stack frames. - /// If this value is 0, then no stack frames were dropped. - #[prost(int32, tag = "2")] - pub dropped_frames_count: i32, - } -} -/// A description of a binary module. -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Module { - /// TODO: document the meaning of this field. - /// For example: main binary, kernel modules, and dynamic libraries - /// such as libc.so, sharedlib.so. - #[prost(message, optional, tag = "1")] - pub module: ::core::option::Option, - /// A unique identifier for the module, usually a hash of its - /// contents. - #[prost(message, optional, tag = "2")] - pub build_id: ::core::option::Option, -} -/// A string that might be shortened to a specified length. -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct TruncatableString { - /// The shortened string. For example, if the original string was 500 bytes long and - /// the limit of the string was 128 bytes, then this value contains the first 128 - /// bytes of the 500-byte string. Note that truncation always happens on a - /// character boundary, to ensure that a truncated string is still valid UTF-8. - /// Because it may contain multi-byte characters, the size of the truncated string - /// may be less than the truncation limit. - #[prost(string, tag = "1")] - pub value: ::prost::alloc::string::String, - /// The number of bytes removed from the original string. If this - /// value is 0, then the string was not shortened. - #[prost(int32, tag = "2")] - pub truncated_byte_count: i32, -} -/// Global configuration of the trace service. All fields must be specified, or -/// the default (zero) values will be used for each type. -#[derive(Clone, Copy, PartialEq, ::prost::Message)] -pub struct TraceConfig { - /// The global default max number of attributes per span. - #[prost(int64, tag = "4")] - pub max_number_of_attributes: i64, - /// The global default max number of annotation events per span. - #[prost(int64, tag = "5")] - pub max_number_of_annotations: i64, - /// The global default max number of message events per span. - #[prost(int64, tag = "6")] - pub max_number_of_message_events: i64, - /// The global default max number of link entries per span. - #[prost(int64, tag = "7")] - pub max_number_of_links: i64, - /// The global default sampler used to make decisions on span sampling. - #[prost(oneof = "trace_config::Sampler", tags = "1, 2, 3")] - pub sampler: ::core::option::Option, -} -/// Nested message and enum types in `TraceConfig`. -pub mod trace_config { - /// The global default sampler used to make decisions on span sampling. - #[derive(Clone, Copy, PartialEq, ::prost::Oneof)] - pub enum Sampler { - #[prost(message, tag = "1")] - ProbabilitySampler(super::ProbabilitySampler), - #[prost(message, tag = "2")] - ConstantSampler(super::ConstantSampler), - #[prost(message, tag = "3")] - RateLimitingSampler(super::RateLimitingSampler), - } -} -/// Sampler that tries to uniformly sample traces with a given probability. -/// The probability of sampling a trace is equal to that of the specified probability. -#[derive(Clone, Copy, PartialEq, ::prost::Message)] -pub struct ProbabilitySampler { - /// The desired probability of sampling. Must be within \[0.0, 1.0\]. - #[prost(double, tag = "1")] - pub sampling_probability: f64, -} -/// Sampler that always makes a constant decision on span sampling. -#[derive(Clone, Copy, PartialEq, ::prost::Message)] -pub struct ConstantSampler { - #[prost(enumeration = "constant_sampler::ConstantDecision", tag = "1")] - pub decision: i32, -} -/// Nested message and enum types in `ConstantSampler`. -pub mod constant_sampler { - /// How spans should be sampled: - /// - Always off - /// - Always on - /// - Always follow the parent Span's decision (off if no parent). - #[derive( - Clone, - Copy, - Debug, - PartialEq, - Eq, - Hash, - PartialOrd, - Ord, - ::prost::Enumeration - )] - #[repr(i32)] - pub enum ConstantDecision { - AlwaysOff = 0, - AlwaysOn = 1, - AlwaysParent = 2, - } - impl ConstantDecision { - /// 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::AlwaysOff => "ALWAYS_OFF", - Self::AlwaysOn => "ALWAYS_ON", - Self::AlwaysParent => "ALWAYS_PARENT", - } - } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "ALWAYS_OFF" => Some(Self::AlwaysOff), - "ALWAYS_ON" => Some(Self::AlwaysOn), - "ALWAYS_PARENT" => Some(Self::AlwaysParent), - _ => None, - } - } - } -} -/// Sampler that tries to sample with a rate per time window. -#[derive(Clone, Copy, PartialEq, ::prost::Message)] -pub struct RateLimitingSampler { - /// Rate per second. - #[prost(int64, tag = "1")] - pub qps: i64, -} diff --git a/opencensus-proto/src/lib.rs b/opencensus-proto/src/lib.rs deleted file mode 100644 index f12d5ba509..0000000000 --- a/opencensus-proto/src/lib.rs +++ /dev/null @@ -1,33 +0,0 @@ -//! gRPC bindings for OpenCensus. -//! -//! Vendored from . - -#![deny(rust_2018_idioms, clippy::disallowed_methods, clippy::disallowed_types)] -#![allow(clippy::derive_partial_eq_without_eq)] -#![forbid(unsafe_code)] - -pub mod agent { - pub mod trace { - pub mod v1 { - include!("gen/opencensus.proto.agent.trace.v1.rs"); - } - } - - pub mod common { - pub mod v1 { - include!("gen/opencensus.proto.agent.common.v1.rs"); - } - } -} - -pub mod trace { - pub mod v1 { - include!("gen/opencensus.proto.trace.v1.rs"); - } -} - -pub mod resource { - pub mod v1 { - include!("gen/opencensus.proto.resource.v1.rs"); - } -} diff --git a/opencensus-proto/tests/bootstrap.rs b/opencensus-proto/tests/bootstrap.rs deleted file mode 100644 index 7646236132..0000000000 --- a/opencensus-proto/tests/bootstrap.rs +++ /dev/null @@ -1,53 +0,0 @@ -//! A test that regenerates the Rust protobuf bindings. -//! -//! It can be run via: -//! -//! ```no_run -//! cargo test -p opencensus-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 = &[ - "opencensus/proto/agent/common/v1/common.proto", - "opencensus/proto/agent/trace/v1/trace_service.proto", - "opencensus/proto/resource/v1/resource.proto", - "opencensus/proto/trace/v1/trace_config.proto", - "opencensus/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() -} diff --git a/tools/Cargo.toml b/tools/Cargo.toml deleted file mode 100644 index 7fc2d22e7b..0000000000 --- a/tools/Cargo.toml +++ /dev/null @@ -1,11 +0,0 @@ -[package] -name = "tools" -version = "0.1.0" -edition = "2021" -license = "Apache-2.0" -publish = false - -[dependencies.tonic-build] -workspace = true -default-features = false -features = ["prost"] diff --git a/tools/src/bin/gen-protos.rs b/tools/src/bin/gen-protos.rs deleted file mode 100644 index 8fe284edbb..0000000000 --- a/tools/src/bin/gen-protos.rs +++ /dev/null @@ -1,41 +0,0 @@ -use std::path::{Path, PathBuf}; - -fn main() { - generate_opencensus_protos(); -} - -fn generate_opencensus_protos() { - let opencensus_dir = get_proto_dir("opencensus-proto"); - - let out_dir = opencensus_dir.join("src").join("gen"); - - let iface_files = { - let proto_dir = opencensus_dir.join("opencensus").join("proto"); - &[ - proto_dir.join("agent/common/v1/common.proto"), - proto_dir.join("agent/trace/v1/trace_service.proto"), - proto_dir.join("resource/v1/resource.proto"), - proto_dir.join("trace/v1/trace_config.proto"), - proto_dir.join("trace/v1/trace.proto"), - ] - }; - - generate_protos(&out_dir, iface_files, &opencensus_dir); -} - -fn get_proto_dir(name: &str) -> PathBuf { - let manifest_dir = std::path::PathBuf::from(std::env!("CARGO_MANIFEST_DIR")); - manifest_dir.parent().unwrap().join(name) -} - -fn generate_protos(out_dir: &Path, iface_files: &[PathBuf], includes: &Path) { - 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, &[includes]) - { - eprintln!("\nfailed to compile protos: {error}"); - } -}