Skip to content

Commit cdd8fa0

Browse files
authored
Remove serialize feature (open-telemetry#738)
Removes non-spec serialization support to reduce public API surface area.
1 parent dacd75a commit cdd8fa0

File tree

31 files changed

+36
-168
lines changed

31 files changed

+36
-168
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ jobs:
7272
override: true
7373
- name: Run tests
7474
run: cargo --version &&
75-
cargo test --verbose --manifest-path=opentelemetry/Cargo.toml --features trace,metrics,serialize,rt-tokio,testing &&
75+
cargo test --verbose --manifest-path=opentelemetry/Cargo.toml --features trace,metrics,rt-tokio,testing &&
7676
cargo test --manifest-path=opentelemetry-jaeger/Cargo.toml --features rt-tokio &&
7777
cargo test --manifest-path=opentelemetry-zipkin/Cargo.toml
7878
cargo-deny:

examples/basic-otlp-http/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ edition = "2018"
55
publish = false
66

77
[dependencies]
8-
opentelemetry = { path = "../../opentelemetry", features = ["rt-tokio", "metrics", "serialize"] }
8+
opentelemetry = { path = "../../opentelemetry", features = ["rt-tokio", "metrics"] }
99
opentelemetry-otlp = { path = "../../opentelemetry-otlp", features = ["http-proto", "reqwest-client"] }
1010
tokio = { version = "1.0", features = ["full"] }

examples/basic-otlp-with-selector/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ publish = false
77
[dependencies]
88
futures-util = { version = "0.3", default-features = false, features = ["std"] }
99
lazy_static = "1.4"
10-
opentelemetry = { path = "../../opentelemetry", features = ["rt-tokio", "metrics", "serialize"] }
10+
opentelemetry = { path = "../../opentelemetry", features = ["rt-tokio", "metrics"] }
1111
opentelemetry-otlp = { path = "../../opentelemetry-otlp", features = ["tonic", "metrics"] }
1212
serde_json = "1.0"
1313
tokio = { version = "1.0", features = ["full"] }

examples/basic-otlp/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ publish = false
77
[dependencies]
88
futures-util = { version = "0.3", default-features = false, features = ["std"] }
99
lazy_static = "1.4"
10-
opentelemetry = { path = "../../opentelemetry", features = ["rt-tokio", "metrics", "serialize"] }
10+
opentelemetry = { path = "../../opentelemetry", features = ["rt-tokio", "metrics"] }
1111
opentelemetry-otlp = { path = "../../opentelemetry-otlp", features = ["tonic", "metrics"] }
1212
serde_json = "1.0"
1313
tokio = { version = "1.0", features = ["full"] }

examples/basic/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ publish = false
77
[dependencies]
88
futures-util = { version = "0.3", default-features = false, features = ["std"] }
99
lazy_static = "1.4"
10-
opentelemetry = { path = "../../opentelemetry", features = ["serialize", "rt-tokio", "metrics"] }
10+
opentelemetry = { path = "../../opentelemetry", features = ["rt-tokio", "metrics"] }
1111
opentelemetry-jaeger = { path = "../../opentelemetry-jaeger", features = ["rt-tokio"] }
12-
serde_json = "1.0"
1312
thrift = "0.13"
1413
tokio = { version = "1.0", features = ["full"] }

examples/basic/src/main.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use opentelemetry::sdk::{metrics::PushController, trace as sdktrace, Resource};
66
use opentelemetry::trace::TraceError;
77
use opentelemetry::{
88
baggage::BaggageExt,
9-
metrics::{MetricsError, ObserverResult},
9+
metrics::ObserverResult,
1010
trace::{TraceContextExt, Tracer},
1111
Context, Key, KeyValue,
1212
};
@@ -29,13 +29,7 @@ fn delayed_interval(duration: Duration) -> impl Stream<Item = tokio::time::Insta
2929
}
3030

