From cad63b69dd2e447f8a7c0fd618c65523493ca0ae Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Thu, 15 Feb 2024 23:41:00 +0100 Subject: [PATCH] Remove the option of using grpcio for gRPC (#1534) --- .github/workflows/ci.yml | 2 +- Cargo.toml | 2 - opentelemetry-otlp/CHANGELOG.md | 2 + opentelemetry-otlp/Cargo.toml | 6 - opentelemetry-otlp/README.md | 22 +- .../external-otlp-grpcio-async-std/Cargo.toml | 18 - .../external-otlp-grpcio-async-std/README.md | 19 - .../src/main.rs | 101 --- .../src/exporter/grpcio/logs.rs | 76 -- .../src/exporter/grpcio/metrics.rs | 82 -- opentelemetry-otlp/src/exporter/grpcio/mod.rs | 274 ------- .../src/exporter/grpcio/trace.rs | 82 -- opentelemetry-otlp/src/exporter/mod.rs | 20 +- opentelemetry-otlp/src/lib.rs | 40 +- opentelemetry-otlp/src/logs.rs | 15 - opentelemetry-otlp/src/metric.rs | 17 +- opentelemetry-otlp/src/span.rs | 15 - opentelemetry-proto/CHANGELOG.md | 1 + opentelemetry-proto/Cargo.toml | 8 +- opentelemetry-proto/README.md | 4 - opentelemetry-proto/src/lib.rs | 12 +- opentelemetry-proto/src/proto.rs | 70 -- .../opentelemetry.proto.collector.logs.v1.rs | 133 --- ...pentelemetry.proto.collector.metrics.v1.rs | 133 --- .../opentelemetry.proto.collector.trace.v1.rs | 133 --- .../grpcio/opentelemetry.proto.common.v1.rs | 86 -- .../grpcio/opentelemetry.proto.logs.v1.rs | 275 ------- .../grpcio/opentelemetry.proto.metrics.v1.rs | 760 ------------------ .../grpcio/opentelemetry.proto.resource.v1.rs | 14 - .../grpcio/opentelemetry.proto.trace.v1.rs | 412 ---------- opentelemetry-proto/src/transform/common.rs | 113 +-- opentelemetry-proto/src/transform/logs.rs | 139 ---- opentelemetry-proto/src/transform/metrics.rs | 340 -------- opentelemetry-proto/src/transform/trace.rs | 113 --- opentelemetry-proto/src/transform/tracez.rs | 2 +- opentelemetry-proto/tests/grpc_build.rs | 31 - scripts/lint.sh | 11 - scripts/test.sh | 1 - 38 files changed, 21 insertions(+), 3563 deletions(-) delete mode 100644 opentelemetry-otlp/examples/external-otlp-grpcio-async-std/Cargo.toml delete mode 100644 opentelemetry-otlp/examples/external-otlp-grpcio-async-std/README.md delete mode 100644 opentelemetry-otlp/examples/external-otlp-grpcio-async-std/src/main.rs delete mode 100644 opentelemetry-otlp/src/exporter/grpcio/logs.rs delete mode 100644 opentelemetry-otlp/src/exporter/grpcio/metrics.rs delete mode 100644 opentelemetry-otlp/src/exporter/grpcio/mod.rs delete mode 100644 opentelemetry-otlp/src/exporter/grpcio/trace.rs delete mode 100644 opentelemetry-proto/src/proto/grpcio/opentelemetry.proto.collector.logs.v1.rs delete mode 100644 opentelemetry-proto/src/proto/grpcio/opentelemetry.proto.collector.metrics.v1.rs delete mode 100644 opentelemetry-proto/src/proto/grpcio/opentelemetry.proto.collector.trace.v1.rs delete mode 100644 opentelemetry-proto/src/proto/grpcio/opentelemetry.proto.common.v1.rs delete mode 100644 opentelemetry-proto/src/proto/grpcio/opentelemetry.proto.logs.v1.rs delete mode 100644 opentelemetry-proto/src/proto/grpcio/opentelemetry.proto.metrics.v1.rs delete mode 100644 opentelemetry-proto/src/proto/grpcio/opentelemetry.proto.resource.v1.rs delete mode 100644 opentelemetry-proto/src/proto/grpcio/opentelemetry.proto.trace.v1.rs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b6108f30a5..c57c99b96b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -70,7 +70,7 @@ jobs: non-default-examples: strategy: matrix: - example: [opentelemetry-otlp/examples/external-otlp-grpcio-async-std, opentelemetry-otlp/examples/basic-otlp] + example: [opentelemetry-otlp/examples/basic-otlp] runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 diff --git a/Cargo.toml b/Cargo.toml index 007ace15e1..a99f571b8d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,6 @@ members = [ "opentelemetry-zipkin", "opentelemetry-otlp/examples/basic-otlp", "opentelemetry-otlp/examples/basic-otlp-http", - "opentelemetry-otlp/examples/external-otlp-grpcio-async-std", "opentelemetry-otlp/tests/integration_test", "examples/metrics-basic", "examples/metrics-advanced", @@ -43,7 +42,6 @@ env_logger = "0.10" futures-core = "0.3" futures-executor = "0.3" futures-util = "0.3" -grpcio = "0.12" hyper = "0.14" http = "0.2" isahc = "1.4" diff --git a/opentelemetry-otlp/CHANGELOG.md b/opentelemetry-otlp/CHANGELOG.md index f6994aa03c..1b89037040 100644 --- a/opentelemetry-otlp/CHANGELOG.md +++ b/opentelemetry-otlp/CHANGELOG.md @@ -2,6 +2,8 @@ ## vNext +- Remove support for grpcio transport (#1534) + ## v0.14.0 ### Added diff --git a/opentelemetry-otlp/Cargo.toml b/opentelemetry-otlp/Cargo.toml index ce9fe6ae66..84b4deeae9 100644 --- a/opentelemetry-otlp/Cargo.toml +++ b/opentelemetry-otlp/Cargo.toml @@ -28,7 +28,6 @@ rustdoc-args = ["--cfg", "docsrs"] [dependencies] async-trait = { workspace = true } futures-core = { workspace = true } -grpcio = { workspace = true, optional = true } opentelemetry = { version = "0.21", default-features = false, path = "../opentelemetry" } opentelemetry_sdk = { version = "0.21", default-features = false, path = "../opentelemetry-sdk" } opentelemetry-http = { version = "0.10", path = "../opentelemetry-http", optional = true } @@ -71,11 +70,6 @@ gzip-tonic = ["tonic/gzip"] tls = ["tonic/tls"] tls-roots = ["tls", "tonic/tls-roots"] -# grpc using grpcio -grpc-sys = ["grpcio", "opentelemetry-proto/gen-grpcio"] -openssl = ["grpcio/openssl"] -openssl-vendored = ["grpcio/openssl-vendored"] - # http binary http-proto = ["prost", "opentelemetry-http", "opentelemetry-proto/gen-tonic-messages", "http", "trace", "metrics"] reqwest-blocking-client = ["reqwest/blocking", "opentelemetry-http/reqwest"] diff --git a/opentelemetry-otlp/README.md b/opentelemetry-otlp/README.md index d28d1d9f46..a4767836ae 100644 --- a/opentelemetry-otlp/README.md +++ b/opentelemetry-otlp/README.md @@ -46,7 +46,6 @@ use opentelemetry::trace::Tracer; fn main() -> Result<(), Box> { // use tonic as grpc layer here. - // If you want to use grpcio. enable `grpc-sys` feature and use with_grpcio function here. let tracer = opentelemetry_otlp::new_pipeline() .tracing() .with_exporter(opentelemetry_otlp::new_exporter().tonic()) @@ -71,7 +70,7 @@ automatically. ```toml [dependencies] opentelemetry_sdk = { version = "*", features = ["async-std"] } -opentelemetry-otlp = { version = "*", features = ["grpc-sys"] } +opentelemetry-otlp = { version = "*", features = ["grpc-tonic"] } ``` ```rust @@ -84,26 +83,11 @@ let tracer = opentelemetry_otlp::new_pipeline() ## Kitchen Sink Full Configuration -[Example](https://docs.rs/opentelemetry-otlp/latest/opentelemetry_otlp/#kitchen-sink-full-configuration) +[Example](https://docs.rs/opentelemetry-otlp/latest/opentelemetry_otlp/#kitchen-sink-full-configuration) showing how to override all configuration options. -Generally there are two parts of configuration. One is metrics config +Generally there are two parts of configuration. One is metrics config or tracing config. Users can config it via [`OtlpTracePipeline`] or [`OtlpMetricPipeline`]. The other is exporting configuration. Users can set those configurations using [`OtlpExporterPipeline`] based on the choice of exporters. - -# Grpc libraries comparison - -Multiple gRPC transport layers are available. [`tonic`](https://crates.io/crates/tonic) is the default gRPC transport -layer and is enabled by default. [`grpcio`](https://crates.io/crates/grpcio) is optional. - -| gRPC transport layer | [hyperium/tonic](https://github.com/hyperium/tonic) | [tikv/grpc-rs](https://github.com/tikv/grpc-rs) | -|---|---|---| -| Feature | --features=default | --features=grpc-sys | -| gRPC library | [`tonic`](https://crates.io/crates/tonic) | [`grpcio`](https://crates.io/crates/grpcio) | -| Transport | [hyperium/hyper](https://github.com/hyperium/hyper) (Rust) | [grpc/grpc](https://github.com/grpc/grpc) (C++ binding) | -| TLS support | yes | yes | -| TLS library | rustls | OpenSSL | -| TLS optional | yes | yes | -| Supported .proto generator | [`prost`](https://crates.io/crates/prost) | [`prost`](https://crates.io/crates/prost), [`protobuf`](https://crates.io/crates/protobuf) | diff --git a/opentelemetry-otlp/examples/external-otlp-grpcio-async-std/Cargo.toml b/opentelemetry-otlp/examples/external-otlp-grpcio-async-std/Cargo.toml deleted file mode 100644 index 3483884a51..0000000000 --- a/opentelemetry-otlp/examples/external-otlp-grpcio-async-std/Cargo.toml +++ /dev/null @@ -1,18 +0,0 @@ -[package] -name = "external-otlp-grpcio-async-std" -version = "0.1.0" -edition = "2021" -license = "Apache-2.0" -publish = false - -[dependencies] -async-std = { version = "= 1.10.0", features = ["attributes"] } -env_logger = { workspace = true } -opentelemetry = { path = "../../../opentelemetry" } -opentelemetry_sdk = { path = "../../../opentelemetry-sdk", features = ["rt-async-std"] } -opentelemetry-otlp = { path = "../../../opentelemetry-otlp", features = [ - "grpc-sys", - "trace", - "openssl-vendored" -], default-features = false } -url = { workspace = true } diff --git a/opentelemetry-otlp/examples/external-otlp-grpcio-async-std/README.md b/opentelemetry-otlp/examples/external-otlp-grpcio-async-std/README.md deleted file mode 100644 index 4f86e57b40..0000000000 --- a/opentelemetry-otlp/examples/external-otlp-grpcio-async-std/README.md +++ /dev/null @@ -1,19 +0,0 @@ -# External OTLP collector with grpcio and async-std with TLS - -This example shows basic span, and exports to OTLP enabled collectors, like honeycomb, lightstep and other services. -Use this service in case you don't use `tokio`s runtime, for example with web frameworks like `tide` or any `async-std` library that -makes you use it as a runtime. -As these services all reside outside your own infrastructure, they require TLS for encryption to ensure your data safety. -With this example, you can export to any service that supports OTLP by using environment variables. -The following example exports data to Honeycomb: - -```shell -cd opentelemetry-otlp/examples/external-otlp-grpcio-async-std/ -OTLP_GRPCIO_ENDPOINT=https://api.honeycomb.io:443 \ -OTLP_GRPCIO_X_HONEYCOMB_TEAM=token \ -OTLP_GRPCIO_X_HONEYCOMB_DATASET=dataset \ -cargo run -``` - -The only required variable is `OTLP_GRPCIO_ENDPOINT` and any other variable that beggins with the prefix `OTLP_GRPCIO_` will be sent as headers -e.g.: `OTLP_GRPCIO_X_HONEYCOMB_TEAM` becomes `x-honeycomb-team` and `OTLP_GRPCIO_X_HONEYCOMB_DATASET` becomes `x-honeycomb-dataset`. diff --git a/opentelemetry-otlp/examples/external-otlp-grpcio-async-std/src/main.rs b/opentelemetry-otlp/examples/external-otlp-grpcio-async-std/src/main.rs deleted file mode 100644 index 1555eab935..0000000000 --- a/opentelemetry-otlp/examples/external-otlp-grpcio-async-std/src/main.rs +++ /dev/null @@ -1,101 +0,0 @@ -//! This shows how to connect to a third party collector like -//! honeycomb or lightstep using grpcio with tls and using async-std as reactor. -//! To run this specify a few environment variables like in the example: -//! ```shell -//! OTLP_GRPCIO_ENDPOINT=https://api.honeycomb.io:443 \ -//! OTLP_GRPCIO_X_HONEYCOMB_TEAM=token \ -//! OTLP_GRPCIO_X_HONEYCOMB_DATASET=dataset \ -//! cargo run --bin external-otlp-grpcio-async-std -//! ``` -use opentelemetry::{ - global::{shutdown_tracer_provider, tracer}, - trace::TraceError, - trace::{TraceContextExt, Tracer}, - Key, KeyValue, -}; -use opentelemetry_otlp::WithExportConfig; -use std::{ - collections::HashMap, - env::{remove_var, set_var, var, vars}, - error::Error, -}; -use url::Url; - -// Use the variables to try and export the example to any external collector that accepts otlp -// like: oltp itself, honeycomb or lightstep -const ENDPOINT: &str = "OTLP_GRPCIO_ENDPOINT"; -const HEADER_PREFIX: &str = "OTLP_GRPCIO_"; - -fn init_tracer() -> Result { - let endpoint = var(ENDPOINT).unwrap_or_else(|_| { - panic!( - "You must specify and endpoint to connect to with the variable {:?}.", - ENDPOINT - ) - }); - let endpoint = Url::parse(&endpoint).expect("endpoint is not a valid url"); - remove_var(ENDPOINT); - - let headers: HashMap<_, _> = vars() - .filter(|(name, _)| name.starts_with(HEADER_PREFIX)) - .map(|(name, value)| { - let header_name = name - .strip_prefix(HEADER_PREFIX) - .unwrap() - .replace('_', "-") - .to_ascii_lowercase(); - (header_name, value) - }) - .collect(); - - let grpcio_endpoint = format!( - "{}:{}", - endpoint.host_str().unwrap(), - endpoint.port_or_known_default().unwrap() - ); - - opentelemetry_otlp::new_pipeline() - .tracing() - .with_exporter( - opentelemetry_otlp::new_exporter() - .grpcio() - .with_endpoint(grpcio_endpoint) - .with_headers(headers) - .with_tls(true), - ) - .install_batch(opentelemetry_sdk::runtime::AsyncStd) -} - -const LEMONS_KEY: Key = Key::from_static_str("ex.com/lemons"); -const ANOTHER_KEY: Key = Key::from_static_str("ex.com/another"); - -#[async_std::main] -async fn main() -> Result<(), Box> { - if let Err(std::env::VarError::NotPresent) = var("RUST_LOG") { - set_var("RUST_LOG", "debug") - }; - env_logger::init(); - let _ = init_tracer()?; - - let tracer = tracer("ex.com/basic"); - - tracer.in_span("operation", |cx| { - let span = cx.span(); - span.add_event( - "Nice operation!".to_string(), - vec![Key::new("bogons").i64(100)], - ); - span.set_attribute(KeyValue::new(ANOTHER_KEY, "yes")); - - tracer.in_span("Sub operation...", |cx| { - let span = cx.span(); - span.set_attribute(KeyValue::new(LEMONS_KEY, "five")); - - span.add_event("Sub span event", vec![]); - }); - }); - - shutdown_tracer_provider(); - - Ok(()) -} diff --git a/opentelemetry-otlp/src/exporter/grpcio/logs.rs b/opentelemetry-otlp/src/exporter/grpcio/logs.rs deleted file mode 100644 index 1c33d53df8..0000000000 --- a/opentelemetry-otlp/src/exporter/grpcio/logs.rs +++ /dev/null @@ -1,76 +0,0 @@ -use core::fmt; -use std::{collections::HashMap, time::Duration}; - -use async_trait::async_trait; -use grpcio::CallOption; -use opentelemetry::logs::{LogError, LogResult}; -use opentelemetry_proto::grpcio::collector::logs::v1::{ - ExportLogsServiceRequest, LogsServiceClient, -}; -use opentelemetry_sdk::export::logs::{LogData, LogExporter}; - -use grpcio::MetadataBuilder; - -pub(crate) struct GrpcioLogsClient { - client: Option, - timeout: Duration, - headers: HashMap, -} - -impl fmt::Debug for GrpcioLogsClient { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.write_str("GrpcioLogsClient") - } -} - -impl GrpcioLogsClient { - /// Create a new logs client - pub(crate) fn new( - client: LogsServiceClient, - timeout: Duration, - headers: HashMap, - ) -> Self { - GrpcioLogsClient { - client: Some(client), - timeout, - headers, - } - } -} - -#[async_trait] -impl LogExporter for GrpcioLogsClient { - async fn export(&mut self, batch: Vec) -> LogResult<()> { - let client = match &self.client { - Some(client) => client, - None => return Err(LogError::Other("exporter is already shut down".into())), - }; - - let request = ExportLogsServiceRequest { - resource_logs: batch.into_iter().map(Into::into).collect(), - }; - - let mut call_options = CallOption::default().timeout(self.timeout); - - if !self.headers.is_empty() { - let mut metadata_builder: MetadataBuilder = MetadataBuilder::new(); - - for (key, value) in self.headers.iter() { - let _ = metadata_builder.add_str(key.as_str(), value.as_str()); - } - - call_options = call_options.headers(metadata_builder.build()); - } - - let receiver = client - .export_async_opt(&request, call_options) - .map_err(crate::Error::from)?; - receiver.await.map_err(crate::Error::from)?; - - Ok(()) - } - - fn shutdown(&mut self) { - let _ = self.client.take(); - } -} diff --git a/opentelemetry-otlp/src/exporter/grpcio/metrics.rs b/opentelemetry-otlp/src/exporter/grpcio/metrics.rs deleted file mode 100644 index 0206da80d7..0000000000 --- a/opentelemetry-otlp/src/exporter/grpcio/metrics.rs +++ /dev/null @@ -1,82 +0,0 @@ -use core::fmt; -use std::{collections::HashMap, sync::Mutex, time::Duration}; - -use async_trait::async_trait; -use grpcio::CallOption; -use opentelemetry::metrics::{MetricsError, Result}; -use opentelemetry_proto::grpcio::collector::metrics::v1::{ - ExportMetricsServiceRequest, MetricsServiceClient, -}; -use opentelemetry_sdk::metrics::data::ResourceMetrics; - -use crate::metric::MetricsClient; - -use grpcio::MetadataBuilder; - -pub(crate) struct GrpcioMetricsClient { - client: Mutex>, - timeout: Duration, - headers: HashMap, -} - -impl fmt::Debug for GrpcioMetricsClient { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.write_str("GrpcioMetricsClient") - } -} - -impl GrpcioMetricsClient { - /// Create a new metrics client - pub(crate) fn new( - client: MetricsServiceClient, - timeout: Duration, - headers: HashMap, - ) -> Self { - GrpcioMetricsClient { - client: Mutex::new(Some(client)), - timeout, - headers, - } - } -} - -#[async_trait] -impl MetricsClient for GrpcioMetricsClient { - async fn export(&self, metrics: &mut ResourceMetrics) -> Result<()> { - let client = - self.client - .lock() - .map_err(Into::into) - .and_then(|mut inner| match &mut *inner { - Some(inner) => Ok(inner.clone()), - None => Err(MetricsError::Other("exporter is already shut down".into())), - })?; - - let request = ExportMetricsServiceRequest::from(&*metrics); - - let mut call_options = CallOption::default().timeout(self.timeout); - - if !self.headers.is_empty() { - let mut metadata_builder: MetadataBuilder = MetadataBuilder::new(); - - for (key, value) in self.headers.iter() { - let _ = metadata_builder.add_str(key.as_str(), value.as_str()); - } - - call_options = call_options.headers(metadata_builder.build()); - } - - let receiver = client - .export_async_opt(&request, call_options) - .map_err(crate::Error::from)?; - receiver.await.map_err(crate::Error::from)?; - - Ok(()) - } - - fn shutdown(&self) -> Result<()> { - let _ = self.client.lock()?.take(); - - Ok(()) - } -} diff --git a/opentelemetry-otlp/src/exporter/grpcio/mod.rs b/opentelemetry-otlp/src/exporter/grpcio/mod.rs deleted file mode 100644 index 4ae47c26f2..0000000000 --- a/opentelemetry-otlp/src/exporter/grpcio/mod.rs +++ /dev/null @@ -1,274 +0,0 @@ -use std::collections::HashMap; -use std::sync::Arc; - -use grpcio::{Channel, ChannelBuilder, ChannelCredentialsBuilder, Environment}; -#[cfg(feature = "serialize")] -use serde::{Deserialize, Serialize}; - -use crate::exporter::Compression; -use crate::ExportConfig; - -use super::default_headers; - -#[cfg(feature = "logs")] -mod logs; - -#[cfg(feature = "trace")] -mod trace; - -#[cfg(feature = "metrics")] -mod metrics; - -/// Configuration of grpcio -#[derive(Debug)] -#[non_exhaustive] -pub struct GrpcioConfig { - /// The credentials to use when communicating with the collector. - pub credentials: Option, - - /// Additional headers to send to the collector. - pub headers: Option>, - - /// The compression algorithm to use when communicating with the collector. - pub compression: Option, - - /// Use TLS without any specific certificate pinning. - pub use_tls: Option, - - /// The number of GRPC worker threads to poll queues. - pub completion_queue_count: usize, -} - -impl Default for GrpcioConfig { - fn default() -> Self { - GrpcioConfig { - credentials: None, - headers: Some(default_headers()), - compression: None, - use_tls: None, - completion_queue_count: 2, - } - } -} - -/// Credential configuration for authenticated requests. -#[cfg_attr(feature = "serialize", derive(Deserialize, Serialize))] -#[derive(Clone, Debug)] -pub struct Credentials { - /// Credential cert - pub cert: String, - /// Credential key - pub key: String, -} - -impl From for grpcio::CompressionAlgorithms { - fn from(compression: Compression) -> Self { - match compression { - Compression::Gzip => grpcio::CompressionAlgorithms::GRPC_COMPRESS_GZIP, - } - } -} - -/// Configuration for the [grpcio] OTLP GRPC exporter. -/// -/// It allows you to -/// - setup credentials -/// - add additional headers -/// - config compression -/// - select whether to use TLS -/// - set the number of GRPC worker threads to poll queues -/// -/// [grpcio]: https://github.com/tikv/grpc-rs -/// -/// ## Examples -/// -/// ```no_run -/// # #[cfg(feature="metrics")] -/// use opentelemetry_sdk::metrics::reader::{ -/// DefaultAggregationSelector, DefaultTemporalitySelector, -/// }; -/// -/// # fn main() -> Result<(), Box> { -/// // Create a span exporter you can use to when configuring tracer providers -/// # #[cfg(feature="trace")] -/// let span_exporter = opentelemetry_otlp::new_exporter().grpcio().build_span_exporter()?; -/// -/// // Create a metrics exporter you can use when configuring meter providers -/// # #[cfg(feature="metrics")] -/// let metrics_exporter = opentelemetry_otlp::new_exporter() -/// .grpcio() -/// .build_metrics_exporter( -/// Box::new(DefaultAggregationSelector::new()), -/// Box::new(DefaultTemporalitySelector::new()), -/// )?; -/// -/// // Create a log exporter you can use when configuring logger providers -/// # #[cfg(feature="logs")] -/// let log_exporter = opentelemetry_otlp::new_exporter().grpcio().build_log_exporter()?; -/// # Ok(()) -/// # } -/// ``` -#[derive(Default, Debug)] -pub struct GrpcioExporterBuilder { - pub(crate) exporter_config: ExportConfig, - pub(crate) grpcio_config: GrpcioConfig, -} - -impl GrpcioExporterBuilder { - /// Set the credentials to use when communicating with the collector. - pub fn with_credentials(mut self, credentials: Credentials) -> Self { - self.grpcio_config.credentials = Some(credentials); - self - } - - /// Set additional headers to send to the collector. - pub fn with_headers(mut self, headers: HashMap) -> Self { - let mut inst_headers = self.grpcio_config.headers.unwrap_or_default(); - inst_headers.extend(headers); - self.grpcio_config.headers = Some(inst_headers); - self - } - - /// Set the compression algorithm to use when communicating with the collector. - pub fn with_compression(mut self, compression: Compression) -> Self { - self.grpcio_config.compression = Some(compression); - self - } - - /// Enable TLS without any certificate pinning. - pub fn with_tls(mut self, use_tls: bool) -> Self { - self.grpcio_config.use_tls = Some(use_tls); - self - } - - /// Set the number of GRPC worker threads to poll queues. - pub fn with_completion_queue_count(mut self, count: usize) -> Self { - self.grpcio_config.completion_queue_count = count; - self - } - - fn build_channel(&mut self) -> Result { - let mut builder: ChannelBuilder = ChannelBuilder::new(Arc::new(Environment::new( - self.grpcio_config.completion_queue_count, - ))); - - if let Some(compression) = self.grpcio_config.compression { - builder = builder.default_compression_algorithm(compression.into()); - } - - let channel = match ( - self.grpcio_config.credentials.take(), - self.grpcio_config.use_tls.take(), - ) { - (None, Some(true)) => builder - .set_credentials(ChannelCredentialsBuilder::new().build()) - .connect(self.exporter_config.endpoint.as_str()), - (None, _) => builder.connect(self.exporter_config.endpoint.as_str()), - (Some(credentials), _) => builder - .set_credentials( - ChannelCredentialsBuilder::new() - .cert(credentials.cert.into(), credentials.key.into()) - .build(), - ) - .connect(self.exporter_config.endpoint.as_str()), - }; - - Ok(channel) - } - - /// Create a new span exporter with the current configuration - #[cfg(feature = "trace")] - pub fn build_span_exporter( - mut self, - ) -> Result { - use opentelemetry_proto::grpcio::collector::trace::v1::TraceServiceClient; - - use self::trace::GrpcioTraceClient; - - let channel = self.build_channel()?; - - let client = GrpcioTraceClient::new( - TraceServiceClient::new(channel), - self.exporter_config.timeout, - self.grpcio_config.headers.unwrap_or_default(), - ); - - Ok(crate::SpanExporter::new(client)) - } - - #[cfg(feature = "logs")] - /// Builds a new log exporter with the given configuration - pub fn build_log_exporter( - mut self, - ) -> Result { - use self::logs::GrpcioLogsClient; - use opentelemetry_proto::grpcio::collector::logs::v1::LogsServiceClient; - - let channel = self.build_channel()?; - - let client = GrpcioLogsClient::new( - LogsServiceClient::new(channel), - self.exporter_config.timeout, - self.grpcio_config.headers.unwrap_or_default(), - ); - - Ok(crate::logs::LogExporter::new(client)) - } - - #[cfg(feature = "metrics")] - /// Builds a new metrics exporter with the given configuration - pub fn build_metrics_exporter( - mut self, - aggregation_selector: Box, - temporality_selector: Box, - ) -> opentelemetry::metrics::Result { - use self::metrics::GrpcioMetricsClient; - use opentelemetry_proto::grpcio::collector::metrics::v1::MetricsServiceClient; - - let channel = self.build_channel()?; - - let client = GrpcioMetricsClient::new( - MetricsServiceClient::new(channel), - self.exporter_config.timeout, - self.grpcio_config.headers.unwrap_or_default(), - ); - - Ok(crate::MetricsExporter::new( - client, - temporality_selector, - aggregation_selector, - )) - } -} - -#[cfg(test)] -mod tests { - use crate::GrpcioExporterBuilder; - use std::collections::HashMap; - - #[test] - fn test_with_headers() { - // metadata should merge with the current one with priority instead of just replacing it - let mut headers = HashMap::new(); - headers.insert("key".to_string(), "value".to_string()); - let builder = GrpcioExporterBuilder::default().with_headers(headers); - let result = builder.grpcio_config.headers.unwrap(); - assert_eq!(result.get("key").unwrap(), "value"); - assert!(result.get("User-Agent").is_some()); - - // metadata should override entries with the same key in the default one - let mut headers = HashMap::new(); - headers.insert("User-Agent".to_string(), "baz".to_string()); - let builder = GrpcioExporterBuilder::default().with_headers(headers); - let result = builder.grpcio_config.headers.unwrap(); - assert_eq!(result.get("User-Agent").unwrap(), "baz"); - assert_eq!( - result.len(), - GrpcioExporterBuilder::default() - .grpcio_config - .headers - .unwrap() - .len() - ); - } -} diff --git a/opentelemetry-otlp/src/exporter/grpcio/trace.rs b/opentelemetry-otlp/src/exporter/grpcio/trace.rs deleted file mode 100644 index bfd6624c1c..0000000000 --- a/opentelemetry-otlp/src/exporter/grpcio/trace.rs +++ /dev/null @@ -1,82 +0,0 @@ -use core::fmt; -use std::{collections::HashMap, time::Duration}; - -use futures_core::future::BoxFuture; -use grpcio::CallOption; -use opentelemetry::trace::TraceError; -use opentelemetry_proto::grpcio::collector::trace::v1::{ - ExportTraceServiceRequest, TraceServiceClient, -}; -use opentelemetry_sdk::export::trace::{ExportResult, SpanData, SpanExporter}; - -use grpcio::MetadataBuilder; - -pub(crate) struct GrpcioTraceClient { - client: Option, - timeout: Duration, - headers: HashMap, -} - -impl fmt::Debug for GrpcioTraceClient { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.write_str("GrpcioTracesClient") - } -} - -impl GrpcioTraceClient { - /// Create a new trace client - pub(crate) fn new( - client: TraceServiceClient, - timeout: Duration, - headers: HashMap, - ) -> Self { - GrpcioTraceClient { - client: Some(client), - timeout, - headers, - } - } -} - -impl SpanExporter for GrpcioTraceClient { - fn export(&mut self, batch: Vec) -> BoxFuture<'static, ExportResult> { - let client = match &self.client { - Some(client) => client.clone(), - None => { - return Box::pin(std::future::ready(Err(TraceError::Other( - "exporter is already shut down".into(), - )))) - } - }; - - let request = ExportTraceServiceRequest { - resource_spans: batch.into_iter().map(Into::into).collect(), - }; - - let mut call_options = CallOption::default().timeout(self.timeout); - - if !self.headers.is_empty() { - let mut metadata_builder: MetadataBuilder = MetadataBuilder::new(); - - for (key, value) in self.headers.iter() { - let _ = metadata_builder.add_str(key.as_str(), value.as_str()); - } - - call_options = call_options.headers(metadata_builder.build()); - } - - Box::pin(async move { - let receiver = client - .export_async_opt(&request, call_options) - .map_err(crate::Error::from)?; - - receiver.await.map_err(crate::Error::from)?; - - Ok(()) - }) - } - - fn shutdown(&mut self) { - let _ = self.client.take(); - } -} diff --git a/opentelemetry-otlp/src/exporter/mod.rs b/opentelemetry-otlp/src/exporter/mod.rs index 93fbdec724..7ed22de0c8 100644 --- a/opentelemetry-otlp/src/exporter/mod.rs +++ b/opentelemetry-otlp/src/exporter/mod.rs @@ -2,8 +2,6 @@ //! //! OTLP supports sending data via different protocols and formats. -#[cfg(feature = "grpc-sys")] -use crate::exporter::grpcio::GrpcioExporterBuilder; #[cfg(feature = "http-proto")] use crate::exporter::http::HttpExporterBuilder; #[cfg(feature = "grpc-tonic")] @@ -33,13 +31,10 @@ pub const OTEL_EXPORTER_OTLP_COMPRESSION: &str = "OTEL_EXPORTER_OTLP_COMPRESSION #[cfg(feature = "http-proto")] /// Default protocol, using http-proto. pub const OTEL_EXPORTER_OTLP_PROTOCOL_DEFAULT: &str = OTEL_EXPORTER_OTLP_PROTOCOL_HTTP_PROTOBUF; -#[cfg(all( - any(feature = "grpc-tonic", feature = "grpcio"), - not(feature = "http-proto") -))] +#[cfg(all(feature = "grpc-tonic", not(feature = "http-proto")))] /// Default protocol, using grpc as http-proto feature is not enabled. pub const OTEL_EXPORTER_OTLP_PROTOCOL_DEFAULT: &str = OTEL_EXPORTER_OTLP_PROTOCOL_GRPC; -#[cfg(not(any(any(feature = "grpc-tonic", feature = "grpcio", feature = "http-proto"))))] +#[cfg(not(any(any(feature = "grpc-tonic", feature = "http-proto"))))] /// Default protocol if no features are enabled. pub const OTEL_EXPORTER_OTLP_PROTOCOL_DEFAULT: &str = ""; @@ -55,8 +50,6 @@ pub const OTEL_EXPORTER_OTLP_TIMEOUT_DEFAULT: u64 = 10; const OTEL_EXPORTER_OTLP_GRPC_ENDPOINT_DEFAULT: &str = "http://localhost:4317"; const OTEL_EXPORTER_OTLP_HTTP_ENDPOINT_DEFAULT: &str = "http://localhost:4318"; -#[cfg(feature = "grpc-sys")] -pub(crate) mod grpcio; #[cfg(feature = "http-proto")] pub(crate) mod http; #[cfg(feature = "grpc-tonic")] @@ -132,7 +125,7 @@ fn default_endpoint(protocol: Protocol) -> String { } /// default user-agent headers -#[cfg(any(feature = "grpc-tonic", feature = "grpc-sys", feature = "http-proto"))] +#[cfg(any(feature = "grpc-tonic", feature = "http-proto"))] fn default_headers() -> std::collections::HashMap { let mut headers = std::collections::HashMap::new(); headers.insert( @@ -155,13 +148,6 @@ impl HasExportConfig for TonicExporterBuilder { } } -#[cfg(feature = "grpc-sys")] -impl HasExportConfig for GrpcioExporterBuilder { - fn export_config(&mut self) -> &mut ExportConfig { - &mut self.exporter_config - } -} - #[cfg(feature = "http-proto")] impl HasExportConfig for HttpExporterBuilder { fn export_config(&mut self) -> &mut ExportConfig { diff --git a/opentelemetry-otlp/src/lib.rs b/opentelemetry-otlp/src/lib.rs index ff346aef70..20bddb7c38 100644 --- a/opentelemetry-otlp/src/lib.rs +++ b/opentelemetry-otlp/src/lib.rs @@ -61,7 +61,7 @@ //! ```toml //! [dependencies] //! opentelemetry_sdk = { version = "*", features = ["async-std"] } -//! opentelemetry-otlp = { version = "*", features = ["grpc-sys"] } +//! opentelemetry-otlp = { version = "*", features = ["grpc-tonic"] } //! ``` //! //! ```no_run @@ -98,11 +98,6 @@ //! * `tls-tonic`: Enable TLS. //! * `tls-roots`: Adds system trust roots to rustls-based gRPC clients using the rustls-native-certs crate //! -//! For users uses `grpcio` as grpc layer: -//! * `grpc-sys`: Use `grpcio` as grpc layer. -//! * `openssl`: Enable TLS supported by OpenSSL -//! * `openssl-vendored`: Same as `openssl` but it will build openssl from bundled sources. -//! //! The following feature flags offer additional configurations on http: //! //! * `http-proto`: Use http as transport layer, protobuf as body format. @@ -197,22 +192,6 @@ //! Ok(()) //! } //! ``` -//! -//! # Grpc libraries comparison -//! -//! The table below provides a short comparison between `grpcio` and `tonic`, two -//! of the most popular grpc libraries in Rust. Users can choose between them when -//! working with otlp and grpc. -//! -//! | Project | [hyperium/tonic](https://github.com/hyperium/tonic) | [tikv/grpc-rs](https://github.com/tikv/grpc-rs) | -//! |---|---|---| -//! | Feature name | --features=default | --features=grpc-sys | -//! | gRPC library | [`tonic`](https://crates.io/crates/tonic) | [`grpcio`](https://crates.io/crates/grpcio) | -//! | Transport | [hyperium/hyper](https://github.com/hyperium/hyper) (Rust) | [grpc/grpc](https://github.com/grpc/grpc) (C++ binding) | -//! | TLS support | yes | yes | -//! | TLS optional | yes | yes | -//! | TLS library | rustls | OpenSSL | -//! | Supported .proto generator | [`prost`](https://crates.io/crates/prost) | [`prost`](https://crates.io/crates/prost), [`protobuf`](https://crates.io/crates/protobuf) | #![warn( future_incompatible, missing_debug_implementations, @@ -270,9 +249,6 @@ pub use crate::exporter::{ use opentelemetry_sdk::export::ExportError; -#[cfg(feature = "grpc-sys")] -pub use crate::exporter::grpcio::{Credentials, GrpcioConfig, GrpcioExporterBuilder}; - #[cfg(feature = "http-proto")] pub use crate::exporter::http::HttpExporterBuilder; @@ -300,15 +276,6 @@ impl OtlpExporterPipeline { TonicExporterBuilder::default() } - /// Use grpcio as grpc layer, return a `GrpcioExporterBuilder` to config the grpcio and build the exporter. - /// - /// This exporter can only be used in `tracing` pipeline. Support for `metrics` pipeline will be - /// added in the future. - #[cfg(feature = "grpc-sys")] - pub fn grpcio(self) -> GrpcioExporterBuilder { - GrpcioExporterBuilder::default() - } - /// Use HTTP as transport layer, return a `HttpExporterBuilder` to config the http transport /// and build the exporter. /// @@ -363,11 +330,6 @@ pub enum Error { message: String, }, - /// Wrap errors from grpcio. - #[cfg(feature = "grpc-sys")] - #[error("grpcio error {0}")] - Grpcio(#[from] grpcio::Error), - /// Http requests failed because no http client is provided. #[cfg(feature = "http-proto")] #[error( diff --git a/opentelemetry-otlp/src/logs.rs b/opentelemetry-otlp/src/logs.rs index bb69b06238..a9ec267d0c 100644 --- a/opentelemetry-otlp/src/logs.rs +++ b/opentelemetry-otlp/src/logs.rs @@ -5,9 +5,6 @@ #[cfg(feature = "grpc-tonic")] use crate::exporter::tonic::TonicExporterBuilder; -#[cfg(feature = "grpc-sys")] -use crate::exporter::grpcio::GrpcioExporterBuilder; - #[cfg(feature = "http-proto")] use crate::exporter::http::HttpExporterBuilder; @@ -55,9 +52,6 @@ pub enum LogExporterBuilder { /// Tonic log exporter builder #[cfg(feature = "grpc-tonic")] Tonic(TonicExporterBuilder), - /// Grpc log exporter builder - #[cfg(feature = "grpc-sys")] - Grpcio(GrpcioExporterBuilder), /// Http log exporter builder #[cfg(feature = "http-proto")] Http(HttpExporterBuilder), @@ -69,8 +63,6 @@ impl LogExporterBuilder { match self { #[cfg(feature = "grpc-tonic")] LogExporterBuilder::Tonic(builder) => builder.build_log_exporter(), - #[cfg(feature = "grpc-sys")] - LogExporterBuilder::Grpcio(builder) => builder.build_log_exporter(), #[cfg(feature = "http-proto")] LogExporterBuilder::Http(builder) => builder.build_log_exporter(), } @@ -84,13 +76,6 @@ impl From for LogExporterBuilder { } } -#[cfg(feature = "grpc-sys")] -impl From for LogExporterBuilder { - fn from(exporter: GrpcioExporterBuilder) -> Self { - LogExporterBuilder::Grpcio(exporter) - } -} - #[cfg(feature = "http-proto")] impl From for LogExporterBuilder { fn from(exporter: HttpExporterBuilder) -> Self { diff --git a/opentelemetry-otlp/src/metric.rs b/opentelemetry-otlp/src/metric.rs index 78155aace1..b0b030b359 100644 --- a/opentelemetry-otlp/src/metric.rs +++ b/opentelemetry-otlp/src/metric.rs @@ -26,9 +26,6 @@ use opentelemetry_sdk::{ use std::fmt::{Debug, Formatter}; use std::time; -#[cfg(feature = "grpc-sys")] -use crate::exporter::grpcio::GrpcioExporterBuilder; - #[cfg(feature = "http-proto")] use crate::exporter::http::HttpExporterBuilder; @@ -70,16 +67,13 @@ pub enum MetricsExporterBuilder { /// Tonic metrics exporter builder #[cfg(feature = "grpc-tonic")] Tonic(TonicExporterBuilder), - /// Grpcio metrics exporter builder - #[cfg(feature = "grpc-sys")] - Grpcio(GrpcioExporterBuilder), /// Http metrics exporter builder #[cfg(feature = "http-proto")] Http(HttpExporterBuilder), /// Missing exporter builder #[doc(hidden)] - #[cfg(not(any(feature = "http-proto", feature = "grpc-sys", feature = "grpc-tonic")))] + #[cfg(not(any(feature = "http-proto", feature = "grpc-tonic")))] Unconfigured, } @@ -95,21 +89,16 @@ impl MetricsExporterBuilder { MetricsExporterBuilder::Tonic(builder) => { builder.build_metrics_exporter(aggregation_selector, temporality_selector) } - #[cfg(feature = "grpc-sys")] - MetricsExporterBuilder::Grpcio(builder) => { - builder.build_metrics_exporter(aggregation_selector, temporality_selector) - } #[cfg(feature = "http-proto")] MetricsExporterBuilder::Http(builder) => { builder.build_metrics_exporter(aggregation_selector, temporality_selector) } - - #[cfg(not(any(feature = "http-proto", feature = "grpc-sys", feature = "grpc-tonic")))] + #[cfg(not(any(feature = "http-proto", feature = "grpc-tonic")))] MetricsExporterBuilder::Unconfigured => { drop(temporality_selector); drop(aggregation_selector); Err(opentelemetry::metrics::MetricsError::Other( - "no configured metrics exporter, enable `http-proto`, `grpc-sys` or `grpc-tonic` feature to configure a metrics exporter".into(), + "no configured metrics exporter, enable `http-proto` or `grpc-tonic` feature to configure a metrics exporter".into(), )) } } diff --git a/opentelemetry-otlp/src/span.rs b/opentelemetry-otlp/src/span.rs index a8503c87a4..76383f2f04 100644 --- a/opentelemetry-otlp/src/span.rs +++ b/opentelemetry-otlp/src/span.rs @@ -19,9 +19,6 @@ use sdk::runtime::RuntimeChannel; #[cfg(feature = "grpc-tonic")] use crate::exporter::tonic::TonicExporterBuilder; -#[cfg(feature = "grpc-sys")] -use crate::exporter::grpcio::GrpcioExporterBuilder; - #[cfg(feature = "http-proto")] use crate::exporter::http::HttpExporterBuilder; @@ -189,9 +186,6 @@ pub enum SpanExporterBuilder { /// Tonic span exporter builder #[cfg(feature = "grpc-tonic")] Tonic(TonicExporterBuilder), - /// Grpc span exporter builder - #[cfg(feature = "grpc-sys")] - Grpcio(GrpcioExporterBuilder), /// Http span exporter builder #[cfg(feature = "http-proto")] Http(HttpExporterBuilder), @@ -203,8 +197,6 @@ impl SpanExporterBuilder { match self { #[cfg(feature = "grpc-tonic")] SpanExporterBuilder::Tonic(builder) => builder.build_span_exporter(), - #[cfg(feature = "grpc-sys")] - SpanExporterBuilder::Grpcio(builder) => builder.build_span_exporter(), #[cfg(feature = "http-proto")] SpanExporterBuilder::Http(builder) => builder.build_span_exporter(), } @@ -218,13 +210,6 @@ impl From for SpanExporterBuilder { } } -#[cfg(feature = "grpc-sys")] -impl From for SpanExporterBuilder { - fn from(exporter: GrpcioExporterBuilder) -> Self { - SpanExporterBuilder::Grpcio(exporter) - } -} - #[cfg(feature = "http-proto")] impl From for SpanExporterBuilder { fn from(exporter: HttpExporterBuilder) -> Self { diff --git a/opentelemetry-proto/CHANGELOG.md b/opentelemetry-proto/CHANGELOG.md index f0a0d916c5..bec564e9c4 100644 --- a/opentelemetry-proto/CHANGELOG.md +++ b/opentelemetry-proto/CHANGELOG.md @@ -4,6 +4,7 @@ ### Added +- Remove support for grpcio transport (#1534) - Add `schemars::JsonSchema` trait support with `with-schemars` feature (#1419) - Update protobuf definitions to v1.1.0 (#1154) diff --git a/opentelemetry-proto/Cargo.toml b/opentelemetry-proto/Cargo.toml index 19bc3ae0dd..4a1c1ce99b 100644 --- a/opentelemetry-proto/Cargo.toml +++ b/opentelemetry-proto/Cargo.toml @@ -31,13 +31,11 @@ path = "tests/json_deserialize.rs" [features] default = [] -full = ["gen-tonic", "gen-grpcio", "trace", "logs", "metrics", "zpages", "with-serde"] +full = ["gen-tonic", "trace", "logs", "metrics", "zpages", "with-serde"] # crates used to generate rs files gen-tonic = ["gen-tonic-messages", "tonic/transport"] gen-tonic-messages = ["tonic", "prost"] -gen-grpcio = ["gen-grpcio-messages", "grpcio"] -gen-grpcio-messages = ["prost"] # telemetry pillars and functions trace = ["opentelemetry/trace", "opentelemetry_sdk/trace"] @@ -50,7 +48,6 @@ with-schemars = ["schemars"] with-serde = ["serde", "hex"] [dependencies] -grpcio = { workspace = true, optional = true, features = ["prost-codec"] } tonic = { workspace = true, optional = true, features = ["codegen", "prost"] } prost = { workspace = true, optional = true } opentelemetry = { version = "0.21", default-features = false, path = "../opentelemetry" } @@ -60,8 +57,7 @@ serde = { workspace = true, optional = true, features = ["serde_derive"] } hex = { version = "0.4.3", optional = true } [dev-dependencies] -grpcio-compiler = { version = "0.12.1", default-features = false, features = ["prost-codec"] } tonic-build = { version = "0.9.0" } prost-build = { version = "0.11.1" } tempfile = "3.3.0" -serde_json = "1.0" \ No newline at end of file +serde_json = "1.0" diff --git a/opentelemetry-proto/README.md b/opentelemetry-proto/README.md index e18f30117d..b540bc4403 100644 --- a/opentelemetry-proto/README.md +++ b/opentelemetry-proto/README.md @@ -5,7 +5,3 @@ # OpenTelemetry Proto This crate contains generated files from [opentelemetry-proto](https://github.com/open-telemetry/opentelemetry-proto) repository and transformation between types from generated files and types defined in [opentelemetry](https://github.com/open-telemetry/opentelemetry-rust/tree/main/opentelemetry). - -Based on the grpc framework needed, users can choose to generate files using [tonic](https://github.com/hyperium/tonic) -or [grpcio](https://github.com/tikv/grpc-rs). - diff --git a/opentelemetry-proto/src/lib.rs b/opentelemetry-proto/src/lib.rs index a5068f7ddb..209df125a6 100644 --- a/opentelemetry-proto/src/lib.rs +++ b/opentelemetry-proto/src/lib.rs @@ -11,16 +11,14 @@ //! The following is the full list of currently supported features: //! //! ## Signals -//! - `trace`: generate types that used in traces. Currently supports `gen-tonic` or `gen-grpcio`. +//! - `trace`: generate types that used in traces. Currently supports `gen-tonic`. //! - `metrics`: generate types that used in metrics. Currently supports `gen-tonic`. //! - `logs`: generate types that used in logs. Currently supports `gen-tonic`. -//! - `zpages`: generate types that used in zPages. Currently only tracez related types will be generated. Currently supports `gen-tonic` or `gen-grpcio`. +//! - `zpages`: generate types that used in zPages. Currently only tracez related types will be generated. Currently supports `gen-tonic`. //! //! ## Creates used to generate files //! - `gen-tonic-messages`: generate rs files using [tonic](https://github.com/hyperium/tonic) and [prost](https://github.com/tokio-rs/prost). //! - `gen-tonic`: adding tonic transport to "`gen-tonic-messages" -//! - `gen-grpcio-messages`: generate rs files using [grpcio](https://github.com/tikv/grpc-rs). -//! - `gen-grpcio`: adding gRPC core to "gen-grpcio-messages" //! //! ## Misc //! - `full`: enabled all features above. @@ -34,13 +32,7 @@ #[doc(hidden)] mod proto; -#[cfg(feature = "gen-grpcio-messages")] -pub use proto::grpcio; - #[cfg(feature = "gen-tonic-messages")] pub use proto::tonic; pub mod transform; - -#[cfg(feature = "gen-grpcio-messages")] -pub use prost; diff --git a/opentelemetry-proto/src/proto.rs b/opentelemetry-proto/src/proto.rs index ea5396dba3..c281a235fb 100644 --- a/opentelemetry-proto/src/proto.rs +++ b/opentelemetry-proto/src/proto.rs @@ -149,73 +149,3 @@ pub mod tonic { pub use crate::transform::common::tonic::Attributes; } - -#[cfg(feature = "gen-grpcio-messages")] -/// Generated files using [`grpcio`](https://docs.rs/crate/grpcio) and [`grpcio-compiler`](https://docs.rs/grpcio-compiler) -pub mod grpcio { - /// Service stub and clients - #[cfg(feature = "gen-grpcio")] - #[path = ""] - pub mod collector { - #[cfg(feature = "logs")] - #[path = ""] - pub mod logs { - #[path = "opentelemetry.proto.collector.logs.v1.rs"] - pub mod v1; - } - - #[cfg(feature = "metrics")] - #[path = ""] - pub mod metrics { - #[path = "opentelemetry.proto.collector.metrics.v1.rs"] - pub mod v1; - } - - #[cfg(feature = "trace")] - #[path = ""] - pub mod trace { - #[path = "opentelemetry.proto.collector.trace.v1.rs"] - pub mod v1; - } - } - - /// Common types used across all signals - #[path = ""] - pub mod common { - #[path = "opentelemetry.proto.common.v1.rs"] - pub mod v1; - } - - /// Generated types used in logging. - #[cfg(feature = "logs")] - #[path = ""] - pub mod logs { - #[path = "opentelemetry.proto.logs.v1.rs"] - pub mod v1; - } - - /// Generated types used in metrics. - #[cfg(feature = "metrics")] - #[path = ""] - pub mod metrics { - #[path = "opentelemetry.proto.metrics.v1.rs"] - pub mod v1; - } - - /// Generated types used in resources. - #[path = ""] - pub mod resource { - #[path = "opentelemetry.proto.resource.v1.rs"] - pub mod v1; - } - - /// Generated types used in traces. - #[cfg(feature = "trace")] - #[path = ""] - pub mod trace { - #[path = "opentelemetry.proto.trace.v1.rs"] - pub mod v1; - } - - pub use crate::transform::common::grpcio::Attributes; -} diff --git a/opentelemetry-proto/src/proto/grpcio/opentelemetry.proto.collector.logs.v1.rs b/opentelemetry-proto/src/proto/grpcio/opentelemetry.proto.collector.logs.v1.rs deleted file mode 100644 index 97073fe9db..0000000000 --- a/opentelemetry-proto/src/proto/grpcio/opentelemetry.proto.collector.logs.v1.rs +++ /dev/null @@ -1,133 +0,0 @@ -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ExportLogsServiceRequest { - /// An array of ResourceLogs. - /// For data coming from a single resource this array will typically contain one - /// element. Intermediary nodes (such as OpenTelemetry Collector) that receive - /// data from multiple origins typically batch the data before forwarding further and - /// in that case this array will contain multiple elements. - #[prost(message, repeated, tag = "1")] - pub resource_logs: ::prost::alloc::vec::Vec< - super::super::super::logs::v1::ResourceLogs, - >, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ExportLogsServiceResponse { - /// The details of a partially successful export request. - /// - /// If the request is only partially accepted - /// (i.e. when the server accepts only parts of the data and rejects the rest) - /// the server MUST initialize the `partial_success` field and MUST - /// set the `rejected_` with the number of items it rejected. - /// - /// Servers MAY also make use of the `partial_success` field to convey - /// warnings/suggestions to senders even when the request was fully accepted. - /// In such cases, the `rejected_` MUST have a value of `0` and - /// the `error_message` MUST be non-empty. - /// - /// A `partial_success` message with an empty value (rejected_ = 0 and - /// `error_message` = "") is equivalent to it not being set/present. Senders - /// SHOULD interpret it the same way as in the full success case. - #[prost(message, optional, tag = "1")] - pub partial_success: ::core::option::Option, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ExportLogsPartialSuccess { - /// The number of rejected log records. - /// - /// A `rejected_` field holding a `0` value indicates that the - /// request was fully accepted. - #[prost(int64, tag = "1")] - pub rejected_log_records: i64, - /// A developer-facing human-readable message in English. It should be used - /// either to explain why the server rejected parts of the data during a partial - /// success or to convey warnings/suggestions during a full success. The message - /// should offer guidance on how users can address such issues. - /// - /// error_message is an optional field. An error_message with an empty value - /// is equivalent to it not being set. - #[prost(string, tag = "2")] - pub error_message: ::prost::alloc::string::String, -} -const METHOD_LOGS_SERVICE_EXPORT: ::grpcio::Method< - ExportLogsServiceRequest, - ExportLogsServiceResponse, -> = ::grpcio::Method { - ty: ::grpcio::MethodType::Unary, - name: "/opentelemetry.proto.collector.logs.v1.LogsService/Export", - req_mar: ::grpcio::Marshaller { - ser: ::grpcio::pr_ser, - de: ::grpcio::pr_de, - }, - resp_mar: ::grpcio::Marshaller { - ser: ::grpcio::pr_ser, - de: ::grpcio::pr_de, - }, -}; -#[derive(Clone)] -pub struct LogsServiceClient { - pub client: ::grpcio::Client, -} -impl LogsServiceClient { - pub fn new(channel: ::grpcio::Channel) -> Self { - LogsServiceClient { - client: ::grpcio::Client::new(channel), - } - } - pub fn export_opt( - &self, - req: &ExportLogsServiceRequest, - opt: ::grpcio::CallOption, - ) -> ::grpcio::Result { - self.client.unary_call(&METHOD_LOGS_SERVICE_EXPORT, req, opt) - } - pub fn export( - &self, - req: &ExportLogsServiceRequest, - ) -> ::grpcio::Result { - self.export_opt(req, ::grpcio::CallOption::default()) - } - pub fn export_async_opt( - &self, - req: &ExportLogsServiceRequest, - opt: ::grpcio::CallOption, - ) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { - self.client.unary_call_async(&METHOD_LOGS_SERVICE_EXPORT, req, opt) - } - pub fn export_async( - &self, - req: &ExportLogsServiceRequest, - ) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { - self.export_async_opt(req, ::grpcio::CallOption::default()) - } - pub fn spawn(&self, f: F) - where - F: ::std::future::Future + Send + 'static, - { - self.client.spawn(f) - } -} -pub trait LogsService { - fn export( - &mut self, - ctx: ::grpcio::RpcContext, - _req: ExportLogsServiceRequest, - sink: ::grpcio::UnarySink, - ) { - grpcio::unimplemented_call!(ctx, sink) - } -} -pub fn create_logs_service( - s: S, -) -> ::grpcio::Service { - let mut builder = ::grpcio::ServiceBuilder::new(); - let mut instance = s; - builder = builder - .add_unary_handler( - &METHOD_LOGS_SERVICE_EXPORT, - move |ctx, req, resp| instance.export(ctx, req, resp), - ); - builder.build() -} diff --git a/opentelemetry-proto/src/proto/grpcio/opentelemetry.proto.collector.metrics.v1.rs b/opentelemetry-proto/src/proto/grpcio/opentelemetry.proto.collector.metrics.v1.rs deleted file mode 100644 index 744263e8d6..0000000000 --- a/opentelemetry-proto/src/proto/grpcio/opentelemetry.proto.collector.metrics.v1.rs +++ /dev/null @@ -1,133 +0,0 @@ -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ExportMetricsServiceRequest { - /// An array of ResourceMetrics. - /// For data coming from a single resource this array will typically contain one - /// element. Intermediary nodes (such as OpenTelemetry Collector) that receive - /// data from multiple origins typically batch the data before forwarding further and - /// in that case this array will contain multiple elements. - #[prost(message, repeated, tag = "1")] - pub resource_metrics: ::prost::alloc::vec::Vec< - super::super::super::metrics::v1::ResourceMetrics, - >, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ExportMetricsServiceResponse { - /// The details of a partially successful export request. - /// - /// If the request is only partially accepted - /// (i.e. when the server accepts only parts of the data and rejects the rest) - /// the server MUST initialize the `partial_success` field and MUST - /// set the `rejected_` with the number of items it rejected. - /// - /// Servers MAY also make use of the `partial_success` field to convey - /// warnings/suggestions to senders even when the request was fully accepted. - /// In such cases, the `rejected_` MUST have a value of `0` and - /// the `error_message` MUST be non-empty. - /// - /// A `partial_success` message with an empty value (rejected_ = 0 and - /// `error_message` = "") is equivalent to it not being set/present. Senders - /// SHOULD interpret it the same way as in the full success case. - #[prost(message, optional, tag = "1")] - pub partial_success: ::core::option::Option, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ExportMetricsPartialSuccess { - /// The number of rejected data points. - /// - /// A `rejected_` field holding a `0` value indicates that the - /// request was fully accepted. - #[prost(int64, tag = "1")] - pub rejected_data_points: i64, - /// A developer-facing human-readable message in English. It should be used - /// either to explain why the server rejected parts of the data during a partial - /// success or to convey warnings/suggestions during a full success. The message - /// should offer guidance on how users can address such issues. - /// - /// error_message is an optional field. An error_message with an empty value - /// is equivalent to it not being set. - #[prost(string, tag = "2")] - pub error_message: ::prost::alloc::string::String, -} -const METHOD_METRICS_SERVICE_EXPORT: ::grpcio::Method< - ExportMetricsServiceRequest, - ExportMetricsServiceResponse, -> = ::grpcio::Method { - ty: ::grpcio::MethodType::Unary, - name: "/opentelemetry.proto.collector.metrics.v1.MetricsService/Export", - req_mar: ::grpcio::Marshaller { - ser: ::grpcio::pr_ser, - de: ::grpcio::pr_de, - }, - resp_mar: ::grpcio::Marshaller { - ser: ::grpcio::pr_ser, - de: ::grpcio::pr_de, - }, -}; -#[derive(Clone)] -pub struct MetricsServiceClient { - pub client: ::grpcio::Client, -} -impl MetricsServiceClient { - pub fn new(channel: ::grpcio::Channel) -> Self { - MetricsServiceClient { - client: ::grpcio::Client::new(channel), - } - } - pub fn export_opt( - &self, - req: &ExportMetricsServiceRequest, - opt: ::grpcio::CallOption, - ) -> ::grpcio::Result { - self.client.unary_call(&METHOD_METRICS_SERVICE_EXPORT, req, opt) - } - pub fn export( - &self, - req: &ExportMetricsServiceRequest, - ) -> ::grpcio::Result { - self.export_opt(req, ::grpcio::CallOption::default()) - } - pub fn export_async_opt( - &self, - req: &ExportMetricsServiceRequest, - opt: ::grpcio::CallOption, - ) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { - self.client.unary_call_async(&METHOD_METRICS_SERVICE_EXPORT, req, opt) - } - pub fn export_async( - &self, - req: &ExportMetricsServiceRequest, - ) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { - self.export_async_opt(req, ::grpcio::CallOption::default()) - } - pub fn spawn(&self, f: F) - where - F: ::std::future::Future + Send + 'static, - { - self.client.spawn(f) - } -} -pub trait MetricsService { - fn export( - &mut self, - ctx: ::grpcio::RpcContext, - _req: ExportMetricsServiceRequest, - sink: ::grpcio::UnarySink, - ) { - grpcio::unimplemented_call!(ctx, sink) - } -} -pub fn create_metrics_service( - s: S, -) -> ::grpcio::Service { - let mut builder = ::grpcio::ServiceBuilder::new(); - let mut instance = s; - builder = builder - .add_unary_handler( - &METHOD_METRICS_SERVICE_EXPORT, - move |ctx, req, resp| instance.export(ctx, req, resp), - ); - builder.build() -} diff --git a/opentelemetry-proto/src/proto/grpcio/opentelemetry.proto.collector.trace.v1.rs b/opentelemetry-proto/src/proto/grpcio/opentelemetry.proto.collector.trace.v1.rs deleted file mode 100644 index 82687ff765..0000000000 --- a/opentelemetry-proto/src/proto/grpcio/opentelemetry.proto.collector.trace.v1.rs +++ /dev/null @@ -1,133 +0,0 @@ -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ExportTraceServiceRequest { - /// An array of ResourceSpans. - /// For data coming from a single resource this array will typically contain one - /// element. Intermediary nodes (such as OpenTelemetry Collector) that receive - /// data from multiple origins typically batch the data before forwarding further and - /// in that case this array will contain multiple elements. - #[prost(message, repeated, tag = "1")] - pub resource_spans: ::prost::alloc::vec::Vec< - super::super::super::trace::v1::ResourceSpans, - >, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ExportTraceServiceResponse { - /// The details of a partially successful export request. - /// - /// If the request is only partially accepted - /// (i.e. when the server accepts only parts of the data and rejects the rest) - /// the server MUST initialize the `partial_success` field and MUST - /// set the `rejected_` with the number of items it rejected. - /// - /// Servers MAY also make use of the `partial_success` field to convey - /// warnings/suggestions to senders even when the request was fully accepted. - /// In such cases, the `rejected_` MUST have a value of `0` and - /// the `error_message` MUST be non-empty. - /// - /// A `partial_success` message with an empty value (rejected_ = 0 and - /// `error_message` = "") is equivalent to it not being set/present. Senders - /// SHOULD interpret it the same way as in the full success case. - #[prost(message, optional, tag = "1")] - pub partial_success: ::core::option::Option, -} -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ExportTracePartialSuccess { - /// The number of rejected spans. - /// - /// A `rejected_` field holding a `0` value indicates that the - /// request was fully accepted. - #[prost(int64, tag = "1")] - pub rejected_spans: i64, - /// A developer-facing human-readable message in English. It should be used - /// either to explain why the server rejected parts of the data during a partial - /// success or to convey warnings/suggestions during a full success. The message - /// should offer guidance on how users can address such issues. - /// - /// error_message is an optional field. An error_message with an empty value - /// is equivalent to it not being set. - #[prost(string, tag = "2")] - pub error_message: ::prost::alloc::string::String, -} -const METHOD_TRACE_SERVICE_EXPORT: ::grpcio::Method< - ExportTraceServiceRequest, - ExportTraceServiceResponse, -> = ::grpcio::Method { - ty: ::grpcio::MethodType::Unary, - name: "/opentelemetry.proto.collector.trace.v1.TraceService/Export", - req_mar: ::grpcio::Marshaller { - ser: ::grpcio::pr_ser, - de: ::grpcio::pr_de, - }, - resp_mar: ::grpcio::Marshaller { - ser: ::grpcio::pr_ser, - de: ::grpcio::pr_de, - }, -}; -#[derive(Clone)] -pub struct TraceServiceClient { - pub client: ::grpcio::Client, -} -impl TraceServiceClient { - pub fn new(channel: ::grpcio::Channel) -> Self { - TraceServiceClient { - client: ::grpcio::Client::new(channel), - } - } - pub fn export_opt( - &self, - req: &ExportTraceServiceRequest, - opt: ::grpcio::CallOption, - ) -> ::grpcio::Result { - self.client.unary_call(&METHOD_TRACE_SERVICE_EXPORT, req, opt) - } - pub fn export( - &self, - req: &ExportTraceServiceRequest, - ) -> ::grpcio::Result { - self.export_opt(req, ::grpcio::CallOption::default()) - } - pub fn export_async_opt( - &self, - req: &ExportTraceServiceRequest, - opt: ::grpcio::CallOption, - ) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { - self.client.unary_call_async(&METHOD_TRACE_SERVICE_EXPORT, req, opt) - } - pub fn export_async( - &self, - req: &ExportTraceServiceRequest, - ) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { - self.export_async_opt(req, ::grpcio::CallOption::default()) - } - pub fn spawn(&self, f: F) - where - F: ::std::future::Future + Send + 'static, - { - self.client.spawn(f) - } -} -pub trait TraceService { - fn export( - &mut self, - ctx: ::grpcio::RpcContext, - _req: ExportTraceServiceRequest, - sink: ::grpcio::UnarySink, - ) { - grpcio::unimplemented_call!(ctx, sink) - } -} -pub fn create_trace_service( - s: S, -) -> ::grpcio::Service { - let mut builder = ::grpcio::ServiceBuilder::new(); - let mut instance = s; - builder = builder - .add_unary_handler( - &METHOD_TRACE_SERVICE_EXPORT, - move |ctx, req, resp| instance.export(ctx, req, resp), - ); - builder.build() -} diff --git a/opentelemetry-proto/src/proto/grpcio/opentelemetry.proto.common.v1.rs b/opentelemetry-proto/src/proto/grpcio/opentelemetry.proto.common.v1.rs deleted file mode 100644 index f2450f761d..0000000000 --- a/opentelemetry-proto/src/proto/grpcio/opentelemetry.proto.common.v1.rs +++ /dev/null @@ -1,86 +0,0 @@ -/// AnyValue is used to represent any type of attribute value. AnyValue may contain a -/// primitive value such as a string or integer or it may contain an arbitrary nested -/// object containing arrays, key-value lists and primitives. -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct AnyValue { - /// The value is one of the listed fields. It is valid for all values to be unspecified - /// in which case this AnyValue is considered to be "empty". - #[prost(oneof = "any_value::Value", tags = "1, 2, 3, 4, 5, 6, 7")] - pub value: ::core::option::Option, -} -/// Nested message and enum types in `AnyValue`. -pub mod any_value { - /// The value is one of the listed fields. It is valid for all values to be unspecified - /// in which case this AnyValue is considered to be "empty". - #[allow(clippy::derive_partial_eq_without_eq)] - #[derive(Clone, PartialEq, ::prost::Oneof)] - pub enum Value { - #[prost(string, tag = "1")] - StringValue(::prost::alloc::string::String), - #[prost(bool, tag = "2")] - BoolValue(bool), - #[prost(int64, tag = "3")] - IntValue(i64), - #[prost(double, tag = "4")] - DoubleValue(f64), - #[prost(message, tag = "5")] - ArrayValue(super::ArrayValue), - #[prost(message, tag = "6")] - KvlistValue(super::KeyValueList), - #[prost(bytes, tag = "7")] - BytesValue(::prost::alloc::vec::Vec), - } -} -/// ArrayValue is a list of AnyValue messages. We need ArrayValue as a message -/// since oneof in AnyValue does not allow repeated fields. -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ArrayValue { - /// Array of values. The array may be empty (contain 0 elements). - #[prost(message, repeated, tag = "1")] - pub values: ::prost::alloc::vec::Vec, -} -/// KeyValueList is a list of KeyValue messages. We need KeyValueList as a message -/// since `oneof` in AnyValue does not allow repeated fields. Everywhere else where we need -/// a list of KeyValue messages (e.g. in Span) we use `repeated KeyValue` directly to -/// avoid unnecessary extra wrapping (which slows down the protocol). The 2 approaches -/// are semantically equivalent. -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct KeyValueList { - /// A collection of key/value pairs of key-value pairs. The list may be empty (may - /// contain 0 elements). - /// The keys MUST be unique (it is not allowed to have more than one - /// value with the same key). - #[prost(message, repeated, tag = "1")] - pub values: ::prost::alloc::vec::Vec, -} -/// KeyValue is a key-value pair that is used to store Span attributes, Link -/// attributes, etc. -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct KeyValue { - #[prost(string, tag = "1")] - pub key: ::prost::alloc::string::String, - #[prost(message, optional, tag = "2")] - pub value: ::core::option::Option, -} -/// InstrumentationScope is a message representing the instrumentation scope information -/// such as the fully qualified name and version. -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct InstrumentationScope { - /// An empty instrumentation scope name means the name is unknown. - #[prost(string, tag = "1")] - pub name: ::prost::alloc::string::String, - #[prost(string, tag = "2")] - pub version: ::prost::alloc::string::String, - /// Additional attributes that describe the scope. \[Optional\]. - /// Attribute keys MUST be unique (it is not allowed to have more than one - /// attribute with the same key). - #[prost(message, repeated, tag = "3")] - pub attributes: ::prost::alloc::vec::Vec, - #[prost(uint32, tag = "4")] - pub dropped_attributes_count: u32, -} diff --git a/opentelemetry-proto/src/proto/grpcio/opentelemetry.proto.logs.v1.rs b/opentelemetry-proto/src/proto/grpcio/opentelemetry.proto.logs.v1.rs deleted file mode 100644 index 3c2310e3e8..0000000000 --- a/opentelemetry-proto/src/proto/grpcio/opentelemetry.proto.logs.v1.rs +++ /dev/null @@ -1,275 +0,0 @@ -/// LogsData represents the logs data that can be stored in a persistent storage, -/// OR can be embedded by other protocols that transfer OTLP logs data but do not -/// implement the OTLP protocol. -/// -/// The main difference between this message and collector protocol is that -/// in this message there will not be any "control" or "metadata" specific to -/// OTLP protocol. -/// -/// When new fields are added into this message, the OTLP request MUST be updated -/// as well. -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct LogsData { - /// An array of ResourceLogs. - /// For data coming from a single resource this array will typically contain - /// one element. Intermediary nodes that receive data from multiple origins - /// typically batch the data before forwarding further and in that case this - /// array will contain multiple elements. - #[prost(message, repeated, tag = "1")] - pub resource_logs: ::prost::alloc::vec::Vec, -} -/// A collection of ScopeLogs from a Resource. -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ResourceLogs { - /// The resource for the logs in this message. - /// If this field is not set then resource info is unknown. - #[prost(message, optional, tag = "1")] - pub resource: ::core::option::Option, - /// A list of ScopeLogs that originate from a resource. - #[prost(message, repeated, tag = "2")] - pub scope_logs: ::prost::alloc::vec::Vec, - /// The Schema URL, if known. This is the identifier of the Schema that the resource data - /// is recorded in. To learn more about Schema URL see - /// - /// This schema_url applies to the data in the "resource" field. It does not apply - /// to the data in the "scope_logs" field which have their own schema_url field. - #[prost(string, tag = "3")] - pub schema_url: ::prost::alloc::string::String, -} -/// A collection of Logs produced by a Scope. -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ScopeLogs { - /// The instrumentation scope information for the logs in this message. - /// Semantically when InstrumentationScope isn't set, it is equivalent with - /// an empty instrumentation scope name (unknown). - #[prost(message, optional, tag = "1")] - pub scope: ::core::option::Option, - /// A list of log records. - #[prost(message, repeated, tag = "2")] - pub log_records: ::prost::alloc::vec::Vec, - /// The Schema URL, if known. This is the identifier of the Schema that the log data - /// is recorded in. To learn more about Schema URL see - /// - /// This schema_url applies to all logs in the "logs" field. - #[prost(string, tag = "3")] - pub schema_url: ::prost::alloc::string::String, -} -/// A log record according to OpenTelemetry Log Data Model: -/// -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct LogRecord { - /// time_unix_nano is the time when the event occurred. - /// Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970. - /// Value of 0 indicates unknown or missing timestamp. - #[prost(fixed64, tag = "1")] - pub time_unix_nano: u64, - /// Time when the event was observed by the collection system. - /// For events that originate in OpenTelemetry (e.g. using OpenTelemetry Logging SDK) - /// this timestamp is typically set at the generation time and is equal to Timestamp. - /// For events originating externally and collected by OpenTelemetry (e.g. using - /// Collector) this is the time when OpenTelemetry's code observed the event measured - /// by the clock of the OpenTelemetry code. This field MUST be set once the event is - /// observed by OpenTelemetry. - /// - /// For converting OpenTelemetry log data to formats that support only one timestamp or - /// when receiving OpenTelemetry log data by recipients that support only one timestamp - /// internally the following logic is recommended: - /// - Use time_unix_nano if it is present, otherwise use observed_time_unix_nano. - /// - /// Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970. - /// Value of 0 indicates unknown or missing timestamp. - #[prost(fixed64, tag = "11")] - pub observed_time_unix_nano: u64, - /// Numerical value of the severity, normalized to values described in Log Data Model. - /// \[Optional\]. - #[prost(enumeration = "SeverityNumber", tag = "2")] - pub severity_number: i32, - /// The severity text (also known as log level). The original string representation as - /// it is known at the source. \[Optional\]. - #[prost(string, tag = "3")] - pub severity_text: ::prost::alloc::string::String, - /// A value containing the body of the log record. Can be for example a human-readable - /// string message (including multi-line) describing the event in a free form or it can - /// be a structured data composed of arrays and maps of other values. \[Optional\]. - #[prost(message, optional, tag = "5")] - pub body: ::core::option::Option, - /// Additional attributes that describe the specific event occurrence. \[Optional\]. - /// Attribute keys MUST be unique (it is not allowed to have more than one - /// attribute with the same key). - #[prost(message, repeated, tag = "6")] - pub attributes: ::prost::alloc::vec::Vec, - #[prost(uint32, tag = "7")] - pub dropped_attributes_count: u32, - /// Flags, a bit field. 8 least significant bits are the trace flags as - /// defined in W3C Trace Context specification. 24 most significant bits are reserved - /// and must be set to 0. Readers must not assume that 24 most significant bits - /// will be zero and must correctly mask the bits when reading 8-bit trace flag (use - /// flags & LOG_RECORD_FLAGS_TRACE_FLAGS_MASK). \[Optional\]. - #[prost(fixed32, tag = "8")] - pub flags: u32, - /// A unique identifier for a trace. All logs from the same trace share - /// the same `trace_id`. The ID is a 16-byte array. An ID with all zeroes OR - /// of length other than 16 bytes is considered invalid (empty string in OTLP/JSON - /// is zero-length and thus is also invalid). - /// - /// This field is optional. - /// - /// The receivers SHOULD assume that the log record is not associated with a - /// trace if any of the following is true: - /// - the field is not present, - /// - the field contains an invalid value. - #[prost(bytes = "vec", tag = "9")] - 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 OR of length - /// other than 8 bytes is considered invalid (empty string in OTLP/JSON - /// is zero-length and thus is also invalid). - /// - /// This field is optional. If the sender specifies a valid span_id then it SHOULD also - /// specify a valid trace_id. - /// - /// The receivers SHOULD assume that the log record is not associated with a - /// span if any of the following is true: - /// - the field is not present, - /// - the field contains an invalid value. - #[prost(bytes = "vec", tag = "10")] - pub span_id: ::prost::alloc::vec::Vec, -} -/// Possible values for LogRecord.SeverityNumber. -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] -#[repr(i32)] -pub enum SeverityNumber { - /// UNSPECIFIED is the default SeverityNumber, it MUST NOT be used. - Unspecified = 0, - Trace = 1, - Trace2 = 2, - Trace3 = 3, - Trace4 = 4, - Debug = 5, - Debug2 = 6, - Debug3 = 7, - Debug4 = 8, - Info = 9, - Info2 = 10, - Info3 = 11, - Info4 = 12, - Warn = 13, - Warn2 = 14, - Warn3 = 15, - Warn4 = 16, - Error = 17, - Error2 = 18, - Error3 = 19, - Error4 = 20, - Fatal = 21, - Fatal2 = 22, - Fatal3 = 23, - Fatal4 = 24, -} -impl SeverityNumber { - /// 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 { - SeverityNumber::Unspecified => "SEVERITY_NUMBER_UNSPECIFIED", - SeverityNumber::Trace => "SEVERITY_NUMBER_TRACE", - SeverityNumber::Trace2 => "SEVERITY_NUMBER_TRACE2", - SeverityNumber::Trace3 => "SEVERITY_NUMBER_TRACE3", - SeverityNumber::Trace4 => "SEVERITY_NUMBER_TRACE4", - SeverityNumber::Debug => "SEVERITY_NUMBER_DEBUG", - SeverityNumber::Debug2 => "SEVERITY_NUMBER_DEBUG2", - SeverityNumber::Debug3 => "SEVERITY_NUMBER_DEBUG3", - SeverityNumber::Debug4 => "SEVERITY_NUMBER_DEBUG4", - SeverityNumber::Info => "SEVERITY_NUMBER_INFO", - SeverityNumber::Info2 => "SEVERITY_NUMBER_INFO2", - SeverityNumber::Info3 => "SEVERITY_NUMBER_INFO3", - SeverityNumber::Info4 => "SEVERITY_NUMBER_INFO4", - SeverityNumber::Warn => "SEVERITY_NUMBER_WARN", - SeverityNumber::Warn2 => "SEVERITY_NUMBER_WARN2", - SeverityNumber::Warn3 => "SEVERITY_NUMBER_WARN3", - SeverityNumber::Warn4 => "SEVERITY_NUMBER_WARN4", - SeverityNumber::Error => "SEVERITY_NUMBER_ERROR", - SeverityNumber::Error2 => "SEVERITY_NUMBER_ERROR2", - SeverityNumber::Error3 => "SEVERITY_NUMBER_ERROR3", - SeverityNumber::Error4 => "SEVERITY_NUMBER_ERROR4", - SeverityNumber::Fatal => "SEVERITY_NUMBER_FATAL", - SeverityNumber::Fatal2 => "SEVERITY_NUMBER_FATAL2", - SeverityNumber::Fatal3 => "SEVERITY_NUMBER_FATAL3", - SeverityNumber::Fatal4 => "SEVERITY_NUMBER_FATAL4", - } - } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "SEVERITY_NUMBER_UNSPECIFIED" => Some(Self::Unspecified), - "SEVERITY_NUMBER_TRACE" => Some(Self::Trace), - "SEVERITY_NUMBER_TRACE2" => Some(Self::Trace2), - "SEVERITY_NUMBER_TRACE3" => Some(Self::Trace3), - "SEVERITY_NUMBER_TRACE4" => Some(Self::Trace4), - "SEVERITY_NUMBER_DEBUG" => Some(Self::Debug), - "SEVERITY_NUMBER_DEBUG2" => Some(Self::Debug2), - "SEVERITY_NUMBER_DEBUG3" => Some(Self::Debug3), - "SEVERITY_NUMBER_DEBUG4" => Some(Self::Debug4), - "SEVERITY_NUMBER_INFO" => Some(Self::Info), - "SEVERITY_NUMBER_INFO2" => Some(Self::Info2), - "SEVERITY_NUMBER_INFO3" => Some(Self::Info3), - "SEVERITY_NUMBER_INFO4" => Some(Self::Info4), - "SEVERITY_NUMBER_WARN" => Some(Self::Warn), - "SEVERITY_NUMBER_WARN2" => Some(Self::Warn2), - "SEVERITY_NUMBER_WARN3" => Some(Self::Warn3), - "SEVERITY_NUMBER_WARN4" => Some(Self::Warn4), - "SEVERITY_NUMBER_ERROR" => Some(Self::Error), - "SEVERITY_NUMBER_ERROR2" => Some(Self::Error2), - "SEVERITY_NUMBER_ERROR3" => Some(Self::Error3), - "SEVERITY_NUMBER_ERROR4" => Some(Self::Error4), - "SEVERITY_NUMBER_FATAL" => Some(Self::Fatal), - "SEVERITY_NUMBER_FATAL2" => Some(Self::Fatal2), - "SEVERITY_NUMBER_FATAL3" => Some(Self::Fatal3), - "SEVERITY_NUMBER_FATAL4" => Some(Self::Fatal4), - _ => None, - } - } -} -/// LogRecordFlags represents constants used to interpret the -/// LogRecord.flags field, which is protobuf 'fixed32' type and is to -/// be used as bit-fields. Each non-zero value defined in this enum is -/// a bit-mask. To extract the bit-field, for example, use an -/// expression like: -/// -/// (logRecord.flags & LOG_RECORD_FLAGS_TRACE_FLAGS_MASK) -/// -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] -#[repr(i32)] -pub enum LogRecordFlags { - /// The zero value for the enum. Should not be used for comparisons. - /// Instead use bitwise "and" with the appropriate mask as shown above. - DoNotUse = 0, - /// Bits 0-7 are used for trace flags. - TraceFlagsMask = 255, -} -impl LogRecordFlags { - /// 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 { - LogRecordFlags::DoNotUse => "LOG_RECORD_FLAGS_DO_NOT_USE", - LogRecordFlags::TraceFlagsMask => "LOG_RECORD_FLAGS_TRACE_FLAGS_MASK", - } - } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "LOG_RECORD_FLAGS_DO_NOT_USE" => Some(Self::DoNotUse), - "LOG_RECORD_FLAGS_TRACE_FLAGS_MASK" => Some(Self::TraceFlagsMask), - _ => None, - } - } -} diff --git a/opentelemetry-proto/src/proto/grpcio/opentelemetry.proto.metrics.v1.rs b/opentelemetry-proto/src/proto/grpcio/opentelemetry.proto.metrics.v1.rs deleted file mode 100644 index ce044ccc65..0000000000 --- a/opentelemetry-proto/src/proto/grpcio/opentelemetry.proto.metrics.v1.rs +++ /dev/null @@ -1,760 +0,0 @@ -/// MetricsData represents the metrics data that can be stored in a persistent -/// storage, OR can be embedded by other protocols that transfer OTLP metrics -/// data but do not implement the OTLP protocol. -/// -/// The main difference between this message and collector protocol is that -/// in this message there will not be any "control" or "metadata" specific to -/// OTLP protocol. -/// -/// When new fields are added into this message, the OTLP request MUST be updated -/// as well. -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct MetricsData { - /// An array of ResourceMetrics. - /// For data coming from a single resource this array will typically contain - /// one element. Intermediary nodes that receive data from multiple origins - /// typically batch the data before forwarding further and in that case this - /// array will contain multiple elements. - #[prost(message, repeated, tag = "1")] - pub resource_metrics: ::prost::alloc::vec::Vec, -} -/// A collection of ScopeMetrics from a Resource. -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ResourceMetrics { - /// The resource for the metrics in this message. - /// If this field is not set then no resource info is known. - #[prost(message, optional, tag = "1")] - pub resource: ::core::option::Option, - /// A list of metrics that originate from a resource. - #[prost(message, repeated, tag = "2")] - pub scope_metrics: ::prost::alloc::vec::Vec, - /// The Schema URL, if known. This is the identifier of the Schema that the resource data - /// is recorded in. To learn more about Schema URL see - /// - /// This schema_url applies to the data in the "resource" field. It does not apply - /// to the data in the "scope_metrics" field which have their own schema_url field. - #[prost(string, tag = "3")] - pub schema_url: ::prost::alloc::string::String, -} -/// A collection of Metrics produced by an Scope. -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ScopeMetrics { - /// The instrumentation scope information for the metrics in this message. - /// Semantically when InstrumentationScope isn't set, it is equivalent with - /// an empty instrumentation scope name (unknown). - #[prost(message, optional, tag = "1")] - pub scope: ::core::option::Option, - /// A list of metrics that originate from an instrumentation library. - #[prost(message, repeated, tag = "2")] - pub metrics: ::prost::alloc::vec::Vec, - /// The Schema URL, if known. This is the identifier of the Schema that the metric data - /// is recorded in. To learn more about Schema URL see - /// - /// This schema_url applies to all metrics in the "metrics" field. - #[prost(string, tag = "3")] - pub schema_url: ::prost::alloc::string::String, -} -/// Defines a Metric which has one or more timeseries. The following is a -/// brief summary of the Metric data model. For more details, see: -/// -/// -/// -/// -/// The data model and relation between entities is shown in the -/// diagram below. Here, "DataPoint" is the term used to refer to any -/// one of the specific data point value types, and "points" is the term used -/// to refer to any one of the lists of points contained in the Metric. -/// -/// - Metric is composed of a metadata and data. -/// - Metadata part contains a name, description, unit. -/// - Data is one of the possible types (Sum, Gauge, Histogram, Summary). -/// - DataPoint contains timestamps, attributes, and one of the possible value type -/// fields. -/// -/// Metric -/// +------------+ -/// |name | -/// |description | -/// |unit | +------------------------------------+ -/// |data |---> |Gauge, Sum, Histogram, Summary, ... | -/// +------------+ +------------------------------------+ -/// -/// Data [One of Gauge, Sum, Histogram, Summary, ...] -/// +-----------+ -/// |... | // Metadata about the Data. -/// |points |--+ -/// +-----------+ | -/// | +---------------------------+ -/// | |DataPoint 1 | -/// v |+------+------+ +------+ | -/// +-----+ ||label |label |...|label | | -/// | 1 |-->||value1|value2|...|valueN| | -/// +-----+ |+------+------+ +------+ | -/// | . | |+-----+ | -/// | . | ||value| | -/// | . | |+-----+ | -/// | . | +---------------------------+ -/// | . | . -/// | . | . -/// | . | . -/// | . | +---------------------------+ -/// | . | |DataPoint M | -/// +-----+ |+------+------+ +------+ | -/// | M |-->||label |label |...|label | | -/// +-----+ ||value1|value2|...|valueN| | -/// |+------+------+ +------+ | -/// |+-----+ | -/// ||value| | -/// |+-----+ | -/// +---------------------------+ -/// -/// Each distinct type of DataPoint represents the output of a specific -/// aggregation function, the result of applying the DataPoint's -/// associated function of to one or more measurements. -/// -/// All DataPoint types have three common fields: -/// - Attributes includes key-value pairs associated with the data point -/// - TimeUnixNano is required, set to the end time of the aggregation -/// - StartTimeUnixNano is optional, but strongly encouraged for DataPoints -/// having an AggregationTemporality field, as discussed below. -/// -/// Both TimeUnixNano and StartTimeUnixNano values are expressed as -/// UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970. -/// -/// # TimeUnixNano -/// -/// This field is required, having consistent interpretation across -/// DataPoint types. TimeUnixNano is the moment corresponding to when -/// the data point's aggregate value was captured. -/// -/// Data points with the 0 value for TimeUnixNano SHOULD be rejected -/// by consumers. -/// -/// # StartTimeUnixNano -/// -/// StartTimeUnixNano in general allows detecting when a sequence of -/// observations is unbroken. This field indicates to consumers the -/// start time for points with cumulative and delta -/// AggregationTemporality, and it should be included whenever possible -/// to support correct rate calculation. Although it may be omitted -/// when the start time is truly unknown, setting StartTimeUnixNano is -/// strongly encouraged. -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Metric { - /// name of the metric. - #[prost(string, tag = "1")] - pub name: ::prost::alloc::string::String, - /// description of the metric, which can be used in documentation. - #[prost(string, tag = "2")] - pub description: ::prost::alloc::string::String, - /// unit in which the metric value is reported. Follows the format - /// described by - #[prost(string, tag = "3")] - pub unit: ::prost::alloc::string::String, - /// Data determines the aggregation type (if any) of the metric, what is the - /// reported value type for the data points, as well as the relatationship to - /// the time interval over which they are reported. - #[prost(oneof = "metric::Data", tags = "5, 7, 9, 10, 11")] - pub data: ::core::option::Option, -} -/// Nested message and enum types in `Metric`. -pub mod metric { - /// Data determines the aggregation type (if any) of the metric, what is the - /// reported value type for the data points, as well as the relatationship to - /// the time interval over which they are reported. - #[allow(clippy::derive_partial_eq_without_eq)] - #[derive(Clone, PartialEq, ::prost::Oneof)] - pub enum Data { - #[prost(message, tag = "5")] - Gauge(super::Gauge), - #[prost(message, tag = "7")] - Sum(super::Sum), - #[prost(message, tag = "9")] - Histogram(super::Histogram), - #[prost(message, tag = "10")] - ExponentialHistogram(super::ExponentialHistogram), - #[prost(message, tag = "11")] - Summary(super::Summary), - } -} -/// Gauge represents the type of a scalar metric that always exports the -/// "current value" for every data point. It should be used for an "unknown" -/// aggregation. -/// -/// A Gauge does not support different aggregation temporalities. Given the -/// aggregation is unknown, points cannot be combined using the same -/// aggregation, regardless of aggregation temporalities. Therefore, -/// AggregationTemporality is not included. Consequently, this also means -/// "StartTimeUnixNano" is ignored for all data points. -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Gauge { - #[prost(message, repeated, tag = "1")] - pub data_points: ::prost::alloc::vec::Vec, -} -/// Sum represents the type of a scalar metric that is calculated as a sum of all -/// reported measurements over a time interval. -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Sum { - #[prost(message, repeated, tag = "1")] - pub data_points: ::prost::alloc::vec::Vec, - /// aggregation_temporality describes if the aggregator reports delta changes - /// since last report time, or cumulative changes since a fixed start time. - #[prost(enumeration = "AggregationTemporality", tag = "2")] - pub aggregation_temporality: i32, - /// If "true" means that the sum is monotonic. - #[prost(bool, tag = "3")] - pub is_monotonic: bool, -} -/// Histogram represents the type of a metric that is calculated by aggregating -/// as a Histogram of all reported measurements over a time interval. -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Histogram { - #[prost(message, repeated, tag = "1")] - pub data_points: ::prost::alloc::vec::Vec, - /// aggregation_temporality describes if the aggregator reports delta changes - /// since last report time, or cumulative changes since a fixed start time. - #[prost(enumeration = "AggregationTemporality", tag = "2")] - pub aggregation_temporality: i32, -} -/// ExponentialHistogram represents the type of a metric that is calculated by aggregating -/// as a ExponentialHistogram of all reported double measurements over a time interval. -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ExponentialHistogram { - #[prost(message, repeated, tag = "1")] - pub data_points: ::prost::alloc::vec::Vec, - /// aggregation_temporality describes if the aggregator reports delta changes - /// since last report time, or cumulative changes since a fixed start time. - #[prost(enumeration = "AggregationTemporality", tag = "2")] - pub aggregation_temporality: i32, -} -/// Summary metric data are used to convey quantile summaries, -/// a Prometheus (see: ) -/// and OpenMetrics (see: ) -/// data type. These data points cannot always be merged in a meaningful way. -/// While they can be useful in some applications, histogram data points are -/// recommended for new applications. -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Summary { - #[prost(message, repeated, tag = "1")] - pub data_points: ::prost::alloc::vec::Vec, -} -/// NumberDataPoint is a single data point in a timeseries that describes the -/// time-varying scalar value of a metric. -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct NumberDataPoint { - /// The set of key/value pairs that uniquely identify the timeseries from - /// where this point belongs. The list may be empty (may contain 0 elements). - /// Attribute keys MUST be unique (it is not allowed to have more than one - /// attribute with the same key). - #[prost(message, repeated, tag = "7")] - pub attributes: ::prost::alloc::vec::Vec, - /// StartTimeUnixNano is optional but strongly encouraged, see the - /// the detailed comments above Metric. - /// - /// Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January - /// 1970. - #[prost(fixed64, tag = "2")] - pub start_time_unix_nano: u64, - /// TimeUnixNano is required, see the detailed comments above Metric. - /// - /// Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January - /// 1970. - #[prost(fixed64, tag = "3")] - pub time_unix_nano: u64, - /// (Optional) List of exemplars collected from - /// measurements that were used to form the data point - #[prost(message, repeated, tag = "5")] - pub exemplars: ::prost::alloc::vec::Vec, - /// Flags that apply to this specific data point. See DataPointFlags - /// for the available flags and their meaning. - #[prost(uint32, tag = "8")] - pub flags: u32, - /// The value itself. A point is considered invalid when one of the recognized - /// value fields is not present inside this oneof. - #[prost(oneof = "number_data_point::Value", tags = "4, 6")] - pub value: ::core::option::Option, -} -/// Nested message and enum types in `NumberDataPoint`. -pub mod number_data_point { - /// The value itself. A point is considered invalid when one of the recognized - /// value fields is not present inside this oneof. - #[allow(clippy::derive_partial_eq_without_eq)] - #[derive(Clone, PartialEq, ::prost::Oneof)] - pub enum Value { - #[prost(double, tag = "4")] - AsDouble(f64), - #[prost(sfixed64, tag = "6")] - AsInt(i64), - } -} -/// HistogramDataPoint is a single data point in a timeseries that describes the -/// time-varying values of a Histogram. A Histogram contains summary statistics -/// for a population of values, it may optionally contain the distribution of -/// those values across a set of buckets. -/// -/// If the histogram contains the distribution of values, then both -/// "explicit_bounds" and "bucket counts" fields must be defined. -/// If the histogram does not contain the distribution of values, then both -/// "explicit_bounds" and "bucket_counts" must be omitted and only "count" and -/// "sum" are known. -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct HistogramDataPoint { - /// The set of key/value pairs that uniquely identify the timeseries from - /// where this point belongs. The list may be empty (may contain 0 elements). - /// Attribute keys MUST be unique (it is not allowed to have more than one - /// attribute with the same key). - #[prost(message, repeated, tag = "9")] - pub attributes: ::prost::alloc::vec::Vec, - /// StartTimeUnixNano is optional but strongly encouraged, see the - /// the detailed comments above Metric. - /// - /// Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January - /// 1970. - #[prost(fixed64, tag = "2")] - pub start_time_unix_nano: u64, - /// TimeUnixNano is required, see the detailed comments above Metric. - /// - /// Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January - /// 1970. - #[prost(fixed64, tag = "3")] - pub time_unix_nano: u64, - /// count is the number of values in the population. Must be non-negative. This - /// value must be equal to the sum of the "count" fields in buckets if a - /// histogram is provided. - #[prost(fixed64, tag = "4")] - pub count: u64, - /// sum of the values in the population. If count is zero then this field - /// must be zero. - /// - /// Note: Sum should only be filled out when measuring non-negative discrete - /// events, and is assumed to be monotonic over the values of these events. - /// Negative events *can* be recorded, but sum should not be filled out when - /// doing so. This is specifically to enforce compatibility w/ OpenMetrics, - /// see: - #[prost(double, optional, tag = "5")] - pub sum: ::core::option::Option, - /// bucket_counts is an optional field contains the count values of histogram - /// for each bucket. - /// - /// The sum of the bucket_counts must equal the value in the count field. - /// - /// The number of elements in bucket_counts array must be by one greater than - /// the number of elements in explicit_bounds array. - #[prost(fixed64, repeated, tag = "6")] - pub bucket_counts: ::prost::alloc::vec::Vec, - /// explicit_bounds specifies buckets with explicitly defined bounds for values. - /// - /// The boundaries for bucket at index i are: - /// - /// (-infinity, explicit_bounds\[i]\] for i == 0 - /// (explicit_bounds\[i-1\], explicit_bounds\[i]\] for 0 < i < size(explicit_bounds) - /// (explicit_bounds\[i-1\], +infinity) for i == size(explicit_bounds) - /// - /// The values in the explicit_bounds array must be strictly increasing. - /// - /// Histogram buckets are inclusive of their upper boundary, except the last - /// bucket where the boundary is at infinity. This format is intentionally - /// compatible with the OpenMetrics histogram definition. - #[prost(double, repeated, tag = "7")] - pub explicit_bounds: ::prost::alloc::vec::Vec, - /// (Optional) List of exemplars collected from - /// measurements that were used to form the data point - #[prost(message, repeated, tag = "8")] - pub exemplars: ::prost::alloc::vec::Vec, - /// Flags that apply to this specific data point. See DataPointFlags - /// for the available flags and their meaning. - #[prost(uint32, tag = "10")] - pub flags: u32, - /// min is the minimum value over (start_time, end_time]. - #[prost(double, optional, tag = "11")] - pub min: ::core::option::Option, - /// max is the maximum value over (start_time, end_time]. - #[prost(double, optional, tag = "12")] - pub max: ::core::option::Option, -} -/// ExponentialHistogramDataPoint is a single data point in a timeseries that describes the -/// time-varying values of a ExponentialHistogram of double values. A ExponentialHistogram contains -/// summary statistics for a population of values, it may optionally contain the -/// distribution of those values across a set of buckets. -/// -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ExponentialHistogramDataPoint { - /// The set of key/value pairs that uniquely identify the timeseries from - /// where this point belongs. The list may be empty (may contain 0 elements). - /// Attribute keys MUST be unique (it is not allowed to have more than one - /// attribute with the same key). - #[prost(message, repeated, tag = "1")] - pub attributes: ::prost::alloc::vec::Vec, - /// StartTimeUnixNano is optional but strongly encouraged, see the - /// the detailed comments above Metric. - /// - /// Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January - /// 1970. - #[prost(fixed64, tag = "2")] - pub start_time_unix_nano: u64, - /// TimeUnixNano is required, see the detailed comments above Metric. - /// - /// Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January - /// 1970. - #[prost(fixed64, tag = "3")] - pub time_unix_nano: u64, - /// count is the number of values in the population. Must be - /// non-negative. This value must be equal to the sum of the "bucket_counts" - /// values in the positive and negative Buckets plus the "zero_count" field. - #[prost(fixed64, tag = "4")] - pub count: u64, - /// sum of the values in the population. If count is zero then this field - /// must be zero. - /// - /// Note: Sum should only be filled out when measuring non-negative discrete - /// events, and is assumed to be monotonic over the values of these events. - /// Negative events *can* be recorded, but sum should not be filled out when - /// doing so. This is specifically to enforce compatibility w/ OpenMetrics, - /// see: - #[prost(double, optional, tag = "5")] - pub sum: ::core::option::Option, - /// scale describes the resolution of the histogram. Boundaries are - /// located at powers of the base, where: - /// - /// base = (2^(2^-scale)) - /// - /// The histogram bucket identified by `index`, a signed integer, - /// contains values that are greater than (base^index) and - /// less than or equal to (base^(index+1)). - /// - /// The positive and negative ranges of the histogram are expressed - /// separately. Negative values are mapped by their absolute value - /// into the negative range using the same scale as the positive range. - /// - /// scale is not restricted by the protocol, as the permissible - /// values depend on the range of the data. - #[prost(sint32, tag = "6")] - pub scale: i32, - /// zero_count is the count of values that are either exactly zero or - /// within the region considered zero by the instrumentation at the - /// tolerated degree of precision. This bucket stores values that - /// cannot be expressed using the standard exponential formula as - /// well as values that have been rounded to zero. - /// - /// Implementations MAY consider the zero bucket to have probability - /// mass equal to (zero_count / count). - #[prost(fixed64, tag = "7")] - pub zero_count: u64, - /// positive carries the positive range of exponential bucket counts. - #[prost(message, optional, tag = "8")] - pub positive: ::core::option::Option, - /// negative carries the negative range of exponential bucket counts. - #[prost(message, optional, tag = "9")] - pub negative: ::core::option::Option, - /// Flags that apply to this specific data point. See DataPointFlags - /// for the available flags and their meaning. - #[prost(uint32, tag = "10")] - pub flags: u32, - /// (Optional) List of exemplars collected from - /// measurements that were used to form the data point - #[prost(message, repeated, tag = "11")] - pub exemplars: ::prost::alloc::vec::Vec, - /// min is the minimum value over (start_time, end_time]. - #[prost(double, optional, tag = "12")] - pub min: ::core::option::Option, - /// max is the maximum value over (start_time, end_time]. - #[prost(double, optional, tag = "13")] - pub max: ::core::option::Option, - /// ZeroThreshold may be optionally set to convey the width of the zero - /// region. Where the zero region is defined as the closed interval - /// [-ZeroThreshold, ZeroThreshold]. - /// When ZeroThreshold is 0, zero count bucket stores values that cannot be - /// expressed using the standard exponential formula as well as values that - /// have been rounded to zero. - #[prost(double, tag = "14")] - pub zero_threshold: f64, -} -/// Nested message and enum types in `ExponentialHistogramDataPoint`. -pub mod exponential_histogram_data_point { - /// Buckets are a set of bucket counts, encoded in a contiguous array - /// of counts. - #[allow(clippy::derive_partial_eq_without_eq)] - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct Buckets { - /// Offset is the bucket index of the first entry in the bucket_counts array. - /// - /// Note: This uses a varint encoding as a simple form of compression. - #[prost(sint32, tag = "1")] - pub offset: i32, - /// bucket_counts is an array of count values, where bucket_counts\[i\] carries - /// the count of the bucket at index (offset+i). bucket_counts\[i\] is the count - /// of values greater than base^(offset+i) and less than or equal to - /// base^(offset+i+1). - /// - /// Note: By contrast, the explicit HistogramDataPoint uses - /// fixed64. This field is expected to have many buckets, - /// especially zeros, so uint64 has been selected to ensure - /// varint encoding. - #[prost(uint64, repeated, tag = "2")] - pub bucket_counts: ::prost::alloc::vec::Vec, - } -} -/// SummaryDataPoint is a single data point in a timeseries that describes the -/// time-varying values of a Summary metric. -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct SummaryDataPoint { - /// The set of key/value pairs that uniquely identify the timeseries from - /// where this point belongs. The list may be empty (may contain 0 elements). - /// Attribute keys MUST be unique (it is not allowed to have more than one - /// attribute with the same key). - #[prost(message, repeated, tag = "7")] - pub attributes: ::prost::alloc::vec::Vec, - /// StartTimeUnixNano is optional but strongly encouraged, see the - /// the detailed comments above Metric. - /// - /// Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January - /// 1970. - #[prost(fixed64, tag = "2")] - pub start_time_unix_nano: u64, - /// TimeUnixNano is required, see the detailed comments above Metric. - /// - /// Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January - /// 1970. - #[prost(fixed64, tag = "3")] - pub time_unix_nano: u64, - /// count is the number of values in the population. Must be non-negative. - #[prost(fixed64, tag = "4")] - pub count: u64, - /// sum of the values in the population. If count is zero then this field - /// must be zero. - /// - /// Note: Sum should only be filled out when measuring non-negative discrete - /// events, and is assumed to be monotonic over the values of these events. - /// Negative events *can* be recorded, but sum should not be filled out when - /// doing so. This is specifically to enforce compatibility w/ OpenMetrics, - /// see: - #[prost(double, tag = "5")] - pub sum: f64, - /// (Optional) list of values at different quantiles of the distribution calculated - /// from the current snapshot. The quantiles must be strictly increasing. - #[prost(message, repeated, tag = "6")] - pub quantile_values: ::prost::alloc::vec::Vec, - /// Flags that apply to this specific data point. See DataPointFlags - /// for the available flags and their meaning. - #[prost(uint32, tag = "8")] - pub flags: u32, -} -/// Nested message and enum types in `SummaryDataPoint`. -pub mod summary_data_point { - /// Represents the value at a given quantile of a distribution. - /// - /// To record Min and Max values following conventions are used: - /// - The 1.0 quantile is equivalent to the maximum value observed. - /// - The 0.0 quantile is equivalent to the minimum value observed. - /// - /// See the following issue for more context: - /// - #[allow(clippy::derive_partial_eq_without_eq)] - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct ValueAtQuantile { - /// The quantile of a distribution. Must be in the interval - /// [0.0, 1.0]. - #[prost(double, tag = "1")] - pub quantile: f64, - /// The value at the given quantile of a distribution. - /// - /// Quantile values must NOT be negative. - #[prost(double, tag = "2")] - pub value: f64, - } -} -/// A representation of an exemplar, which is a sample input measurement. -/// Exemplars also hold information about the environment when the measurement -/// was recorded, for example the span and trace ID of the active span when the -/// exemplar was recorded. -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Exemplar { - /// The set of key/value pairs that were filtered out by the aggregator, but - /// recorded alongside the original measurement. Only key/value pairs that were - /// filtered out by the aggregator should be included - #[prost(message, repeated, tag = "7")] - pub filtered_attributes: ::prost::alloc::vec::Vec< - super::super::common::v1::KeyValue, - >, - /// time_unix_nano is the exact time when this exemplar was recorded - /// - /// Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January - /// 1970. - #[prost(fixed64, tag = "2")] - pub time_unix_nano: u64, - /// (Optional) Span ID of the exemplar trace. - /// span_id may be missing if the measurement is not recorded inside a trace - /// or if the trace is not sampled. - #[prost(bytes = "vec", tag = "4")] - pub span_id: ::prost::alloc::vec::Vec, - /// (Optional) Trace ID of the exemplar trace. - /// trace_id may be missing if the measurement is not recorded inside a trace - /// or if the trace is not sampled. - #[prost(bytes = "vec", tag = "5")] - pub trace_id: ::prost::alloc::vec::Vec, - /// The value of the measurement that was recorded. An exemplar is - /// considered invalid when one of the recognized value fields is not present - /// inside this oneof. - #[prost(oneof = "exemplar::Value", tags = "3, 6")] - pub value: ::core::option::Option, -} -/// Nested message and enum types in `Exemplar`. -pub mod exemplar { - /// The value of the measurement that was recorded. An exemplar is - /// considered invalid when one of the recognized value fields is not present - /// inside this oneof. - #[allow(clippy::derive_partial_eq_without_eq)] - #[derive(Clone, PartialEq, ::prost::Oneof)] - pub enum Value { - #[prost(double, tag = "3")] - AsDouble(f64), - #[prost(sfixed64, tag = "6")] - AsInt(i64), - } -} -/// AggregationTemporality defines how a metric aggregator reports aggregated -/// values. It describes how those values relate to the time interval over -/// which they are aggregated. -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] -#[repr(i32)] -pub enum AggregationTemporality { - /// UNSPECIFIED is the default AggregationTemporality, it MUST not be used. - Unspecified = 0, - /// DELTA is an AggregationTemporality for a metric aggregator which reports - /// changes since last report time. Successive metrics contain aggregation of - /// values from continuous and non-overlapping intervals. - /// - /// The values for a DELTA metric are based only on the time interval - /// associated with one measurement cycle. There is no dependency on - /// previous measurements like is the case for CUMULATIVE metrics. - /// - /// For example, consider a system measuring the number of requests that - /// it receives and reports the sum of these requests every second as a - /// DELTA metric: - /// - /// 1. The system starts receiving at time=t_0. - /// 2. A request is received, the system measures 1 request. - /// 3. A request is received, the system measures 1 request. - /// 4. A request is received, the system measures 1 request. - /// 5. The 1 second collection cycle ends. A metric is exported for the - /// number of requests received over the interval of time t_0 to - /// t_0+1 with a value of 3. - /// 6. A request is received, the system measures 1 request. - /// 7. A request is received, the system measures 1 request. - /// 8. The 1 second collection cycle ends. A metric is exported for the - /// number of requests received over the interval of time t_0+1 to - /// t_0+2 with a value of 2. - Delta = 1, - /// CUMULATIVE is an AggregationTemporality for a metric aggregator which - /// reports changes since a fixed start time. This means that current values - /// of a CUMULATIVE metric depend on all previous measurements since the - /// start time. Because of this, the sender is required to retain this state - /// in some form. If this state is lost or invalidated, the CUMULATIVE metric - /// values MUST be reset and a new fixed start time following the last - /// reported measurement time sent MUST be used. - /// - /// For example, consider a system measuring the number of requests that - /// it receives and reports the sum of these requests every second as a - /// CUMULATIVE metric: - /// - /// 1. The system starts receiving at time=t_0. - /// 2. A request is received, the system measures 1 request. - /// 3. A request is received, the system measures 1 request. - /// 4. A request is received, the system measures 1 request. - /// 5. The 1 second collection cycle ends. A metric is exported for the - /// number of requests received over the interval of time t_0 to - /// t_0+1 with a value of 3. - /// 6. A request is received, the system measures 1 request. - /// 7. A request is received, the system measures 1 request. - /// 8. The 1 second collection cycle ends. A metric is exported for the - /// number of requests received over the interval of time t_0 to - /// t_0+2 with a value of 5. - /// 9. The system experiences a fault and loses state. - /// 10. The system recovers and resumes receiving at time=t_1. - /// 11. A request is received, the system measures 1 request. - /// 12. The 1 second collection cycle ends. A metric is exported for the - /// number of requests received over the interval of time t_1 to - /// t_0+1 with a value of 1. - /// - /// Note: Even though, when reporting changes since last report time, using - /// CUMULATIVE is valid, it is not recommended. This may cause problems for - /// systems that do not use start_time to determine when the aggregation - /// value was reset (e.g. Prometheus). - Cumulative = 2, -} -impl AggregationTemporality { - /// 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 { - AggregationTemporality::Unspecified => "AGGREGATION_TEMPORALITY_UNSPECIFIED", - AggregationTemporality::Delta => "AGGREGATION_TEMPORALITY_DELTA", - AggregationTemporality::Cumulative => "AGGREGATION_TEMPORALITY_CUMULATIVE", - } - } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "AGGREGATION_TEMPORALITY_UNSPECIFIED" => Some(Self::Unspecified), - "AGGREGATION_TEMPORALITY_DELTA" => Some(Self::Delta), - "AGGREGATION_TEMPORALITY_CUMULATIVE" => Some(Self::Cumulative), - _ => None, - } - } -} -/// DataPointFlags is defined as a protobuf 'uint32' type and is to be used as a -/// bit-field representing 32 distinct boolean flags. Each flag defined in this -/// enum is a bit-mask. To test the presence of a single flag in the flags of -/// a data point, for example, use an expression like: -/// -/// (point.flags & DATA_POINT_FLAGS_NO_RECORDED_VALUE_MASK) == DATA_POINT_FLAGS_NO_RECORDED_VALUE_MASK -/// -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] -#[repr(i32)] -pub enum DataPointFlags { - /// The zero value for the enum. Should not be used for comparisons. - /// Instead use bitwise "and" with the appropriate mask as shown above. - DoNotUse = 0, - /// This DataPoint is valid but has no recorded value. This value - /// SHOULD be used to reflect explicitly missing data in a series, as - /// for an equivalent to the Prometheus "staleness marker". - NoRecordedValueMask = 1, -} -impl DataPointFlags { - /// 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 { - DataPointFlags::DoNotUse => "DATA_POINT_FLAGS_DO_NOT_USE", - DataPointFlags::NoRecordedValueMask => { - "DATA_POINT_FLAGS_NO_RECORDED_VALUE_MASK" - } - } - } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "DATA_POINT_FLAGS_DO_NOT_USE" => Some(Self::DoNotUse), - "DATA_POINT_FLAGS_NO_RECORDED_VALUE_MASK" => Some(Self::NoRecordedValueMask), - _ => None, - } - } -} diff --git a/opentelemetry-proto/src/proto/grpcio/opentelemetry.proto.resource.v1.rs b/opentelemetry-proto/src/proto/grpcio/opentelemetry.proto.resource.v1.rs deleted file mode 100644 index 2b06ae8ca4..0000000000 --- a/opentelemetry-proto/src/proto/grpcio/opentelemetry.proto.resource.v1.rs +++ /dev/null @@ -1,14 +0,0 @@ -/// Resource information. -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Resource { - /// Set of attributes that describe the resource. - /// Attribute keys MUST be unique (it is not allowed to have more than one - /// attribute with the same key). - #[prost(message, repeated, tag = "1")] - pub attributes: ::prost::alloc::vec::Vec, - /// dropped_attributes_count is the number of dropped attributes. If the value is 0, then - /// no attributes were dropped. - #[prost(uint32, tag = "2")] - pub dropped_attributes_count: u32, -} diff --git a/opentelemetry-proto/src/proto/grpcio/opentelemetry.proto.trace.v1.rs b/opentelemetry-proto/src/proto/grpcio/opentelemetry.proto.trace.v1.rs deleted file mode 100644 index 9843c9e000..0000000000 --- a/opentelemetry-proto/src/proto/grpcio/opentelemetry.proto.trace.v1.rs +++ /dev/null @@ -1,412 +0,0 @@ -/// TracesData represents the traces data that can be stored in a persistent storage, -/// OR can be embedded by other protocols that transfer OTLP traces data but do -/// not implement the OTLP protocol. -/// -/// The main difference between this message and collector protocol is that -/// in this message there will not be any "control" or "metadata" specific to -/// OTLP protocol. -/// -/// When new fields are added into this message, the OTLP request MUST be updated -/// as well. -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct TracesData { - /// An array of ResourceSpans. - /// For data coming from a single resource this array will typically contain - /// one element. Intermediary nodes that receive data from multiple origins - /// typically batch the data before forwarding further and in that case this - /// array will contain multiple elements. - #[prost(message, repeated, tag = "1")] - pub resource_spans: ::prost::alloc::vec::Vec, -} -/// A collection of ScopeSpans from a Resource. -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ResourceSpans { - /// The resource for the spans in this message. - /// If this field is not set then no resource info is known. - #[prost(message, optional, tag = "1")] - pub resource: ::core::option::Option, - /// A list of ScopeSpans that originate from a resource. - #[prost(message, repeated, tag = "2")] - pub scope_spans: ::prost::alloc::vec::Vec, - /// The Schema URL, if known. This is the identifier of the Schema that the resource data - /// is recorded in. To learn more about Schema URL see - /// - /// This schema_url applies to the data in the "resource" field. It does not apply - /// to the data in the "scope_spans" field which have their own schema_url field. - #[prost(string, tag = "3")] - pub schema_url: ::prost::alloc::string::String, -} -/// A collection of Spans produced by an InstrumentationScope. -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ScopeSpans { - /// The instrumentation scope information for the spans in this message. - /// Semantically when InstrumentationScope isn't set, it is equivalent with - /// an empty instrumentation scope name (unknown). - #[prost(message, optional, tag = "1")] - pub scope: ::core::option::Option, - /// A list of Spans that originate from an instrumentation scope. - #[prost(message, repeated, tag = "2")] - pub spans: ::prost::alloc::vec::Vec, - /// The Schema URL, if known. This is the identifier of the Schema that the span data - /// is recorded in. To learn more about Schema URL see - /// - /// This schema_url applies to all spans and span events in the "spans" field. - #[prost(string, tag = "3")] - pub schema_url: ::prost::alloc::string::String, -} -/// A Span represents a single operation performed by a single component of the system. -/// -/// The next available field id is 17. -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Span { - /// A unique identifier for a trace. All spans from the same trace share - /// the same `trace_id`. The ID is a 16-byte array. An ID with all zeroes OR - /// of length other than 16 bytes is considered invalid (empty string in OTLP/JSON - /// is zero-length and thus is also invalid). - /// - /// This field is required. - #[prost(bytes = "vec", tag = "1")] - pub trace_id: ::prost::alloc::vec::Vec, - /// A unique identifier for a span within a trace, assigned when the span - /// is created. The ID is an 8-byte array. An ID with all zeroes OR of length - /// other than 8 bytes is considered invalid (empty string in OTLP/JSON - /// is zero-length and thus is also invalid). - /// - /// This field is required. - #[prost(bytes = "vec", tag = "2")] - pub span_id: ::prost::alloc::vec::Vec, - /// trace_state conveys information about request position in multiple distributed tracing graphs. - /// It is a trace_state in w3c-trace-context format: - /// See also for more details about this field. - #[prost(string, tag = "3")] - pub trace_state: ::prost::alloc::string::String, - /// The `span_id` of this span's parent span. If this is a root span, then this - /// field must be empty. The ID is an 8-byte array. - #[prost(bytes = "vec", tag = "4")] - pub parent_span_id: ::prost::alloc::vec::Vec, - /// Flags, a bit field. 8 least significant bits are the trace - /// flags as defined in W3C Trace Context specification. Readers - /// MUST not assume that 24 most significant bits will be zero. - /// To read the 8-bit W3C trace flag, use `flags & SPAN_FLAGS_TRACE_FLAGS_MASK`. - /// - /// When creating span messages, if the message is logically forwarded from another source - /// with an equivalent flags fields (i.e., usually another OTLP span message), the field SHOULD - /// be copied as-is. If creating from a source that does not have an equivalent flags field - /// (such as a runtime representation of an OpenTelemetry span), the high 24 bits MUST - /// be set to zero. - /// - /// \[Optional\]. - /// - /// See for the flag definitions. - #[prost(fixed32, tag = "16")] - pub flags: u32, - /// A description of the span's operation. - /// - /// For example, the name can be a qualified method name or a file name - /// and a line number where the operation is called. A best practice is to use - /// the same display name at the same call point in an application. - /// This makes it easier to correlate spans in different traces. - /// - /// This field is semantically required to be set to non-empty string. - /// Empty value is equivalent to an unknown span name. - /// - /// This field is required. - #[prost(string, tag = "5")] - pub name: ::prost::alloc::string::String, - /// Distinguishes between spans generated in a particular context. For example, - /// two spans with the same name may be distinguished using `CLIENT` (caller) - /// and `SERVER` (callee) to identify queueing latency associated with the span. - #[prost(enumeration = "span::SpanKind", tag = "6")] - pub kind: i32, - /// start_time_unix_nano is the start time of the span. On the client side, this is the time - /// kept by the local machine where the span execution starts. On the server side, this - /// is the time when the server's application handler starts running. - /// Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970. - /// - /// This field is semantically required and it is expected that end_time >= start_time. - #[prost(fixed64, tag = "7")] - pub start_time_unix_nano: u64, - /// end_time_unix_nano is the end time of the span. On the client side, this is the time - /// kept by the local machine where the span execution ends. On the server side, this - /// is the time when the server application handler stops running. - /// Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970. - /// - /// This field is semantically required and it is expected that end_time >= start_time. - #[prost(fixed64, tag = "8")] - pub end_time_unix_nano: u64, - /// attributes is a collection of key/value pairs. Note, global attributes - /// like server name can be set using the resource API. Examples of attributes: - /// - /// "/http/user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36" - /// "/http/server_latency": 300 - /// "example.com/myattribute": true - /// "example.com/score": 10.239 - /// - /// The OpenTelemetry API specification further restricts the allowed value types: - /// - /// Attribute keys MUST be unique (it is not allowed to have more than one - /// attribute with the same key). - #[prost(message, repeated, tag = "9")] - pub attributes: ::prost::alloc::vec::Vec, - /// dropped_attributes_count is the number of attributes that were discarded. Attributes - /// can be discarded because their keys are too long or because there are too many - /// attributes. If this value is 0, then no attributes were dropped. - #[prost(uint32, tag = "10")] - pub dropped_attributes_count: u32, - /// events is a collection of Event items. - #[prost(message, repeated, tag = "11")] - pub events: ::prost::alloc::vec::Vec, - /// dropped_events_count is the number of dropped events. If the value is 0, then no - /// events were dropped. - #[prost(uint32, tag = "12")] - pub dropped_events_count: u32, - /// links is a collection of Links, which are references from this span to a span - /// in the same or different trace. - #[prost(message, repeated, tag = "13")] - pub links: ::prost::alloc::vec::Vec, - /// dropped_links_count is the number of dropped links after the maximum size was - /// enforced. If this value is 0, then no links were dropped. - #[prost(uint32, tag = "14")] - pub dropped_links_count: u32, - /// An optional final status for this span. Semantically when Status isn't set, it means - /// span's status code is unset, i.e. assume STATUS_CODE_UNSET (code = 0). - #[prost(message, optional, tag = "15")] - pub status: ::core::option::Option, -} -/// Nested message and enum types in `Span`. -pub mod span { - /// Event is a time-stamped annotation of the span, consisting of user-supplied - /// text description and key-value pairs. - #[allow(clippy::derive_partial_eq_without_eq)] - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct Event { - /// time_unix_nano is the time the event occurred. - #[prost(fixed64, tag = "1")] - pub time_unix_nano: u64, - /// name of the event. - /// This field is semantically required to be set to non-empty string. - #[prost(string, tag = "2")] - pub name: ::prost::alloc::string::String, - /// attributes is a collection of attribute key/value pairs on the event. - /// Attribute keys MUST be unique (it is not allowed to have more than one - /// attribute with the same key). - #[prost(message, repeated, tag = "3")] - pub attributes: ::prost::alloc::vec::Vec< - super::super::super::common::v1::KeyValue, - >, - /// dropped_attributes_count is the number of dropped attributes. If the value is 0, - /// then no attributes were dropped. - #[prost(uint32, tag = "4")] - pub dropped_attributes_count: u32, - } - /// A pointer from the current span to another span in the same trace or in a - /// different trace. For example, this can be used in batching operations, - /// where a single batch handler processes multiple requests from different - /// traces or when the handler receives a request from a different project. - #[allow(clippy::derive_partial_eq_without_eq)] - #[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 trace_state associated with the link. - #[prost(string, tag = "3")] - pub trace_state: ::prost::alloc::string::String, - /// attributes is a collection of attribute key/value pairs on the link. - /// Attribute keys MUST be unique (it is not allowed to have more than one - /// attribute with the same key). - #[prost(message, repeated, tag = "4")] - pub attributes: ::prost::alloc::vec::Vec< - super::super::super::common::v1::KeyValue, - >, - /// dropped_attributes_count is the number of dropped attributes. If the value is 0, - /// then no attributes were dropped. - #[prost(uint32, tag = "5")] - pub dropped_attributes_count: u32, - /// Flags, a bit field. 8 least significant bits are the trace - /// flags as defined in W3C Trace Context specification. Readers - /// MUST not assume that 24 most significant bits will be zero. - /// When creating new spans, the most-significant 24-bits MUST be - /// zero. To read the 8-bit W3C trace flag (use flags & - /// SPAN_FLAGS_TRACE_FLAGS_MASK). \[Optional\]. - /// - /// See for the flag definitions. - #[prost(fixed32, tag = "6")] - pub flags: u32, - } - /// SpanKind is the type of span. Can be used to specify additional relationships between spans - /// in addition to a parent/child relationship. - #[derive( - Clone, - Copy, - Debug, - PartialEq, - Eq, - Hash, - PartialOrd, - Ord, - ::prost::Enumeration - )] - #[repr(i32)] - pub enum SpanKind { - /// Unspecified. Do NOT use as default. - /// Implementations MAY assume SpanKind to be INTERNAL when receiving UNSPECIFIED. - Unspecified = 0, - /// Indicates that the span represents an internal operation within an application, - /// as opposed to an operation happening at the boundaries. Default value. - Internal = 1, - /// Indicates that the span covers server-side handling of an RPC or other - /// remote network request. - Server = 2, - /// Indicates that the span describes a request to some remote service. - Client = 3, - /// Indicates that the span describes a producer sending a message to a broker. - /// Unlike CLIENT and SERVER, there is often no direct critical path latency relationship - /// between producer and consumer spans. A PRODUCER span ends when the message was accepted - /// by the broker while the logical processing of the message might span a much longer time. - Producer = 4, - /// Indicates that the span describes consumer receiving a message from a broker. - /// Like the PRODUCER kind, there is often no direct critical path latency relationship - /// between producer and consumer spans. - Consumer = 5, - } - impl SpanKind { - /// String value of the enum field names used in the ProtoBuf definition. - /// - /// The values are not transformed in any way and thus are considered stable - /// (if the ProtoBuf definition does not change) and safe for programmatic use. - pub fn as_str_name(&self) -> &'static str { - match self { - SpanKind::Unspecified => "SPAN_KIND_UNSPECIFIED", - SpanKind::Internal => "SPAN_KIND_INTERNAL", - SpanKind::Server => "SPAN_KIND_SERVER", - SpanKind::Client => "SPAN_KIND_CLIENT", - SpanKind::Producer => "SPAN_KIND_PRODUCER", - SpanKind::Consumer => "SPAN_KIND_CONSUMER", - } - } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "SPAN_KIND_UNSPECIFIED" => Some(Self::Unspecified), - "SPAN_KIND_INTERNAL" => Some(Self::Internal), - "SPAN_KIND_SERVER" => Some(Self::Server), - "SPAN_KIND_CLIENT" => Some(Self::Client), - "SPAN_KIND_PRODUCER" => Some(Self::Producer), - "SPAN_KIND_CONSUMER" => Some(Self::Consumer), - _ => None, - } - } - } -} -/// The Status type defines a logical error model that is suitable for different -/// programming environments, including REST APIs and RPC APIs. -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Status { - /// A developer-facing human readable error message. - #[prost(string, tag = "2")] - pub message: ::prost::alloc::string::String, - /// The status code. - #[prost(enumeration = "status::StatusCode", tag = "3")] - pub code: i32, -} -/// Nested message and enum types in `Status`. -pub mod status { - /// For the semantics of status codes see - /// - #[derive( - Clone, - Copy, - Debug, - PartialEq, - Eq, - Hash, - PartialOrd, - Ord, - ::prost::Enumeration - )] - #[repr(i32)] - pub enum StatusCode { - /// The default status. - Unset = 0, - /// The Span has been validated by an Application developer or Operator to - /// have completed successfully. - Ok = 1, - /// The Span contains an error. - Error = 2, - } - impl StatusCode { - /// String value of the enum field names used in the ProtoBuf definition. - /// - /// The values are not transformed in any way and thus are considered stable - /// (if the ProtoBuf definition does not change) and safe for programmatic use. - pub fn as_str_name(&self) -> &'static str { - match self { - StatusCode::Unset => "STATUS_CODE_UNSET", - StatusCode::Ok => "STATUS_CODE_OK", - StatusCode::Error => "STATUS_CODE_ERROR", - } - } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "STATUS_CODE_UNSET" => Some(Self::Unset), - "STATUS_CODE_OK" => Some(Self::Ok), - "STATUS_CODE_ERROR" => Some(Self::Error), - _ => None, - } - } - } -} -/// SpanFlags represents constants used to interpret the -/// Span.flags field, which is protobuf 'fixed32' type and is to -/// be used as bit-fields. Each non-zero value defined in this enum is -/// a bit-mask. To extract the bit-field, for example, use an -/// expression like: -/// -/// (span.flags & SPAN_FLAGS_TRACE_FLAGS_MASK) -/// -/// See for the flag definitions. -/// -/// Note that Span flags were introduced in version 1.1 of the -/// OpenTelemetry protocol. Older Span producers do not set this -/// field, consequently consumers should not rely on the absence of a -/// particular flag bit to indicate the presence of a particular feature. -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] -#[repr(i32)] -pub enum SpanFlags { - /// The zero value for the enum. Should not be used for comparisons. - /// Instead use bitwise "and" with the appropriate mask as shown above. - DoNotUse = 0, - /// Bits 0-7 are used for trace flags. - TraceFlagsMask = 255, -} -impl SpanFlags { - /// String value of the enum field names used in the ProtoBuf definition. - /// - /// The values are not transformed in any way and thus are considered stable - /// (if the ProtoBuf definition does not change) and safe for programmatic use. - pub fn as_str_name(&self) -> &'static str { - match self { - SpanFlags::DoNotUse => "SPAN_FLAGS_DO_NOT_USE", - SpanFlags::TraceFlagsMask => "SPAN_FLAGS_TRACE_FLAGS_MASK", - } - } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "SPAN_FLAGS_DO_NOT_USE" => Some(Self::DoNotUse), - "SPAN_FLAGS_TRACE_FLAGS_MASK" => Some(Self::TraceFlagsMask), - _ => None, - } - } -} diff --git a/opentelemetry-proto/src/transform/common.rs b/opentelemetry-proto/src/transform/common.rs index a6ddcff6b6..9aa29e4b22 100644 --- a/opentelemetry-proto/src/transform/common.rs +++ b/opentelemetry-proto/src/transform/common.rs @@ -1,11 +1,11 @@ #[cfg(all( - any(feature = "gen-tonic-messages", feature = "gen-grpcio-messages"), + feature = "gen-tonic-messages", any(feature = "trace", feature = "metrics", feature = "logs") ))] use std::time::{Duration, SystemTime, UNIX_EPOCH}; #[cfg(all( - any(feature = "gen-tonic-messages", feature = "gen-grpcio-messages"), + feature = "gen-tonic-messages", any(feature = "trace", feature = "metrics", feature = "logs") ))] pub(crate) fn to_nanos(time: SystemTime) -> u64 { @@ -122,112 +122,3 @@ pub mod tonic { .into() } } - -#[cfg(feature = "gen-grpcio-messages")] -pub mod grpcio { - use crate::proto::grpcio::common::v1::{ - any_value, AnyValue, ArrayValue, InstrumentationScope, KeyValue, - }; - use opentelemetry::{Array, Value}; - use std::borrow::Cow; - - #[cfg(any(feature = "trace", feature = "logs"))] - use opentelemetry_sdk::Resource; - - impl From for InstrumentationScope { - fn from(library: opentelemetry_sdk::InstrumentationLibrary) -> Self { - InstrumentationScope { - name: library.name.into_owned(), - version: library.version.map(Cow::into_owned).unwrap_or_default(), - attributes: Attributes::from(library.attributes).0, - ..Default::default() - } - } - } - - impl From<&opentelemetry_sdk::InstrumentationLibrary> for InstrumentationScope { - fn from(library: &opentelemetry_sdk::InstrumentationLibrary) -> Self { - InstrumentationScope { - name: library.name.to_string(), - version: library - .version - .as_ref() - .map(ToString::to_string) - .unwrap_or_default(), - attributes: Attributes::from(library.attributes.clone()).0, - ..Default::default() - } - } - } - - /// Wrapper type for Vec<`KeyValue`> - #[derive(Default)] - pub struct Attributes(pub ::std::vec::Vec); - - impl From> for Attributes { - fn from(kvs: Vec) -> Self { - Attributes( - kvs.into_iter() - .map(|api_kv| KeyValue { - key: api_kv.key.as_str().to_string(), - value: Some(api_kv.value.into()), - }) - .collect(), - ) - } - } - - #[cfg(feature = "logs")] - impl, V: Into> FromIterator<(K, V)> for Attributes { - fn from_iter>(iter: T) -> Self { - Attributes( - iter.into_iter() - .map(|(k, v)| KeyValue { - key: k.into(), - value: Some(v.into()), - }) - .collect(), - ) - } - } - - impl From for AnyValue { - fn from(value: Value) -> Self { - AnyValue { - value: match value { - Value::Bool(val) => Some(any_value::Value::BoolValue(val)), - Value::I64(val) => Some(any_value::Value::IntValue(val)), - Value::F64(val) => Some(any_value::Value::DoubleValue(val)), - Value::String(val) => Some(any_value::Value::StringValue(val.to_string())), - Value::Array(array) => Some(any_value::Value::ArrayValue(match array { - Array::Bool(vals) => array_into_proto(vals), - Array::I64(vals) => array_into_proto(vals), - Array::F64(vals) => array_into_proto(vals), - Array::String(vals) => array_into_proto(vals), - })), - }, - } - } - } - - fn array_into_proto(vals: Vec) -> ArrayValue - where - Value: From, - { - let values = vals - .into_iter() - .map(|val| AnyValue::from(Value::from(val))) - .collect(); - - ArrayValue { values } - } - - #[cfg(any(feature = "trace", feature = "logs"))] - pub(crate) fn resource_attributes(resource: &Resource) -> Attributes { - resource - .iter() - .map(|(k, v)| opentelemetry::KeyValue::new(k.clone(), v.clone())) - .collect::>() - .into() - } -} diff --git a/opentelemetry-proto/src/transform/logs.rs b/opentelemetry-proto/src/transform/logs.rs index 754788f3bb..bc5c2697c0 100644 --- a/opentelemetry-proto/src/transform/logs.rs +++ b/opentelemetry-proto/src/transform/logs.rs @@ -136,142 +136,3 @@ pub mod tonic { } } } - -#[cfg(feature = "gen-grpcio")] -pub mod grpcio { - use crate::{ - grpcio::{ - common::v1::{any_value::Value, AnyValue, ArrayValue, KeyValue, KeyValueList}, - logs::v1::{LogRecord, ResourceLogs, ScopeLogs, SeverityNumber}, - resource::v1::Resource, - Attributes, - }, - transform::common::{grpcio::resource_attributes, to_nanos}, - }; - use opentelemetry::logs::{AnyValue as LogsAnyValue, Severity}; - - impl From for AnyValue { - fn from(value: LogsAnyValue) -> Self { - AnyValue { - value: Some(value.into()), - } - } - } - - impl From for Value { - fn from(value: LogsAnyValue) -> Self { - match value { - LogsAnyValue::Double(f) => Value::DoubleValue(f), - LogsAnyValue::Int(i) => Value::IntValue(i), - LogsAnyValue::String(s) => Value::StringValue(s.into()), - LogsAnyValue::Boolean(b) => Value::BoolValue(b), - LogsAnyValue::ListAny(v) => Value::ArrayValue(ArrayValue { - values: v - .into_iter() - .map(|v| AnyValue { - value: Some(v.into()), - }) - .collect(), - }), - LogsAnyValue::Map(m) => Value::KvlistValue(KeyValueList { - values: m - .into_iter() - .map(|(key, value)| KeyValue { - key: key.into(), - value: Some(AnyValue { - value: Some(value.into()), - }), - }) - .collect(), - }), - LogsAnyValue::Bytes(v) => Value::BytesValue(v), - } - } - } - - impl From for LogRecord { - fn from(log_record: opentelemetry::logs::LogRecord) -> Self { - let trace_context = log_record.trace_context.as_ref(); - let severity_number = match log_record.severity_number { - Some(Severity::Trace) => SeverityNumber::Trace, - Some(Severity::Trace2) => SeverityNumber::Trace2, - Some(Severity::Trace3) => SeverityNumber::Trace3, - Some(Severity::Trace4) => SeverityNumber::Trace4, - Some(Severity::Debug) => SeverityNumber::Debug, - Some(Severity::Debug2) => SeverityNumber::Debug2, - Some(Severity::Debug3) => SeverityNumber::Debug3, - Some(Severity::Debug4) => SeverityNumber::Debug4, - Some(Severity::Info) => SeverityNumber::Info, - Some(Severity::Info2) => SeverityNumber::Info2, - Some(Severity::Info3) => SeverityNumber::Info3, - Some(Severity::Info4) => SeverityNumber::Info4, - Some(Severity::Warn) => SeverityNumber::Warn, - Some(Severity::Warn2) => SeverityNumber::Warn2, - Some(Severity::Warn3) => SeverityNumber::Warn3, - Some(Severity::Warn4) => SeverityNumber::Warn4, - Some(Severity::Error) => SeverityNumber::Error, - Some(Severity::Error2) => SeverityNumber::Error2, - Some(Severity::Error3) => SeverityNumber::Error3, - Some(Severity::Error4) => SeverityNumber::Error4, - Some(Severity::Fatal) => SeverityNumber::Fatal, - Some(Severity::Fatal2) => SeverityNumber::Fatal2, - Some(Severity::Fatal3) => SeverityNumber::Fatal3, - Some(Severity::Fatal4) => SeverityNumber::Fatal4, - None => SeverityNumber::Unspecified, - }; - - LogRecord { - time_unix_nano: log_record.timestamp.map(to_nanos).unwrap_or_default(), - observed_time_unix_nano: to_nanos(log_record.observed_timestamp), - severity_number: severity_number.into(), - severity_text: log_record.severity_text.map(Into::into).unwrap_or_default(), - body: log_record.body.map(Into::into), - attributes: log_record - .attributes - .map(Attributes::from_iter) - .unwrap_or_default() - .0, - dropped_attributes_count: 0, - flags: trace_context - .map(|ctx| { - ctx.trace_flags - .map(|flags| flags.to_u8() as u32) - .unwrap_or_default() - }) - .unwrap_or_default(), - span_id: trace_context - .map(|ctx| ctx.span_id.to_bytes().to_vec()) - .unwrap_or_default(), - trace_id: trace_context - .map(|ctx| ctx.trace_id.to_bytes().to_vec()) - .unwrap_or_default(), - } - } - } - - impl From for ResourceLogs { - fn from(log_data: opentelemetry_sdk::export::logs::LogData) -> Self { - ResourceLogs { - resource: Some(Resource { - attributes: resource_attributes(&log_data.resource).0, - dropped_attributes_count: 0, - }), - schema_url: log_data - .resource - .schema_url() - .map(Into::into) - .unwrap_or_default(), - scope_logs: vec![ScopeLogs { - schema_url: log_data - .instrumentation - .schema_url - .clone() - .map(Into::into) - .unwrap_or_default(), - scope: Some(log_data.instrumentation.into()), - log_records: vec![log_data.record.into()], - }], - } - } - } -} diff --git a/opentelemetry-proto/src/transform/metrics.rs b/opentelemetry-proto/src/transform/metrics.rs index f3b04bb6e9..964ed486b0 100644 --- a/opentelemetry-proto/src/transform/metrics.rs +++ b/opentelemetry-proto/src/transform/metrics.rs @@ -342,343 +342,3 @@ pub mod tonic { } } } - -#[cfg(feature = "gen-grpcio-messages")] -pub mod grpcio { - use std::any::Any; - use std::fmt; - - use opentelemetry::{global, metrics::MetricsError, Key, Value}; - use opentelemetry_sdk::metrics::data::{ - self, Exemplar as SdkExemplar, ExponentialHistogram as SdkExponentialHistogram, - Gauge as SdkGauge, Histogram as SdkHistogram, Metric as SdkMetric, - ScopeMetrics as SdkScopeMetrics, Sum as SdkSum, Temporality, - }; - use opentelemetry_sdk::Resource as SdkResource; - - use crate::proto::grpcio::{ - collector::metrics::v1::ExportMetricsServiceRequest, - common::v1::KeyValue, - metrics::v1::{ - exemplar, exemplar::Value as GrpcioExemplarValue, - exponential_histogram_data_point::Buckets as GrpcioBuckets, - metric::Data as GrpcioMetricData, number_data_point, - number_data_point::Value as GrpcioDataPointValue, - AggregationTemporality as GrpcioTemporality, AggregationTemporality, - DataPointFlags as GrpcioDataPointFlags, Exemplar as GrpcioExemplar, - ExponentialHistogram as GrpcioExponentialHistogram, - ExponentialHistogramDataPoint as GrpcioExponentialHistogramDataPoint, - Gauge as GrpcioGauge, Histogram as GrpcioHistogram, - HistogramDataPoint as GrpcioHistogramDataPoint, Metric as GrpcioMetric, - NumberDataPoint as GrpcioNumberDataPoint, ResourceMetrics as GrpcioResourceMetrics, - ScopeMetrics as GrpcioScopeMetrics, Sum as GrpcioSum, - }, - resource::v1::Resource as GrpcioResource, - }; - use crate::transform::common::to_nanos; - - impl From for exemplar::Value { - fn from(value: u64) -> Self { - exemplar::Value::AsInt(i64::try_from(value).unwrap_or_default()) - } - } - - impl From for exemplar::Value { - fn from(value: i64) -> Self { - exemplar::Value::AsInt(value) - } - } - - impl From for exemplar::Value { - fn from(value: f64) -> Self { - exemplar::Value::AsDouble(value) - } - } - - impl From for number_data_point::Value { - fn from(value: u64) -> Self { - number_data_point::Value::AsInt(i64::try_from(value).unwrap_or_default()) - } - } - - impl From for number_data_point::Value { - fn from(value: i64) -> Self { - number_data_point::Value::AsInt(value) - } - } - - impl From for number_data_point::Value { - fn from(value: f64) -> Self { - number_data_point::Value::AsDouble(value) - } - } - - impl From<(&Key, &Value)> for KeyValue { - fn from(kv: (&Key, &Value)) -> Self { - KeyValue { - key: kv.0.to_string(), - value: Some(kv.1.clone().into()), - } - } - } - - impl From<&opentelemetry::KeyValue> for KeyValue { - fn from(kv: &opentelemetry::KeyValue) -> Self { - KeyValue { - key: kv.key.to_string(), - value: Some(kv.value.clone().into()), - } - } - } - - impl From for AggregationTemporality { - fn from(temporality: Temporality) -> Self { - match temporality { - Temporality::Cumulative => AggregationTemporality::Cumulative, - Temporality::Delta => AggregationTemporality::Delta, - other => { - opentelemetry::global::handle_error(MetricsError::Other(format!( - "Unknown temporality {:?}, using default instead.", - other - ))); - AggregationTemporality::Cumulative - } - } - } - } - - impl From<&data::ResourceMetrics> for ExportMetricsServiceRequest { - fn from(rm: &data::ResourceMetrics) -> Self { - ExportMetricsServiceRequest { - resource_metrics: vec![GrpcioResourceMetrics { - resource: Some((&rm.resource).into()), - scope_metrics: rm.scope_metrics.iter().map(Into::into).collect(), - schema_url: rm.resource.schema_url().map(Into::into).unwrap_or_default(), - }], - } - } - } - - impl From<&SdkResource> for GrpcioResource { - fn from(resource: &SdkResource) -> Self { - GrpcioResource { - attributes: resource.iter().map(Into::into).collect(), - dropped_attributes_count: 0, - } - } - } - - impl From<&SdkScopeMetrics> for GrpcioScopeMetrics { - fn from(sm: &SdkScopeMetrics) -> Self { - GrpcioScopeMetrics { - scope: Some((&sm.scope).into()), - metrics: sm.metrics.iter().map(Into::into).collect(), - schema_url: sm - .scope - .schema_url - .as_ref() - .map(ToString::to_string) - .unwrap_or_default(), - } - } - } - - impl From<&SdkMetric> for GrpcioMetric { - fn from(metric: &SdkMetric) -> Self { - GrpcioMetric { - name: metric.name.to_string(), - description: metric.description.to_string(), - unit: metric.unit.as_str().to_string(), - data: metric.data.as_any().try_into().ok(), - } - } - } - - impl TryFrom<&dyn Any> for GrpcioMetricData { - type Error = (); - - fn try_from(data: &dyn Any) -> Result { - if let Some(hist) = data.downcast_ref::>() { - Ok(GrpcioMetricData::Histogram(hist.into())) - } else if let Some(hist) = data.downcast_ref::>() { - Ok(GrpcioMetricData::Histogram(hist.into())) - } else if let Some(hist) = data.downcast_ref::>() { - Ok(GrpcioMetricData::Histogram(hist.into())) - } else if let Some(hist) = data.downcast_ref::>() { - Ok(GrpcioMetricData::ExponentialHistogram(hist.into())) - } else if let Some(hist) = data.downcast_ref::>() { - Ok(GrpcioMetricData::ExponentialHistogram(hist.into())) - } else if let Some(hist) = data.downcast_ref::>() { - Ok(GrpcioMetricData::ExponentialHistogram(hist.into())) - } else if let Some(sum) = data.downcast_ref::>() { - Ok(GrpcioMetricData::Sum(sum.into())) - } else if let Some(sum) = data.downcast_ref::>() { - Ok(GrpcioMetricData::Sum(sum.into())) - } else if let Some(sum) = data.downcast_ref::>() { - Ok(GrpcioMetricData::Sum(sum.into())) - } else if let Some(gauge) = data.downcast_ref::>() { - Ok(GrpcioMetricData::Gauge(gauge.into())) - } else if let Some(gauge) = data.downcast_ref::>() { - Ok(GrpcioMetricData::Gauge(gauge.into())) - } else if let Some(gauge) = data.downcast_ref::>() { - Ok(GrpcioMetricData::Gauge(gauge.into())) - } else { - global::handle_error(MetricsError::Other("unknown aggregator".into())); - Err(()) - } - } - } - - trait Numeric: Into + Into + Copy { - // lossy at large values for u64 and i64 but otlp histograms only handle float values - fn into_f64(self) -> f64; - } - - impl Numeric for u64 { - fn into_f64(self) -> f64 { - self as f64 - } - } - - impl Numeric for i64 { - fn into_f64(self) -> f64 { - self as f64 - } - } - - impl Numeric for f64 { - fn into_f64(self) -> f64 { - self - } - } - - impl From<&SdkHistogram> for GrpcioHistogram - where - T: Numeric, - { - fn from(hist: &SdkHistogram) -> Self { - GrpcioHistogram { - data_points: hist - .data_points - .iter() - .map(|dp| GrpcioHistogramDataPoint { - attributes: dp.attributes.iter().map(Into::into).collect(), - start_time_unix_nano: to_nanos(dp.start_time), - time_unix_nano: to_nanos(dp.time), - count: dp.count, - sum: Some(dp.sum.into_f64()), - bucket_counts: dp.bucket_counts.clone(), - explicit_bounds: dp.bounds.clone(), - exemplars: dp.exemplars.iter().map(Into::into).collect(), - flags: GrpcioDataPointFlags::default() as u32, - min: dp.min.map(Numeric::into_f64), - max: dp.max.map(Numeric::into_f64), - }) - .collect(), - aggregation_temporality: GrpcioTemporality::from(hist.temporality).into(), - } - } - } - - impl From<&SdkExponentialHistogram> for GrpcioExponentialHistogram - where - T: Numeric, - { - fn from(hist: &SdkExponentialHistogram) -> Self { - GrpcioExponentialHistogram { - data_points: hist - .data_points - .iter() - .map(|dp| GrpcioExponentialHistogramDataPoint { - attributes: dp.attributes.iter().map(Into::into).collect(), - start_time_unix_nano: to_nanos(dp.start_time), - time_unix_nano: to_nanos(dp.time), - count: dp.count as u64, - sum: Some(dp.sum.into_f64()), - scale: dp.scale.into(), - zero_count: dp.zero_count, - positive: Some(GrpcioBuckets { - offset: dp.positive_bucket.offset, - bucket_counts: dp.positive_bucket.counts.clone(), - }), - negative: Some(GrpcioBuckets { - offset: dp.negative_bucket.offset, - bucket_counts: dp.negative_bucket.counts.clone(), - }), - flags: GrpcioDataPointFlags::default() as u32, - exemplars: dp.exemplars.iter().map(Into::into).collect(), - min: dp.min.map(Numeric::into_f64), - max: dp.max.map(Numeric::into_f64), - zero_threshold: dp.zero_threshold, - }) - .collect(), - aggregation_temporality: GrpcioTemporality::from(hist.temporality).into(), - } - } - } - - impl From<&SdkSum> for GrpcioSum - where - T: fmt::Debug + Into + Into + Copy, - { - fn from(sum: &SdkSum) -> Self { - GrpcioSum { - data_points: sum - .data_points - .iter() - .map(|dp| GrpcioNumberDataPoint { - attributes: dp.attributes.iter().map(Into::into).collect(), - start_time_unix_nano: dp.start_time.map(to_nanos).unwrap_or_default(), - time_unix_nano: dp.time.map(to_nanos).unwrap_or_default(), - exemplars: dp.exemplars.iter().map(Into::into).collect(), - flags: GrpcioDataPointFlags::default() as u32, - value: Some(dp.value.into()), - }) - .collect(), - aggregation_temporality: GrpcioTemporality::from(sum.temporality).into(), - is_monotonic: sum.is_monotonic, - } - } - } - - impl From<&SdkGauge> for GrpcioGauge - where - T: fmt::Debug + Into + Into + Copy, - { - fn from(gauge: &SdkGauge) -> Self { - GrpcioGauge { - data_points: gauge - .data_points - .iter() - .map(|dp| GrpcioNumberDataPoint { - attributes: dp.attributes.iter().map(Into::into).collect(), - start_time_unix_nano: dp.start_time.map(to_nanos).unwrap_or_default(), - time_unix_nano: dp.time.map(to_nanos).unwrap_or_default(), - exemplars: dp.exemplars.iter().map(Into::into).collect(), - flags: GrpcioDataPointFlags::default() as u32, - value: Some(dp.value.into()), - }) - .collect(), - } - } - } - - impl From<&SdkExemplar> for GrpcioExemplar - where - T: Into + Copy, - { - fn from(ex: &SdkExemplar) -> Self { - GrpcioExemplar { - filtered_attributes: ex - .filtered_attributes - .iter() - .map(|kv| (&kv.key, &kv.value).into()) - .collect(), - time_unix_nano: to_nanos(ex.time), - span_id: ex.span_id.into(), - trace_id: ex.trace_id.into(), - value: Some(ex.value.into()), - } - } - } -} diff --git a/opentelemetry-proto/src/transform/trace.rs b/opentelemetry-proto/src/transform/trace.rs index a6597a50a5..77f4f18de2 100644 --- a/opentelemetry-proto/src/transform/trace.rs +++ b/opentelemetry-proto/src/transform/trace.rs @@ -110,116 +110,3 @@ pub mod tonic { } } } - -#[cfg(feature = "gen-grpcio-messages")] -pub mod grpcio { - use crate::proto::grpcio::resource::v1::Resource; - use crate::proto::grpcio::trace::v1::{span, status, ResourceSpans, ScopeSpans, Span, Status}; - use crate::transform::common::{ - grpcio::{resource_attributes, Attributes}, - to_nanos, - }; - use opentelemetry::trace; - use opentelemetry::trace::{Link, SpanId, SpanKind}; - use opentelemetry_sdk::export::trace::SpanData; - - impl From for span::SpanKind { - fn from(span_kind: SpanKind) -> Self { - match span_kind { - SpanKind::Client => span::SpanKind::Client, - SpanKind::Consumer => span::SpanKind::Consumer, - SpanKind::Internal => span::SpanKind::Internal, - SpanKind::Producer => span::SpanKind::Producer, - SpanKind::Server => span::SpanKind::Server, - } - } - } - - impl From<&trace::Status> for status::StatusCode { - fn from(status: &trace::Status) -> Self { - match status { - trace::Status::Ok => status::StatusCode::Ok, - trace::Status::Unset => status::StatusCode::Unset, - trace::Status::Error { .. } => status::StatusCode::Error, - } - } - } - - impl From for span::Link { - fn from(link: Link) -> Self { - span::Link { - trace_id: link.span_context.trace_id().to_bytes().to_vec(), - span_id: link.span_context.span_id().to_bytes().to_vec(), - trace_state: link.span_context.trace_state().header(), - attributes: Attributes::from(link.attributes).0, - dropped_attributes_count: link.dropped_attributes_count, - flags: link.span_context.trace_flags().to_u8() as u32, - } - } - } - - impl From for ResourceSpans { - fn from(source_span: SpanData) -> Self { - let span_kind: span::SpanKind = source_span.span_kind.into(); - ResourceSpans { - resource: Some(Resource { - attributes: resource_attributes(&source_span.resource).0, - dropped_attributes_count: 0, - }), - schema_url: source_span - .resource - .schema_url() - .map(|url| url.to_string()) - .unwrap_or_default(), - scope_spans: vec![ScopeSpans { - schema_url: source_span - .instrumentation_lib - .schema_url - .as_ref() - .map(ToString::to_string) - .unwrap_or_default(), - scope: Some(source_span.instrumentation_lib.into()), - spans: vec![Span { - trace_id: source_span.span_context.trace_id().to_bytes().to_vec(), - span_id: source_span.span_context.span_id().to_bytes().to_vec(), - trace_state: source_span.span_context.trace_state().header(), - parent_span_id: { - if source_span.parent_span_id != SpanId::INVALID { - source_span.parent_span_id.to_bytes().to_vec() - } else { - vec![] - } - }, - flags: source_span.span_context.trace_flags().to_u8() as u32, - name: source_span.name.into_owned(), - kind: span_kind as i32, - start_time_unix_nano: to_nanos(source_span.start_time), - end_time_unix_nano: to_nanos(source_span.end_time), - dropped_attributes_count: source_span.dropped_attributes_count, - attributes: Attributes::from(source_span.attributes).0, - dropped_events_count: source_span.events.dropped_count, - events: source_span - .events - .into_iter() - .map(|event| span::Event { - time_unix_nano: to_nanos(event.timestamp), - name: event.name.into(), - attributes: Attributes::from(event.attributes).0, - dropped_attributes_count: event.dropped_attributes_count, - }) - .collect(), - dropped_links_count: source_span.links.dropped_count, - links: source_span.links.into_iter().map(Into::into).collect(), - status: Some(Status { - code: status::StatusCode::from(&source_span.status).into(), - message: match source_span.status { - trace::Status::Error { description } => description.to_string(), - _ => Default::default(), - }, - }), - }], - }], - } - } - } -} diff --git a/opentelemetry-proto/src/transform/tracez.rs b/opentelemetry-proto/src/transform/tracez.rs index 99b95fe11b..525064efc9 100644 --- a/opentelemetry-proto/src/transform/tracez.rs +++ b/opentelemetry-proto/src/transform/tracez.rs @@ -1,5 +1,5 @@ #[cfg(all(feature = "gen-tonic-messages", feature = "zpages"))] -mod grpcio { +mod tonic { use opentelemetry::trace::{Event, Status}; use opentelemetry_sdk::export::trace::SpanData; diff --git a/opentelemetry-proto/tests/grpc_build.rs b/opentelemetry-proto/tests/grpc_build.rs index 8dc4d9b86b..2f73fedc0c 100644 --- a/opentelemetry-proto/tests/grpc_build.rs +++ b/opentelemetry-proto/tests/grpc_build.rs @@ -2,19 +2,6 @@ use std::collections::HashMap; use std::path::Path; use tempfile::TempDir; -const GRPCIO_OUT_DIR: &str = "src/proto/grpcio"; -const GRPCIO_PROTO_FILES: &[&str] = &[ - "src/proto/opentelemetry-proto/opentelemetry/proto/common/v1/common.proto", - "src/proto/opentelemetry-proto/opentelemetry/proto/resource/v1/resource.proto", - "src/proto/opentelemetry-proto/opentelemetry/proto/trace/v1/trace.proto", - "src/proto/opentelemetry-proto/opentelemetry/proto/collector/trace/v1/trace_service.proto", - "src/proto/opentelemetry-proto/opentelemetry/proto/metrics/v1/metrics.proto", - "src/proto/opentelemetry-proto/opentelemetry/proto/collector/metrics/v1/metrics_service.proto", - "src/proto/opentelemetry-proto/opentelemetry/proto/logs/v1/logs.proto", - "src/proto/opentelemetry-proto/opentelemetry/proto/collector/logs/v1/logs_service.proto", -]; -const GRPCIO_INCLUDES: &[&str] = &["src/proto/opentelemetry-proto/"]; - const TONIC_OUT_DIR: &str = "src/proto/tonic"; const TONIC_PROTO_FILES: &[&str] = &[ "src/proto/opentelemetry-proto/opentelemetry/proto/common/v1/common.proto", @@ -29,24 +16,6 @@ const TONIC_PROTO_FILES: &[&str] = &[ ]; const TONIC_INCLUDES: &[&str] = &["src/proto/opentelemetry-proto", "src/proto"]; -// This test helps to keep files generated and used by grpcio update to date. -// If the test fails, it means the generated files has been changed. Please commit the change -// and rerun test. It should pass at the second time. -#[test] -fn build_grpc() { - let before_build = build_content_map(GRPCIO_OUT_DIR); - - grpcio_compiler::prost_codegen::compile_protos( - GRPCIO_PROTO_FILES, - GRPCIO_INCLUDES, - GRPCIO_OUT_DIR, - ) - .expect("cannot compile protobuf using grpcio"); - - let after_build = build_content_map(GRPCIO_OUT_DIR); - ensure_files_are_same(before_build, after_build, GRPCIO_OUT_DIR); -} - #[test] fn build_tonic() { let before_build = build_content_map(TONIC_OUT_DIR); diff --git a/scripts/lint.sh b/scripts/lint.sh index 009b420731..c14b57f5c3 100755 --- a/scripts/lint.sh +++ b/scripts/lint.sh @@ -19,9 +19,6 @@ if rustup component add clippy; then cargo_feature opentelemetry-otlp "default" cargo_feature opentelemetry-otlp "default,tls" cargo_feature opentelemetry-otlp "default,tls-roots" - cargo_feature opentelemetry-otlp "trace,grpc-sys" - cargo_feature opentelemetry-otlp "trace,grpc-sys,openssl" - cargo_feature opentelemetry-otlp "trace,grpc-sys,openssl-vendored" cargo_feature opentelemetry-otlp "http-proto" cargo_feature opentelemetry-otlp "http-proto, reqwest-blocking-client" cargo_feature opentelemetry-otlp "http-proto, reqwest-client" @@ -49,13 +46,5 @@ if rustup component add clippy; then cargo_feature opentelemetry-proto "gen-tonic,trace,with-schemars,with-serde" cargo_feature opentelemetry-proto "gen-tonic,metrics" cargo_feature opentelemetry-proto "gen-tonic,logs" - cargo_feature opentelemetry-proto "gen-grpcio,trace" - cargo_feature opentelemetry-proto "gen-grpcio,trace,with-serde" - cargo_feature opentelemetry-proto "gen-grpcio,trace,with-schemars,with-serde" - cargo_feature opentelemetry-proto "gen-grpcio,metrics" - cargo_feature opentelemetry-proto "gen-grpcio,logs" - cargo_feature opentelemetry-proto "gen-grpcio,zpages" - cargo_feature opentelemetry-proto "gen-grpcio,zpages,with-serde" - cargo_feature opentelemetry-proto "gen-grpcio,zpages,with-schemars,with-serde" fi diff --git a/scripts/test.sh b/scripts/test.sh index 76d35127ee..1b7437b1f6 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -12,5 +12,4 @@ cargo test --manifest-path=opentelemetry/Cargo.toml --all-features -- --ignored cargo test --manifest-path=opentelemetry/Cargo.toml --all-features cargo test --manifest-path=opentelemetry-jaeger/Cargo.toml --all-features -- --test-threads=1 -cargo test --manifest-path=opentelemetry-otlp/Cargo.toml --features "trace,grpc-sys" --no-default-features cargo test --manifest-path=opentelemetry-zipkin/Cargo.toml --all-features