From c585cd957aaac1fc60a69a323179a1368715e2e4 Mon Sep 17 00:00:00 2001 From: Julian Tescher Date: Sat, 19 Feb 2022 13:59:40 -0500 Subject: [PATCH 1/2] Remove serialize feature Removes non-spec serialization support to reduce public API surface area. --- .github/workflows/ci.yml | 2 +- examples/basic-otlp-http/Cargo.toml | 2 +- examples/basic-otlp-with-selector/Cargo.toml | 2 +- examples/basic-otlp/Cargo.toml | 2 +- examples/basic/Cargo.toml | 3 +- examples/basic/src/main.rs | 10 +-- examples/dynatrace/Cargo.toml | 2 +- .../external-otlp-grpcio-async-std/Cargo.toml | 5 +- examples/external-otlp-tonic-tokio/Cargo.toml | 2 +- opentelemetry-api/Cargo.toml | 2 - opentelemetry-api/src/baggage.rs | 4 -- opentelemetry-api/src/common.rs | 6 -- opentelemetry-api/src/trace/mod.rs | 4 -- opentelemetry-api/src/trace/span.rs | 4 -- opentelemetry-api/src/trace/span_context.rs | 7 -- opentelemetry-sdk/Cargo.toml | 1 - .../src/export/metrics/stdout.rs | 22 ------- opentelemetry-sdk/src/export/trace/mod.rs | 64 ------------------- opentelemetry-sdk/src/resource/mod.rs | 3 - .../src/trace/evicted_hash_map.rs | 3 - opentelemetry-sdk/src/trace/evicted_queue.rs | 3 - opentelemetry-sdk/src/trace/sampler.rs | 3 - opentelemetry-sdk/src/trace/span_limit.rs | 4 -- opentelemetry/Cargo.toml | 1 - opentelemetry/src/lib.rs | 2 - 25 files changed, 10 insertions(+), 153 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 33370ee6bf..7e43d20bd1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -72,7 +72,7 @@ jobs: override: true - name: Run tests run: cargo --version && - cargo test --verbose --manifest-path=opentelemetry/Cargo.toml --features trace,metrics,serialize,rt-tokio,testing && + cargo test --verbose --manifest-path=opentelemetry/Cargo.toml --features trace,metrics,rt-tokio,testing && cargo test --manifest-path=opentelemetry-jaeger/Cargo.toml --features rt-tokio && cargo test --manifest-path=opentelemetry-zipkin/Cargo.toml cargo-deny: diff --git a/examples/basic-otlp-http/Cargo.toml b/examples/basic-otlp-http/Cargo.toml index c1e400b929..c0b616b12f 100644 --- a/examples/basic-otlp-http/Cargo.toml +++ b/examples/basic-otlp-http/Cargo.toml @@ -5,6 +5,6 @@ edition = "2018" publish = false [dependencies] -opentelemetry = { path = "../../opentelemetry", features = ["rt-tokio", "metrics", "serialize"] } +opentelemetry = { path = "../../opentelemetry", features = ["rt-tokio", "metrics"] } opentelemetry-otlp = { path = "../../opentelemetry-otlp", features = ["http-proto", "reqwest-client"] } tokio = { version = "1.0", features = ["full"] } diff --git a/examples/basic-otlp-with-selector/Cargo.toml b/examples/basic-otlp-with-selector/Cargo.toml index 767c034c20..a7f61234c3 100644 --- a/examples/basic-otlp-with-selector/Cargo.toml +++ b/examples/basic-otlp-with-selector/Cargo.toml @@ -7,7 +7,7 @@ publish = false [dependencies] futures-util = { version = "0.3", default-features = false, features = ["std"] } lazy_static = "1.4" -opentelemetry = { path = "../../opentelemetry", features = ["rt-tokio", "metrics", "serialize"] } +opentelemetry = { path = "../../opentelemetry", features = ["rt-tokio", "metrics"] } opentelemetry-otlp = { path = "../../opentelemetry-otlp", features = ["tonic", "metrics"] } serde_json = "1.0" tokio = { version = "1.0", features = ["full"] } diff --git a/examples/basic-otlp/Cargo.toml b/examples/basic-otlp/Cargo.toml index 944ea6e19c..422add82ed 100644 --- a/examples/basic-otlp/Cargo.toml +++ b/examples/basic-otlp/Cargo.toml @@ -7,7 +7,7 @@ publish = false [dependencies] futures-util = { version = "0.3", default-features = false, features = ["std"] } lazy_static = "1.4" -opentelemetry = { path = "../../opentelemetry", features = ["rt-tokio", "metrics", "serialize"] } +opentelemetry = { path = "../../opentelemetry", features = ["rt-tokio", "metrics"] } opentelemetry-otlp = { path = "../../opentelemetry-otlp", features = ["tonic", "metrics"] } serde_json = "1.0" tokio = { version = "1.0", features = ["full"] } diff --git a/examples/basic/Cargo.toml b/examples/basic/Cargo.toml index 24a64b881d..48063294fc 100644 --- a/examples/basic/Cargo.toml +++ b/examples/basic/Cargo.toml @@ -7,8 +7,7 @@ publish = false [dependencies] futures-util = { version = "0.3", default-features = false, features = ["std"] } lazy_static = "1.4" -opentelemetry = { path = "../../opentelemetry", features = ["serialize", "rt-tokio", "metrics"] } +opentelemetry = { path = "../../opentelemetry", features = ["rt-tokio", "metrics"] } opentelemetry-jaeger = { path = "../../opentelemetry-jaeger", features = ["rt-tokio"] } -serde_json = "1.0" thrift = "0.13" tokio = { version = "1.0", features = ["full"] } diff --git a/examples/basic/src/main.rs b/examples/basic/src/main.rs index a3229814a0..73aeed8747 100644 --- a/examples/basic/src/main.rs +++ b/examples/basic/src/main.rs @@ -6,7 +6,7 @@ use opentelemetry::sdk::{metrics::PushController, trace as sdktrace, Resource}; use opentelemetry::trace::TraceError; use opentelemetry::{ baggage::BaggageExt, - metrics::{MetricsError, ObserverResult}, + metrics::ObserverResult, trace::{TraceContextExt, Tracer}, Context, Key, KeyValue, }; @@ -29,13 +29,7 @@ fn delayed_interval(duration: Duration) -> impl Stream PushController { - opentelemetry::sdk::export::metrics::stdout(tokio::spawn, delayed_interval) - .with_formatter(|batch| { - serde_json::to_value(batch) - .map(|value| value.to_string()) - .map_err(|err| MetricsError::Other(err.to_string())) - }) - .init() + opentelemetry::sdk::export::metrics::stdout(tokio::spawn, delayed_interval).init() } const FOO_KEY: Key = Key::from_static_str("ex.com/foo"); diff --git a/examples/dynatrace/Cargo.toml b/examples/dynatrace/Cargo.toml index 88af93b58b..90d47d32aa 100644 --- a/examples/dynatrace/Cargo.toml +++ b/examples/dynatrace/Cargo.toml @@ -8,7 +8,7 @@ publish = false futures = "0.3" http = "0.2" lazy_static = "1.4" -opentelemetry = { path = "../../opentelemetry", default-features = false, features = ["trace", "serialize"] } +opentelemetry = { path = "../../opentelemetry", default-features = false, features = ["trace"] } opentelemetry-dynatrace = { path = "../../opentelemetry-dynatrace" } opentelemetry-http = { path = "../../opentelemetry-http", default-features = false } opentelemetry-otlp = { path = "../../opentelemetry-otlp", default-features = false, features = ["http-proto", "reqwest-client"] } diff --git a/examples/external-otlp-grpcio-async-std/Cargo.toml b/examples/external-otlp-grpcio-async-std/Cargo.toml index 49e0f34b7e..4e1e262811 100644 --- a/examples/external-otlp-grpcio-async-std/Cargo.toml +++ b/examples/external-otlp-grpcio-async-std/Cargo.toml @@ -7,10 +7,7 @@ publish = false [dependencies] async-std = { version = "1.9.0", features = ["attributes"] } env_logger = "0.8.2" -opentelemetry = { path = "../../opentelemetry", features = [ - "rt-async-std", - "serialize" -] } +opentelemetry = { path = "../../opentelemetry", features = ["rt-async-std"] } opentelemetry-otlp = { path = "../../opentelemetry-otlp", features = [ "grpc-sys", "trace", diff --git a/examples/external-otlp-tonic-tokio/Cargo.toml b/examples/external-otlp-tonic-tokio/Cargo.toml index 80db6df13e..df53269280 100644 --- a/examples/external-otlp-tonic-tokio/Cargo.toml +++ b/examples/external-otlp-tonic-tokio/Cargo.toml @@ -5,7 +5,7 @@ edition = "2018" publish = false [dependencies] -opentelemetry = { path = "../../opentelemetry", features = ["rt-tokio", "metrics", "serialize"] } +opentelemetry = { path = "../../opentelemetry", features = ["rt-tokio", "metrics"] } opentelemetry-otlp = { path = "../../opentelemetry-otlp", features = ["tonic", "tls", "tls-roots"] } serde_json = "1.0" tokio = { version = "1.0", features = ["full"] } diff --git a/opentelemetry-api/Cargo.toml b/opentelemetry-api/Cargo.toml index 189b0acf75..257ad09a47 100644 --- a/opentelemetry-api/Cargo.toml +++ b/opentelemetry-api/Cargo.toml @@ -9,7 +9,6 @@ futures-channel = "0.3" futures-util = { version = "0.3", default-features = false, features = ["std", "sink"] } lazy_static = "1.4" pin-project = { version = "1.0.2", optional = true } -serde = { version = "1.0", features = ["derive", "rc"], optional = true } thiserror = "1" tokio-stream = { version = "0.1", optional = true } @@ -24,5 +23,4 @@ js-sys = "0.3" default = ["trace"] trace = ["pin-project"] metrics = ["fnv"] -serialize = ["serde"] testing = ["trace"] diff --git a/opentelemetry-api/src/baggage.rs b/opentelemetry-api/src/baggage.rs index 4ad278e99a..bdf5c22cae 100644 --- a/opentelemetry-api/src/baggage.rs +++ b/opentelemetry-api/src/baggage.rs @@ -12,8 +12,6 @@ //! [`BaggagePropagator`]: crate::sdk::propagation::BaggagePropagator //! [W3C Baggage]: https://w3c.github.io/baggage use crate::{Context, Key, KeyValue, Value}; -#[cfg(feature = "serialize")] -use serde::{Deserialize, Serialize}; use std::collections::{hash_map, HashMap}; use std::iter::FromIterator; @@ -375,7 +373,6 @@ impl BaggageExt for Context { /// `BaggageMetadata` can be added to values in the form of a property set, /// represented as semi-colon `;` delimited list of names and/or name-value /// pairs, e.g. `;k1=v1;k2;k3=v3`. -#[cfg_attr(feature = "serialize", derive(Deserialize, Serialize))] #[derive(Clone, Debug, PartialOrd, PartialEq, Default)] pub struct BaggageMetadata(String); @@ -399,7 +396,6 @@ impl From<&str> for BaggageMetadata { } /// [`Baggage`] name-value pairs with their associated metadata. -#[cfg_attr(feature = "serialize", derive(Deserialize, Serialize))] #[derive(Clone, Debug, PartialEq)] pub struct KeyValueMetadata { /// Dimension or event key diff --git a/opentelemetry-api/src/common.rs b/opentelemetry-api/src/common.rs index 8d4232fb6b..8abbead44f 100644 --- a/opentelemetry-api/src/common.rs +++ b/opentelemetry-api/src/common.rs @@ -1,10 +1,7 @@ -#[cfg(feature = "serialize")] -use serde::{Deserialize, Serialize}; use std::borrow::Cow; use std::fmt; /// Key used for metric `AttributeSet`s and trace `Span` attributes. -#[cfg_attr(feature = "serialize", derive(Deserialize, Serialize))] #[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] pub struct Key(Cow<'static, str>); @@ -93,7 +90,6 @@ impl fmt::Display for Key { } /// Array of homogeneous values -#[cfg_attr(feature = "serialize", derive(Deserialize, Serialize))] #[derive(Clone, Debug, PartialEq)] pub enum Array { /// Array of bools @@ -157,7 +153,6 @@ into_array!( ); /// Value types for use in `KeyValue` pairs. -#[cfg_attr(feature = "serialize", derive(Deserialize, Serialize))] #[derive(Clone, Debug, PartialEq)] pub enum Value { /// bool values @@ -237,7 +232,6 @@ impl fmt::Display for Value { } /// `KeyValue` pairs are used by `AttributeSet`s and `Span` attributes. -#[cfg_attr(feature = "serialize", derive(Deserialize, Serialize))] #[derive(Clone, Debug, PartialEq)] pub struct KeyValue { /// Dimension or event key diff --git a/opentelemetry-api/src/trace/mod.rs b/opentelemetry-api/src/trace/mod.rs index 84e63ca891..cb1d04b75b 100644 --- a/opentelemetry-api/src/trace/mod.rs +++ b/opentelemetry-api/src/trace/mod.rs @@ -150,8 +150,6 @@ //! ``` use futures_channel::{mpsc::TrySendError, oneshot::Canceled}; -#[cfg(feature = "serialize")] -use serde::{Deserialize, Serialize}; use std::borrow::Cow; use std::fmt; use std::time; @@ -242,7 +240,6 @@ pub trait IdGenerator: Send + Sync + fmt::Debug { /// A `Span` has the ability to add events. Events have a time associated /// with the moment when they are added to the `Span`. -#[cfg_attr(feature = "serialize", derive(Deserialize, Serialize))] #[derive(Clone, Debug, PartialEq)] pub struct Event { /// Event name @@ -284,7 +281,6 @@ impl Event { /// During the `Span` creation user MUST have the ability to record links to other `Span`s. Linked /// `Span`s can be from the same or a different trace. -#[cfg_attr(feature = "serialize", derive(Deserialize, Serialize))] #[derive(Clone, Debug, PartialEq)] pub struct Link { span_context: SpanContext, diff --git a/opentelemetry-api/src/trace/span.rs b/opentelemetry-api/src/trace/span.rs index 6c12158d83..d65c32a6fe 100644 --- a/opentelemetry-api/src/trace/span.rs +++ b/opentelemetry-api/src/trace/span.rs @@ -16,8 +16,6 @@ //! implementations MUST NOT allow callers to create Spans directly. All `Span`s MUST be created //! via a Tracer. use crate::{trace::SpanContext, KeyValue}; -#[cfg(feature = "serialize")] -use serde::{Deserialize, Serialize}; use std::borrow::Cow; use std::error::Error; use std::fmt; @@ -212,7 +210,6 @@ pub trait Span { /// | `Producer` | | yes | | yes | /// | `Consumer` | | yes | yes | | /// | `Internal` | | | | | -#[cfg_attr(feature = "serialize", derive(Deserialize, Serialize))] #[derive(Clone, Debug, PartialEq)] pub enum SpanKind { /// Indicates that the span describes a synchronous request to @@ -254,7 +251,6 @@ impl fmt::Display for SpanKind { /// The `StatusCode` interface represents the status of a finished `Span`. /// It's composed of a canonical code in conjunction with an optional /// descriptive message. -#[cfg_attr(feature = "serialize", derive(Deserialize, Serialize))] #[derive(Clone, Debug, PartialEq, Copy)] pub enum StatusCode { /// The default status. diff --git a/opentelemetry-api/src/trace/span_context.rs b/opentelemetry-api/src/trace/span_context.rs index 37a869a9ec..a32238a4e7 100644 --- a/opentelemetry-api/src/trace/span_context.rs +++ b/opentelemetry-api/src/trace/span_context.rs @@ -10,8 +10,6 @@ //! The spec can be viewed here: //! //! [w3c TraceContext specification]: https://www.w3.org/TR/trace-context/ -#[cfg(feature = "serialize")] -use serde::{Deserialize, Serialize}; use std::collections::VecDeque; use std::fmt; use std::hash::Hash; @@ -27,7 +25,6 @@ use thiserror::Error; /// See the W3C TraceContext specification's [trace-flags] section for more details. /// /// [trace-flags]: https://www.w3.org/TR/trace-context/#trace-flags -#[cfg_attr(feature = "serialize", derive(Deserialize, Serialize))] #[derive(Clone, Debug, Default, PartialEq, Eq, Copy, Hash)] pub struct TraceFlags(u8); @@ -98,7 +95,6 @@ impl fmt::LowerHex for TraceFlags { /// A 16-byte value which identifies a given trace. /// /// The id is valid if it contains at least one non-zero byte. -#[cfg_attr(feature = "serialize", derive(Deserialize, Serialize))] #[derive(Clone, PartialEq, Eq, Copy, Hash)] pub struct TraceId(pub(crate) u128); @@ -160,7 +156,6 @@ impl fmt::LowerHex for TraceId { /// An 8-byte value which identifies a given span. /// /// The id is valid if it contains at least one non-zero byte. -#[cfg_attr(feature = "serialize", derive(Deserialize, Serialize))] #[derive(Clone, PartialEq, Eq, Copy, Hash)] pub struct SpanId(pub(crate) u64); @@ -226,7 +221,6 @@ impl fmt::LowerHex for SpanId { /// Please review the [W3C specification] for details on this field. /// /// [W3C specification]: https://www.w3.org/TR/trace-context/#tracestate-header -#[cfg_attr(feature = "serialize", derive(Deserialize, Serialize))] #[derive(Clone, Debug, Default, Eq, PartialEq, Hash)] pub struct TraceState(Option>); @@ -445,7 +439,6 @@ pub enum TraceStateError { /// /// Spans that do not have the `sampled` flag set in their [`TraceFlags`] will /// be ignored by most tracing tools. -#[cfg_attr(feature = "serialize", derive(Deserialize, Serialize))] #[derive(Clone, Debug, PartialEq, Hash, Eq)] pub struct SpanContext { trace_id: TraceId, diff --git a/opentelemetry-sdk/Cargo.toml b/opentelemetry-sdk/Cargo.toml index 89ea7824e2..37595ae041 100644 --- a/opentelemetry-sdk/Cargo.toml +++ b/opentelemetry-sdk/Cargo.toml @@ -35,7 +35,6 @@ rand_distr = "0.4.0" default = ["trace"] trace = ["opentelemetry-api/trace", "crossbeam-channel", "rand", "pin-project", "async-trait", "percent-encoding"] metrics = ["opentelemetry-api/metrics", "dashmap", "fnv"] -serialize = ["opentelemetry-api/serialize", "serde"] testing = ["opentelemetry-api/testing", "trace", "metrics", "rt-async-std", "rt-tokio", "rt-tokio-current-thread", "tokio/macros", "tokio/rt-multi-thread"] rt-tokio = ["tokio", "tokio-stream"] rt-tokio-current-thread = ["tokio", "tokio-stream"] diff --git a/opentelemetry-sdk/src/export/metrics/stdout.rs b/opentelemetry-sdk/src/export/metrics/stdout.rs index 675eea2c33..aaf1ae722d 100644 --- a/opentelemetry-sdk/src/export/metrics/stdout.rs +++ b/opentelemetry-sdk/src/export/metrics/stdout.rs @@ -20,8 +20,6 @@ use opentelemetry_api::{ metrics::{Descriptor, MetricsError, Result}, KeyValue, }; -#[cfg(feature = "serialize")] -use serde::{Serialize, Serializer}; use std::fmt; use std::io; use std::iter; @@ -53,29 +51,20 @@ pub struct StdoutExporter { } /// A collection of exported lines -#[cfg_attr(feature = "serialize", derive(Serialize))] #[derive(Default, Debug)] pub struct ExportBatch { - #[cfg_attr(feature = "serialize", serde(skip_serializing_if = "Option::is_none"))] timestamp: Option, lines: Vec, } -#[cfg_attr(feature = "serialize", derive(Serialize))] #[derive(Default, Debug)] struct ExportLine { name: String, - #[cfg_attr(feature = "serialize", serde(skip_serializing_if = "Option::is_none"))] min: Option, - #[cfg_attr(feature = "serialize", serde(skip_serializing_if = "Option::is_none"))] max: Option, - #[cfg_attr(feature = "serialize", serde(skip_serializing_if = "Option::is_none"))] sum: Option, count: u64, - #[cfg_attr(feature = "serialize", serde(skip_serializing_if = "Option::is_none"))] last_value: Option, - - #[cfg_attr(feature = "serialize", serde(skip_serializing_if = "Option::is_none"))] timestamp: Option, } @@ -88,17 +77,6 @@ impl fmt::Debug for ExportNumeric { } } -#[cfg(feature = "serialize")] -impl Serialize for ExportNumeric { - fn serialize(&self, serializer: S) -> std::result::Result - where - S: Serializer, - { - let s = format!("{:?}", self); - serializer.serialize_str(&s) - } -} - impl Exporter for StdoutExporter where W: fmt::Debug + io::Write, diff --git a/opentelemetry-sdk/src/export/trace/mod.rs b/opentelemetry-sdk/src/export/trace/mod.rs index 857ca9b52f..2fe904419c 100644 --- a/opentelemetry-sdk/src/export/trace/mod.rs +++ b/opentelemetry-sdk/src/export/trace/mod.rs @@ -3,8 +3,6 @@ use async_trait::async_trait; use opentelemetry_api::trace::{ Event, Link, SpanContext, SpanId, SpanKind, StatusCode, TraceError, }; -#[cfg(feature = "serialize")] -use serde::{Deserialize, Serialize}; use std::borrow::Cow; use std::fmt::Debug; use std::sync::Arc; @@ -54,7 +52,6 @@ pub trait SpanExporter: Send + Debug { /// `SpanData` contains all the information collected by a `Span` and can be used /// by exporters as a standard input. -#[cfg_attr(feature = "serialize", derive(Deserialize, Serialize))] #[derive(Clone, Debug, PartialEq)] pub struct SpanData { /// Exportable `SpanContext` @@ -82,66 +79,5 @@ pub struct SpanData { /// Resource contains attributes representing an entity that produced this span. pub resource: Option>, /// Instrumentation library that produced this span - #[cfg_attr(feature = "serialize", serde(skip))] pub instrumentation_lib: crate::InstrumentationLibrary, } - -#[cfg(feature = "serialize")] -#[cfg(test)] -mod tests { - use super::*; - use opentelemetry_api::trace::{TraceFlags, TraceId, TraceState}; - - #[test] - fn test_serialise() { - let trace_id = 7; - let span_id = 99; - - let trace_flags = TraceFlags::default(); - let remote = false; - let span_context = SpanContext::new( - TraceId::from_u128(trace_id), - SpanId::from_u64(span_id), - trace_flags, - remote, - TraceState::default(), - ); - - let parent_span_id = 1; - let span_kind = SpanKind::Client; - let name = "foo/bar baz 人?!".into(); - let start_time = opentelemetry_api::time::now(); - let end_time = opentelemetry_api::time::now(); - - let capacity = 3; - let attributes = crate::trace::EvictedHashMap::new(capacity, 0); - let events = crate::trace::EvictedQueue::new(capacity); - let links = crate::trace::EvictedQueue::new(capacity); - - let status_code = StatusCode::Ok; - let status_message = "".into(); - let resource = None; - - let span_data = SpanData { - span_context, - parent_span_id: SpanId::from_u64(parent_span_id), - span_kind, - name, - start_time, - end_time, - attributes, - events, - links, - status_code, - status_message, - resource, - instrumentation_lib: crate::InstrumentationLibrary::new("", None), - }; - - let encoded: Vec = bincode::serialize(&span_data).unwrap(); - - let decoded: SpanData = bincode::deserialize(&encoded[..]).unwrap(); - - assert_eq!(span_data, decoded); - } -} diff --git a/opentelemetry-sdk/src/resource/mod.rs b/opentelemetry-sdk/src/resource/mod.rs index bbf4551b22..56410f11a0 100644 --- a/opentelemetry-sdk/src/resource/mod.rs +++ b/opentelemetry-sdk/src/resource/mod.rs @@ -34,8 +34,6 @@ pub use process::ProcessResourceDetector; #[cfg(feature = "metrics")] use opentelemetry_api::attributes; use opentelemetry_api::{Key, KeyValue, Value}; -#[cfg(feature = "serialize")] -use serde::{Deserialize, Serialize}; use std::collections::{btree_map, BTreeMap}; use std::ops::Deref; use std::time::Duration; @@ -43,7 +41,6 @@ use std::time::Duration; /// Describes an entity about which identifying information and metadata is exposed. /// /// Items are sorted by their key, and are only overwritten if the value is an empty string. -#[cfg_attr(feature = "serialize", derive(Deserialize, Serialize))] #[derive(Clone, Debug, PartialEq)] pub struct Resource { attrs: BTreeMap, diff --git a/opentelemetry-sdk/src/trace/evicted_hash_map.rs b/opentelemetry-sdk/src/trace/evicted_hash_map.rs index bf7753f9be..d766b14136 100644 --- a/opentelemetry-sdk/src/trace/evicted_hash_map.rs +++ b/opentelemetry-sdk/src/trace/evicted_hash_map.rs @@ -1,14 +1,11 @@ //! # Evicted Map use opentelemetry_api::{Key, KeyValue, Value}; -#[cfg(feature = "serialize")] -use serde::{Deserialize, Serialize}; use std::collections::hash_map::Entry; use std::collections::{HashMap, LinkedList}; /// A hash map with a capped number of attributes that retains the most /// recently set entries. -#[cfg_attr(feature = "serialize", derive(Deserialize, Serialize))] #[derive(Clone, Debug, PartialEq)] pub struct EvictedHashMap { map: HashMap, diff --git a/opentelemetry-sdk/src/trace/evicted_queue.rs b/opentelemetry-sdk/src/trace/evicted_queue.rs index fd2549584b..56ec3c5bc0 100644 --- a/opentelemetry-sdk/src/trace/evicted_queue.rs +++ b/opentelemetry-sdk/src/trace/evicted_queue.rs @@ -1,13 +1,10 @@ //! # Evicted Queue -#[cfg(feature = "serialize")] -use serde::{Deserialize, Serialize}; use std::collections::VecDeque; /// This queue maintains an ordered list of elements, and a count of /// dropped elements. Elements are removed from the queue in a first /// in first out fashion. -#[cfg_attr(feature = "serialize", derive(Deserialize, Serialize))] #[derive(Clone, Debug, PartialEq)] pub struct EvictedQueue { queue: Option>, diff --git a/opentelemetry-sdk/src/trace/sampler.rs b/opentelemetry-sdk/src/trace/sampler.rs index 5c2321163d..8928632584 100644 --- a/opentelemetry-sdk/src/trace/sampler.rs +++ b/opentelemetry-sdk/src/trace/sampler.rs @@ -44,8 +44,6 @@ use opentelemetry_api::{ }, Context, KeyValue, }; -#[cfg(feature = "serialize")] -use serde::{Deserialize, Serialize}; use std::convert::TryInto; /// The `ShouldSample` interface allows implementations to provide samplers @@ -67,7 +65,6 @@ pub trait ShouldSample: Send + Sync + std::fmt::Debug { } /// Sampling options -#[cfg_attr(feature = "serialize", derive(Deserialize, Serialize))] #[derive(Clone, Debug, PartialEq)] pub enum Sampler { /// Always sample the trace diff --git a/opentelemetry-sdk/src/trace/span_limit.rs b/opentelemetry-sdk/src/trace/span_limit.rs index 52e9a9c76b..77ea183c30 100644 --- a/opentelemetry-sdk/src/trace/span_limit.rs +++ b/opentelemetry-sdk/src/trace/span_limit.rs @@ -13,9 +13,6 @@ /// If the limit has been breached. The attributes, events or links will be dropped based on their /// index in the collection. The one added to collections later will be dropped first. -#[cfg(feature = "serialize")] -use serde::{Deserialize, Serialize}; - pub(crate) const DEFAULT_MAX_EVENT_PER_SPAN: u32 = 128; pub(crate) const DEFAULT_MAX_ATTRIBUTES_PER_SPAN: u32 = 128; pub(crate) const DEFAULT_MAX_LINKS_PER_SPAN: u32 = 128; @@ -23,7 +20,6 @@ pub(crate) const DEFAULT_MAX_ATTRIBUTES_PER_EVENT: u32 = 128; pub(crate) const DEFAULT_MAX_ATTRIBUTES_PER_LINK: u32 = 128; /// Span limit configuration to keep attributes, events and links to a span in a reasonable number. -#[cfg_attr(feature = "serialize", derive(Deserialize, Serialize))] #[derive(Copy, Clone, Debug)] pub struct SpanLimits { /// The max events that can be added to a `Span`. diff --git a/opentelemetry/Cargo.toml b/opentelemetry/Cargo.toml index 66eb0ec732..63593ad68e 100644 --- a/opentelemetry/Cargo.toml +++ b/opentelemetry/Cargo.toml @@ -27,7 +27,6 @@ opentelemetry-sdk = { version = "0.1", path = "../opentelemetry-sdk" } default = ["trace"] trace = ["opentelemetry-api/trace", "opentelemetry-sdk/trace"] metrics = ["opentelemetry-api/metrics", "opentelemetry-sdk/metrics"] -serialize = ["opentelemetry-api/serialize", "opentelemetry-sdk/serialize"] testing = ["opentelemetry-sdk/testing"] rt-tokio = ["opentelemetry-sdk/rt-tokio"] rt-tokio-current-thread = ["opentelemetry-sdk/rt-tokio-current-thread"] diff --git a/opentelemetry/src/lib.rs b/opentelemetry/src/lib.rs index 839a905916..710343abdf 100644 --- a/opentelemetry/src/lib.rs +++ b/opentelemetry/src/lib.rs @@ -104,7 +104,6 @@ //! //! * `trace`: Includes the trace API and SDK (enabled by default). //! * `metrics`: Includes the unstable metrics API and SDK. -//! * `serialize`: Adds [serde] serializers for common types. //! //! Support for recording and exporting telemetry asynchronously can be added //! via the following flags: @@ -115,7 +114,6 @@ //! //! [tokio]: https://crates.io/crates/tokio //! [async-std]: https://crates.io/crates/async-std -//! [serde]: https://crates.io/crates/serde //! //! ## Related Crates //! From 31ca9edaa98d38f523d85925478b43ad69ffe662 Mon Sep 17 00:00:00 2001 From: Julian Tescher Date: Sat, 19 Feb 2022 14:45:24 -0500 Subject: [PATCH 2/2] Fix doc comment links --- opentelemetry-api/src/baggage.rs | 3 +-- opentelemetry-api/src/global/mod.rs | 6 ++---- opentelemetry-api/src/lib.rs | 15 +++++++++++++++ opentelemetry-api/src/trace/mod.rs | 3 +-- opentelemetry-sdk/src/propagation/baggage.rs | 4 ++-- opentelemetry-sdk/src/propagation/composite.rs | 4 ++-- opentelemetry-sdk/src/testing/trace.rs | 2 +- opentelemetry-sdk/src/trace/span_processor.rs | 4 ++-- 8 files changed, 26 insertions(+), 15 deletions(-) diff --git a/opentelemetry-api/src/baggage.rs b/opentelemetry-api/src/baggage.rs index bdf5c22cae..51d3a57748 100644 --- a/opentelemetry-api/src/baggage.rs +++ b/opentelemetry-api/src/baggage.rs @@ -6,10 +6,9 @@ //! information to metrics, traces, and logs. //! * [`BaggageExt`]: Extensions for managing `Baggage` in a [`Context`]. //! -//! Baggage can be sent between systems using the [`BaggagePropagator`] in +//! Baggage can be sent between systems using a baggage propagator in //! accordance with the [W3C Baggage] specification. //! -//! [`BaggagePropagator`]: crate::sdk::propagation::BaggagePropagator //! [W3C Baggage]: https://w3c.github.io/baggage use crate::{Context, Key, KeyValue, Value}; use std::collections::{hash_map, HashMap}; diff --git a/opentelemetry-api/src/global/mod.rs b/opentelemetry-api/src/global/mod.rs index 6472735159..25a865a2c5 100644 --- a/opentelemetry-api/src/global/mod.rs +++ b/opentelemetry-api/src/global/mod.rs @@ -12,7 +12,7 @@ //! //! ### Usage in Applications //! -//! Applications configure their tracer either by [installing a trace pipeline], +//! Applications configure their tracer either by installing a trace pipeline, //! or calling [`set_tracer_provider`]. //! //! ``` @@ -68,7 +68,6 @@ //! # } //! ``` //! -//! [installing a trace pipeline]: crate::sdk::export::trace::stdout::PipelineBuilder::install_simple //! [`TracerProvider`]: crate::trace::TracerProvider //! [`Span`]: crate::trace::Span //! @@ -84,7 +83,7 @@ //! //! ### Usage in Applications //! -//! Applications configure their meter either by [installing a metrics pipeline], +//! Applications configure their meter either by installing a metrics pipeline, //! or calling [`set_meter_provider`]. //! //! ``` @@ -135,7 +134,6 @@ //! # } //! ``` //! -//! [installing a metrics pipeline]: crate::sdk::export::metrics::stdout::StdoutExporterBuilder::init //! [`MeterProvider`]: crate::metrics::MeterProvider //! [`set_meter_provider`]: crate::global::set_meter_provider diff --git a/opentelemetry-api/src/lib.rs b/opentelemetry-api/src/lib.rs index 6168103911..0598c8cc70 100644 --- a/opentelemetry-api/src/lib.rs +++ b/opentelemetry-api/src/lib.rs @@ -3,9 +3,24 @@ //! can analyze them using [Prometheus], [Jaeger], and other observability tools. //! //! *Compiler support: [requires `rustc` 1.46+][msrv]* +//! //! [Prometheus]: https://prometheus.io //! [Jaeger]: https://www.jaegertracing.io //! [msrv]: #supported-rust-versions +//! +//! ## Supported Rust Versions +//! +//! OpenTelemetry is built against the latest stable release. The minimum +//! supported version is 1.46. The current OpenTelemetry version is not +//! guaranteed to build on Rust versions earlier than the minimum supported +//! version. +//! +//! The current stable Rust compiler and the three most recent minor versions +//! before it will always be supported. For example, if the current stable +//! compiler version is 1.49, the minimum supported version will not be +//! increased past 1.46, three minor versions prior. Increasing the minimum +//! supported compiler version is not considered a semver breaking change as +//! long as doing so complies with this policy. #![warn( future_incompatible, missing_debug_implementations, diff --git a/opentelemetry-api/src/trace/mod.rs b/opentelemetry-api/src/trace/mod.rs index cb1d04b75b..acb6877c1f 100644 --- a/opentelemetry-api/src/trace/mod.rs +++ b/opentelemetry-api/src/trace/mod.rs @@ -53,11 +53,10 @@ //! Exporting spans often involves sending data over a network or performing //! other I/O tasks. OpenTelemetry allows you to schedule these tasks using //! whichever runtime you area already using such as [Tokio] or [async-std]. -//! When using an async runtime it's best to use the [`BatchSpanProcessor`] +//! When using an async runtime it's best to use the batch span processor //! where the spans will be sent in batches as opposed to being sent once ended, //! which often ends up being more efficient. //! -//! [`BatchSpanProcessor`]: crate::sdk::trace::BatchSpanProcessor //! [Tokio]: https://tokio.rs //! [async-std]: https://async.rs //! diff --git a/opentelemetry-sdk/src/propagation/baggage.rs b/opentelemetry-sdk/src/propagation/baggage.rs index bd736e5da8..8b16c8eff1 100644 --- a/opentelemetry-sdk/src/propagation/baggage.rs +++ b/opentelemetry-sdk/src/propagation/baggage.rs @@ -7,7 +7,7 @@ //! `Baggage`s are serialized according to the editor's draft of //! the [W3C Baggage] specification. //! -//! [`Baggage`]: crate::baggage::Baggage +//! [`Baggage`]: opentelemetry_api::baggage::Baggage //! [W3C Baggage]: https://w3c.github.io/baggage/ //! //! # Examples @@ -96,7 +96,7 @@ lazy_static::lazy_static! { /// ``` /// /// [W3C Baggage]: https://w3c.github.io/baggage -/// [`Baggage`]: crate::baggage::Baggage +/// [`Baggage`]: opentelemetry_api::baggage::Baggage #[derive(Debug, Default)] pub struct BaggagePropagator { _private: (), diff --git a/opentelemetry-sdk/src/propagation/composite.rs b/opentelemetry-sdk/src/propagation/composite.rs index 1cf9d87d0f..cddd6c934c 100644 --- a/opentelemetry-sdk/src/propagation/composite.rs +++ b/opentelemetry-sdk/src/propagation/composite.rs @@ -12,7 +12,7 @@ use std::collections::HashSet; /// Injection and extraction from this propagator will preserve the order of the /// injectors and extractors passed in during initialization. /// -/// [`TextMapPropagator`]: crate::propagation::TextMapPropagator +/// [`TextMapPropagator`]: opentelemetry_api::propagation::TextMapPropagator /// /// # Examples /// @@ -67,7 +67,7 @@ pub struct TextMapCompositePropagator { impl TextMapCompositePropagator { /// Constructs a new propagator out of instances of [`TextMapPropagator`]. /// - /// [`TextMapPropagator`]: crate::propagation::TextMapPropagator + /// [`TextMapPropagator`]: opentelemetry_api::propagation::TextMapPropagator pub fn new(propagators: Vec>) -> Self { let mut fields = HashSet::new(); for propagator in &propagators { diff --git a/opentelemetry-sdk/src/testing/trace.rs b/opentelemetry-sdk/src/testing/trace.rs index c56d4ce795..bfe3bf07d0 100644 --- a/opentelemetry-sdk/src/testing/trace.rs +++ b/opentelemetry-sdk/src/testing/trace.rs @@ -130,7 +130,7 @@ impl From> for TestExportError { /// A no-op instance of an [`SpanExporter`]. /// -/// [`SpanExporter`]: crate::sdk::export::trace::SpanExporter +/// [`SpanExporter`]: crate::export::trace::SpanExporter #[derive(Debug, Default)] pub struct NoopSpanExporter { _private: (), diff --git a/opentelemetry-sdk/src/trace/span_processor.rs b/opentelemetry-sdk/src/trace/span_processor.rs index c28eb10f3e..001dc763f9 100644 --- a/opentelemetry-sdk/src/trace/span_processor.rs +++ b/opentelemetry-sdk/src/trace/span_processor.rs @@ -31,8 +31,8 @@ //! +-----+--------------+ +---------------------+ //! ``` //! -//! [`is_recording`]: crate::trace::Span::is_recording() -//! [`TracerProvider`]: crate::trace::TracerProvider +//! [`is_recording`]: opentelemetry_api::trace::Span::is_recording() +//! [`TracerProvider`]: opentelemetry_api::trace::TracerProvider use crate::export::trace::{ExportResult, SpanData, SpanExporter}; use crate::trace::runtime::{TraceRuntime, TrySend};