3131
fn init_meter() -> PushController {
32-
opentelemetry::sdk::export::metrics::stdout(tokio::spawn, delayed_interval)
33-
.with_formatter(|batch| {
34-
serde_json::to_value(batch)
35-
.map(|value| value.to_string())
36-
.map_err(|err| MetricsError::Other(err.to_string()))
37-
})
38-
.init()
32+
opentelemetry::sdk::export::metrics::stdout(tokio::spawn, delayed_interval).init()
3933
}
4034

4135
const FOO_KEY: Key = Key::from_static_str("ex.com/foo");

examples/dynatrace/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ publish = false
88
futures = "0.3"
99
http = "0.2"
1010
lazy_static = "1.4"
11-
opentelemetry = { path = "../../opentelemetry", default-features = false, features = ["trace", "serialize"] }
11+
opentelemetry = { path = "../../opentelemetry", default-features = false, features = ["trace"] }
1212
opentelemetry-dynatrace = { path = "../../opentelemetry-dynatrace" }
1313
opentelemetry-http = { path = "../../opentelemetry-http", default-features = false }
1414
opentelemetry-otlp = { path = "../../opentelemetry-otlp", default-features = false, features = ["http-proto", "reqwest-client"] }

examples/external-otlp-grpcio-async-std/Cargo.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@ publish = false
77
[dependencies]
88
async-std = { version = "1.9.0", features = ["attributes"] }
99
env_logger = "0.8.2"
10-
opentelemetry = { path = "../../opentelemetry", features = [
11-
"rt-async-std",
12-
"serialize"
13-
] }
10+
opentelemetry = { path = "../../opentelemetry", features = ["rt-async-std"] }
1411
opentelemetry-otlp = { path = "../../opentelemetry-otlp", features = [
1512
"grpc-sys",
1613
"trace",

examples/external-otlp-tonic-tokio/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ edition = "2018"
55
publish = false
66

77
[dependencies]
8-
opentelemetry = { path = "../../opentelemetry", features = ["rt-tokio", "metrics", "serialize"] }
8+
opentelemetry = { path = "../../opentelemetry", features = ["rt-tokio", "metrics"] }
99
opentelemetry-otlp = { path = "../../opentelemetry-otlp", features = ["tonic", "tls", "tls-roots"] }
1010
serde_json = "1.0"
1111
tokio = { version = "1.0", features = ["full"] }

opentelemetry-api/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ futures-channel = "0.3"
99
futures-util = { version = "0.3", default-features = false, features = ["std", "sink"] }
1010
lazy_static = "1.4"
1111
pin-project = { version = "1.0.2", optional = true }
12-
serde = { version = "1.0", features = ["derive", "rc"], optional = true }
1312
thiserror = "1"
1413
tokio-stream = { version = "0.1", optional = true }
1514

@@ -24,5 +23,4 @@ js-sys = "0.3"
2423
default = ["trace"]
2524
trace = ["pin-project"]
2625
metrics = ["fnv"]
27-
serialize = ["serde"]
2826
testing = ["trace"]

opentelemetry-api/src/baggage.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,11 @@
66
//! information to metrics, traces, and logs.
77
//! * [`BaggageExt`]: Extensions for managing `Baggage` in a [`Context`].
88
//!
9-
//! Baggage can be sent between systems using the [`BaggagePropagator`] in
9+
//! Baggage can be sent between systems using a baggage propagator in
1010
//! accordance with the [W3C Baggage] specification.
1111
//!
12-
//! [`BaggagePropagator`]: crate::sdk::propagation::BaggagePropagator
1312
//! [W3C Baggage]: https://w3c.github.io/baggage
1413
use crate::{Context, Key, KeyValue, Value};
15-
#[cfg(feature = "serialize")]
16-
use serde::{Deserialize, Serialize};
1714
use std::collections::{hash_map, HashMap};
1815
use std::iter::FromIterator;
1916

@@ -375,7 +372,6 @@ impl BaggageExt for Context {
375372
/// `BaggageMetadata` can be added to values in the form of a property set,
376373
/// represented as semi-colon `;` delimited list of names and/or name-value
377374
/// pairs, e.g. `;k1=v1;k2;k3=v3`.
378-
#[cfg_attr(feature = "serialize", derive(Deserialize, Serialize))]
379375
#[derive(Clone, Debug, PartialOrd, PartialEq, Default)]
380376
pub struct BaggageMetadata(String);
381377

@@ -399,7 +395,6 @@ impl From<&str> for BaggageMetadata {
399395
}
400396

401397
/// [`Baggage`] name-value pairs with their associated metadata.
402-
#[cfg_attr(feature = "serialize", derive(Deserialize, Serialize))]
403398
#[derive(Clone, Debug, PartialEq)]
404399
pub struct KeyValueMetadata {
405400
/// Dimension or event key

opentelemetry-api/src/common.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
#[cfg(feature = "serialize")]
2-
use serde::{Deserialize, Serialize};
31
use std::borrow::Cow;
42
use std::fmt;
53

64
/// Key used for metric `AttributeSet`s and trace `Span` attributes.
7-
#[cfg_attr(feature = "serialize", derive(Deserialize, Serialize))]
85
#[derive(Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
96
pub struct Key(Cow<'static, str>);
107

@@ -93,7 +90,6 @@ impl fmt::Display for Key {
9390
}
9491

9592
/// Array of homogeneous values
96-
#[cfg_attr(feature = "serialize", derive(Deserialize, Serialize))]
9793
#[derive(Clone, Debug, PartialEq)]
9894
pub enum Array {
9995
/// Array of bools
@@ -157,7 +153,6 @@ into_array!(
157153
);
158154

159155
/// Value types for use in `KeyValue` pairs.
160-
#[cfg_attr(feature = "serialize", derive(Deserialize, Serialize))]
161156
#[derive(Clone, Debug, PartialEq)]
162157
pub enum Value {
163158
/// bool values
@@ -237,7 +232,6 @@ impl fmt::Display for Value {
237232
}
238233

239234
/// `KeyValue` pairs are used by `AttributeSet`s and `Span` attributes.
240-
#[cfg_attr(feature = "serialize", derive(Deserialize, Serialize))]
241235
#[derive(Clone, Debug, PartialEq)]
242236
pub struct KeyValue {
243237
/// Dimension or event key

opentelemetry-api/src/global/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
//!
1313
//! ### Usage in Applications
1414
//!
15-
//! Applications configure their tracer either by [installing a trace pipeline],
15+
//! Applications configure their tracer either by installing a trace pipeline,
1616
//! or calling [`set_tracer_provider`].
1717
//!
1818
//! ```
@@ -68,7 +68,6 @@
6868
//! # }
6969
//! ```
7070
//!
71-
//! [installing a trace pipeline]: crate::sdk::export::trace::stdout::PipelineBuilder::install_simple
7271
//! [`TracerProvider`]: crate::trace::TracerProvider
7372
//! [`Span`]: crate::trace::Span
7473
//!
@@ -84,7 +83,7 @@
8483
//!
8584
//! ### Usage in Applications
8685
//!
87-
//! Applications configure their meter either by [installing a metrics pipeline],
86+
//! Applications configure their meter either by installing a metrics pipeline,
8887
//! or calling [`set_meter_provider`].
8988
//!
9089
//! ```
@@ -135,7 +134,6 @@
135134
//! # }
136135
//! ```
137136
//!
138-
//! [installing a metrics pipeline]: crate::sdk::export::metrics::stdout::StdoutExporterBuilder::init
139137
//! [`MeterProvider`]: crate::metrics::MeterProvider
140138
//! [`set_meter_provider`]: crate::global::set_meter_provider
141139

opentelemetry-api/src/lib.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,24 @@
33
//! can analyze them using [Prometheus], [Jaeger], and other observability tools.
44
//!
55
//! *Compiler support: [requires `rustc` 1.46+][msrv]*
6+
//!
67
//! [Prometheus]: https://prometheus.io
78
//! [Jaeger]: https://www.jaegertracing.io
89
//! [msrv]: #supported-rust-versions
10+
//!
11+
//! ## Supported Rust Versions
12+
//!
13+
//! OpenTelemetry is built against the latest stable release. The minimum
14+
//! supported version is 1.46. The current OpenTelemetry version is not
15+
//! guaranteed to build on Rust versions earlier than the minimum supported
16+
//! version.
17+
//!
18+
//! The current stable Rust compiler and the three most recent minor versions
19+
//! before it will always be supported. For example, if the current stable
20+
//! compiler version is 1.49, the minimum supported version will not be
21+
//! increased past 1.46, three minor versions prior. Increasing the minimum
22+
//! supported compiler version is not considered a semver breaking change as
23+
//! long as doing so complies with this policy.
924
#![warn(
1025
future_incompatible,
1126
missing_debug_implementations,

opentelemetry-api/src/trace/mod.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,10 @@
5353
//! Exporting spans often involves sending data over a network or performing
5454
//! other I/O tasks. OpenTelemetry allows you to schedule these tasks using
5555
//! whichever runtime you area already using such as [Tokio] or [async-std].
56-
//! When using an async runtime it's best to use the [`BatchSpanProcessor`]
56+
//! When using an async runtime it's best to use the batch span processor
5757
//! where the spans will be sent in batches as opposed to being sent once ended,
5858
//! which often ends up being more efficient.
5959
//!
60-
//! [`BatchSpanProcessor`]: crate::sdk::trace::BatchSpanProcessor
6160
//! [Tokio]: https://tokio.rs
6261
//! [async-std]: https://async.rs
6362
//!
@@ -150,8 +149,6 @@
150149
//! ```
151150
152151
use futures_channel::{mpsc::TrySendError, oneshot::Canceled};
153-
#[cfg(feature = "serialize")]
154-
use serde::{Deserialize, Serialize};
155152
use std::borrow::Cow;
156153
use std::fmt;
157154
use std::time;
@@ -242,7 +239,6 @@ pub trait IdGenerator: Send + Sync + fmt::Debug {
242239

243240
/// A `Span` has the ability to add events. Events have a time associated
244241
/// with the moment when they are added to the `Span`.
245-
#[cfg_attr(feature = "serialize", derive(Deserialize, Serialize))]
246242
#[derive(Clone, Debug, PartialEq)]
247243
pub struct Event {
248244
/// Event name
@@ -284,7 +280,6 @@ impl Event {
284280

285281
/// During the `Span` creation user MUST have the ability to record links to other `Span`s. Linked
286282
/// `Span`s can be from the same or a different trace.
287-
#[cfg_attr(feature = "serialize", derive(Deserialize, Serialize))]
288283
#[derive(Clone, Debug, PartialEq)]
289284
pub struct Link {
290285
span_context: SpanContext,

opentelemetry-api/src/trace/span.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
//! implementations MUST NOT allow callers to create Spans directly. All `Span`s MUST be created
1717
//! via a Tracer.
1818
use crate::{trace::SpanContext, KeyValue};
19-
#[cfg(feature = "serialize")]
20-
use serde::{Deserialize, Serialize};
2119
use std::borrow::Cow;
2220
use std::error::Error;
2321
use std::fmt;
@@ -212,7 +210,6 @@ pub trait Span {
212210
/// | `Producer` | | yes | | yes |
213211
/// | `Consumer` | | yes | yes | |
214212
/// | `Internal` | | | | |
215-
#[cfg_attr(feature = "serialize", derive(Deserialize, Serialize))]
216213
#[derive(Clone, Debug, PartialEq)]
217214
pub enum SpanKind {
218215
/// Indicates that the span describes a synchronous request to
@@ -254,7 +251,6 @@ impl fmt::Display for SpanKind {
254251
/// The `StatusCode` interface represents the status of a finished `Span`.
255252
/// It's composed of a canonical code in conjunction with an optional
256253
/// descriptive message.
257-
#[cfg_attr(feature = "serialize", derive(Deserialize, Serialize))]
258254
#[derive(Clone, Debug, PartialEq, Copy)]
259255
pub enum StatusCode {
260256
/// The default status.

opentelemetry-api/src/trace/span_context.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
//! The spec can be viewed here: <https://github.com/open-telemetry/opentelemetry-specification/blob/v1.3.0/specification/trace/api.md#spancontext>
1111
//!
1212
//! [w3c TraceContext specification]: https://www.w3.org/TR/trace-context/
13-
#[cfg(feature = "serialize")]
14-
use serde::{Deserialize, Serialize};
1513
use std::collections::VecDeque;
1614
use std::fmt;
1715
use std::hash::Hash;
@@ -27,7 +25,6 @@ use thiserror::Error;
2725
/// See the W3C TraceContext specification's [trace-flags] section for more details.
2826
///
2927
/// [trace-flags]: https://www.w3.org/TR/trace-context/#trace-flags
30-
#[cfg_attr(feature = "serialize", derive(Deserialize, Serialize))]
3128
#[derive(Clone, Debug, Default, PartialEq, Eq, Copy, Hash)]
3229
pub struct TraceFlags(u8);
3330

@@ -98,7 +95,6 @@ impl fmt::LowerHex for TraceFlags {
9895
/// A 16-byte value which identifies a given trace.
9996
///
10097
/// The id is valid if it contains at least one non-zero byte.
101-
#[cfg_attr(feature = "serialize", derive(Deserialize, Serialize))]
10298
#[derive(Clone, PartialEq, Eq, Copy, Hash)]
10399
pub struct TraceId(pub(crate) u128);
104100

@@ -160,7 +156,6 @@ impl fmt::LowerHex for TraceId {
160156
/// An 8-byte value which identifies a given span.
161157
///
162158
/// The id is valid if it contains at least one non-zero byte.
163-
#[cfg_attr(feature = "serialize", derive(Deserialize, Serialize))]
164159
#[derive(Clone, PartialEq, Eq, Copy, Hash)]
165160
pub struct SpanId(pub(crate) u64);
166161

@@ -226,7 +221,6 @@ impl fmt::LowerHex for SpanId {
226221
/// Please review the [W3C specification] for details on this field.
227222
///
228223
/// [W3C specification]: https://www.w3.org/TR/trace-context/#tracestate-header
229-
#[cfg_attr(feature = "serialize", derive(Deserialize, Serialize))]
230224
#[derive(Clone, Debug, Default, Eq, PartialEq, Hash)]
231225
pub struct TraceState(Option<VecDeque<(String, String)>>);
232226

@@ -445,7 +439,6 @@ pub enum TraceStateError {
445439
///
446440
/// Spans that do not have the `sampled` flag set in their [`TraceFlags`] will
447441
/// be ignored by most tracing tools.
448-
#[cfg_attr(feature = "serialize", derive(Deserialize, Serialize))]
449442
#[derive(Clone, Debug, PartialEq, Hash, Eq)]
450443
pub struct SpanContext {
451444
trace_id: TraceId,

opentelemetry-sdk/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ rand_distr = "0.4.0"
3535
default = ["trace"]
3636
trace = ["opentelemetry-api/trace", "crossbeam-channel", "rand", "pin-project", "async-trait", "percent-encoding"]
3737
metrics = ["opentelemetry-api/metrics", "dashmap", "fnv"]
38-
serialize = ["opentelemetry-api/serialize", "serde"]
3938
testing = ["opentelemetry-api/testing", "trace", "metrics", "rt-async-std", "rt-tokio", "rt-tokio-current-thread", "tokio/macros", "tokio/rt-multi-thread"]
4039
rt-tokio = ["tokio", "tokio-stream"]
4140
rt-tokio-current-thread = ["tokio", "tokio-stream"]

0 commit comments

Comments
 (0)