Skip to content

Commit

Permalink
Remove serialize feature (#738)
Browse files Browse the repository at this point in the history
Removes non-spec serialization support to reduce public API surface
area.
  • Loading branch information
jtescher committed Feb 19, 2022
1 parent dacd75a commit cdd8fa0
Show file tree
Hide file tree
Showing 31 changed files with 36 additions and 168 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion examples/basic-otlp-http/Cargo.toml
Expand Up @@ -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"] }
2 changes: 1 addition & 1 deletion examples/basic-otlp-with-selector/Cargo.toml
Expand Up @@ -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"] }
2 changes: 1 addition & 1 deletion examples/basic-otlp/Cargo.toml
Expand Up @@ -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"] }
3 changes: 1 addition & 2 deletions examples/basic/Cargo.toml
Expand Up @@ -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"] }
10 changes: 2 additions & 8 deletions examples/basic/src/main.rs
Expand Up @@ -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,
};
Expand All @@ -29,13 +29,7 @@ fn delayed_interval(duration: Duration) -> impl Stream<Item = tokio::time::Insta
}

fn init_meter() -> 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");
Expand Down
2 changes: 1 addition & 1 deletion examples/dynatrace/Cargo.toml
Expand Up @@ -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"] }
Expand Down
5 changes: 1 addition & 4 deletions examples/external-otlp-grpcio-async-std/Cargo.toml
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion examples/external-otlp-tonic-tokio/Cargo.toml
Expand Up @@ -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"] }
Expand Down
2 changes: 0 additions & 2 deletions opentelemetry-api/Cargo.toml
Expand Up @@ -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 }

Expand All @@ -24,5 +23,4 @@ js-sys = "0.3"
default = ["trace"]
trace = ["pin-project"]
metrics = ["fnv"]
serialize = ["serde"]
testing = ["trace"]
7 changes: 1 addition & 6 deletions opentelemetry-api/src/baggage.rs
Expand Up @@ -6,14 +6,11 @@
//! 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};
#[cfg(feature = "serialize")]
use serde::{Deserialize, Serialize};
use std::collections::{hash_map, HashMap};
use std::iter::FromIterator;

Expand Down Expand Up @@ -375,7 +372,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);

Expand All @@ -399,7 +395,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
Expand Down
6 changes: 0 additions & 6 deletions 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>);

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions opentelemetry-api/src/global/mod.rs
Expand Up @@ -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`].
//!
//! ```
Expand Down Expand Up @@ -68,7 +68,6 @@
//! # }
//! ```
//!
//! [installing a trace pipeline]: crate::sdk::export::trace::stdout::PipelineBuilder::install_simple
//! [`TracerProvider`]: crate::trace::TracerProvider
//! [`Span`]: crate::trace::Span
//!
Expand All @@ -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`].
//!
//! ```
Expand Down Expand Up @@ -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

Expand Down
15 changes: 15 additions & 0 deletions opentelemetry-api/src/lib.rs
Expand Up @@ -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,
Expand Down
7 changes: 1 addition & 6 deletions opentelemetry-api/src/trace/mod.rs
Expand Up @@ -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
//!
Expand Down Expand Up @@ -150,8 +149,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;
Expand Down Expand Up @@ -242,7 +239,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
Expand Down Expand Up @@ -284,7 +280,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,
Expand Down
4 changes: 0 additions & 4 deletions opentelemetry-api/src/trace/span.rs
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
7 changes: 0 additions & 7 deletions opentelemetry-api/src/trace/span_context.rs
Expand Up @@ -10,8 +10,6 @@
//! The spec can be viewed here: <https://github.com/open-telemetry/opentelemetry-specification/blob/v1.3.0/specification/trace/api.md#spancontext>
//!
//! [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;
Expand All @@ -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);

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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<VecDeque<(String, String)>>);

Expand Down Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion opentelemetry-sdk/Cargo.toml
Expand Up @@ -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"]
Expand Down

0 comments on commit cdd8fa0

Please sign in to comment.