Skip to content

Commit

Permalink
Minimal dependencies (open-telemetry#413)
Browse files Browse the repository at this point in the history
  • Loading branch information
djc authored Jan 5, 2021
1 parent 5af183f commit 1bfaef0
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 11 deletions.
10 changes: 5 additions & 5 deletions opentelemetry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ rustdoc-args = ["--cfg", "docsrs"]
[dependencies]
async-std = { version = "1.6", features = ["unstable"], default-features = false, optional = true }
async-trait = { version = "0.1", optional = true }
bincode = { version = "1.2", optional = true }
dashmap = { version = "4.0.1", optional = true }
fnv = { version = "1.0", optional = true }
futures = "0.3"
Expand All @@ -33,7 +32,7 @@ pin-project = { version = "1.0.2", optional = true }
rand = { version = "0.8", default-features = false, features = ["std", "std_rng"], optional = true }
serde = { version = "1.0", features = ["derive", "rc"], optional = true }
http = { version = "0.2", optional = true }
thiserror = { version = "1.0", optional = true }
thiserror = "1"
tokio = { version = "0.2", default-features = false, features = ["rt-core", "blocking", "time", "stream"], optional = true }
tonic = { version = "0.3", default-features = false, optional = true }
reqwest = { version = "0.10", default-features = false, features = ["blocking"], optional = true }
Expand All @@ -43,15 +42,16 @@ surf = { version = "2.0", default-features = false, optional = true }
js-sys = "0.3"

[dev-dependencies]
bincode = "1.2"
criterion = "0.3.1"
rand_distr = "0.4.0"
tokio = { version = "0.2", features = ["full"] }

[features]
default = ["trace"]
trace = ["rand", "pin-project", "async-trait", "percent-encoding", "thiserror"]
metrics = ["thiserror", "dashmap", "fnv"]
serialize = ["serde", "bincode"]
trace = ["rand", "pin-project", "async-trait", "percent-encoding"]
metrics = ["dashmap", "fnv"]
serialize = ["serde"]
testing = ["trace", "metrics", "tokio/full" ]

[[bench]]
Expand Down
3 changes: 3 additions & 0 deletions opentelemetry/src/api/baggage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
//! # Examples
//!
//! ```
//! # #[cfg(feature = "trace")]
//! # {
//! use opentelemetry::{baggage::BaggageExt, Key, propagation::TextMapPropagator};
//! use opentelemetry::sdk::propagation::BaggagePropagator;
//! use std::collections::HashMap;
Expand All @@ -41,6 +43,7 @@
//! let header_value = headers.get("baggage").expect("header is injected");
//! assert!(header_value.contains("user_id=1"), "still contains previous name-value");
//! assert!(header_value.contains("server_id=42"), "contains new name-value pair");
//! # }
//! ```
use crate::{Context, Key, KeyValue, Value};
#[cfg(feature = "serialize")]
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry/src/api/trace/noop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ impl SpanExporter for NoopSpanExporter {
}
}

#[cfg(test)]
#[cfg(all(test, feature = "testing", feature = "trace"))]
mod tests {
use super::*;
use crate::testing::trace::TestSpan;
Expand Down
6 changes: 6 additions & 0 deletions opentelemetry/src/global/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
//! or calling [`set_tracer_provider`].
//!
//! ```
//! # #[cfg(feature="trace")]
//! # {
//! use opentelemetry::trace::{Tracer, NoopTracerProvider};
//! use opentelemetry::global;
//!
Expand All @@ -39,11 +41,14 @@
//! // in main or other app start
//! let _guard = init_tracer();
//! do_something_tracked();
//! # }
//! ```
//!
//! ### Usage in Libraries
//!
//! ```
//! # #[cfg(feature="trace")]
//! # {
//! use opentelemetry::trace::Tracer;
//! use opentelemetry::global;
//!
Expand All @@ -56,6 +61,7 @@
//! // Traced library logic here...
//! });
//! }
//! # }
//! ```
//!
//! [installing a trace pipeline]: crate::sdk::export::trace::stdout::PipelineBuilder::install
Expand Down
4 changes: 4 additions & 0 deletions opentelemetry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
//! ## Getting Started
//!
//! ```no_run
//! # #[cfg(feature = "trace")]
//! # {
//! use opentelemetry::{sdk::export::trace::stdout, trace::Tracer};
//!
//! fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
Expand All @@ -25,6 +27,7 @@
//!
//! Ok(())
//! }
//! }
//! ```
//!
//! See the [examples](https://github.com/open-telemetry/opentelemetry-rust/tree/master/examples)
Expand Down Expand Up @@ -181,6 +184,7 @@ pub use api::{
propagation,
};

#[cfg(any(feature = "metrics", feature = "trace"))]
pub(crate) mod time {
use std::time::SystemTime;

Expand Down
2 changes: 1 addition & 1 deletion opentelemetry/src/sdk/propagation/composite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ impl TextMapPropagator for TextMapCompositePropagator {
}
}

#[cfg(test)]
#[cfg(all(test, feature = "testing", feature = "trace"))]
mod tests {
use crate::sdk::propagation::{TextMapCompositePropagator, TraceContextPropagator};
use crate::testing::trace::TestSpan;
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry/src/sdk/propagation/trace_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ impl TextMapPropagator for TraceContextPropagator {
}
}

#[cfg(test)]
#[cfg(all(test, feature = "testing", feature = "trace"))]
mod tests {
use super::*;
use crate::testing::trace::TestSpan;
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry/src/sdk/trace/sampler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ impl ShouldSample for Sampler {
}
}

#[cfg(test)]
#[cfg(all(test, feature = "testing", feature = "trace"))]
mod tests {
use super::*;
use crate::sdk::trace::{Sampler, SamplingDecision, ShouldSample};
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry/src/sdk/trace/span_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ where
}
}

#[cfg(test)]
#[cfg(all(test, feature = "testing", feature = "trace"))]
mod tests {
use std::fmt::Debug;
use std::time;
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry/src/sdk/trace/tracer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ impl crate::trace::Tracer for Tracer {
}
}

#[cfg(test)]
#[cfg(all(test, feature = "testing", feature = "trace"))]
mod tests {
use crate::{
sdk::{
Expand Down
1 change: 1 addition & 0 deletions scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set -eu
cargo test --all "$@"

# See https://github.com/rust-lang/cargo/issues/5364
cargo test --manifest-path=opentelemetry/Cargo.toml --no-default-features
cargo test --manifest-path=opentelemetry/Cargo.toml --all-features
cargo test --manifest-path=opentelemetry-contrib/Cargo.toml --all-features
cargo test --manifest-path=opentelemetry-jaeger/Cargo.toml --all-features
Expand Down

0 comments on commit 1bfaef0

Please sign in to comment.