Skip to content

Commit

Permalink
Move experimental features to separate folder (#134)
Browse files Browse the repository at this point in the history
  • Loading branch information
tensorchen authored Jun 16, 2020
1 parent b609ada commit 3a74399
Show file tree
Hide file tree
Showing 12 changed files with 61 additions and 13 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@ tokio = { version = "0.2", features = ["full"] }

[features]
default = ["metrics", "trace"]
base64_format = ["base64"]
base64_format = ["base64", "binary_propagator"]
trace = ["futures", "rand", "pin-project"]
metrics = ["prometheus"]
serialize = ["serde", "bincode"]
binary_propagator = []

[workspace]
members = [
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-zipkin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,14 @@ fn into_zipkin_span(config: &ExporterConfig, span_data: Arc<trace::SpanData>) ->
span_data
.start_time
.duration_since(SystemTime::UNIX_EPOCH)
.unwrap_or(Duration::from_secs(0))
.unwrap_or_else(|_| Duration::from_secs(0))
.as_micros() as u64,
)
.duration(
span_data
.end_time
.duration_since(span_data.start_time)
.unwrap_or(Duration::from_secs(0))
.unwrap_or_else(|_| Duration::from_secs(0))
.as_micros() as u64,
)
.local_endpoint(config.local_endpoint.clone())
Expand Down
2 changes: 1 addition & 1 deletion scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
set -eu

cargo test --all "$@"
cargo test --all "$@" --features="default serialize base64_format"
cargo test --all "$@" --features="default serialize base64_format binary_propagator"
3 changes: 0 additions & 3 deletions src/api/context/propagation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,6 @@
use crate::api;
use std::collections::HashMap;

#[cfg(feature = "base64")]
pub mod base64_format;
pub mod binary_propagator;
pub mod composite_propagator;
pub mod text_propagator;

Expand Down
5 changes: 1 addition & 4 deletions src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,9 @@ pub mod metrics;
pub mod trace;

pub use self::core::{Key, KeyValue, Unit, Value};
#[cfg(feature = "base64_format")]
pub use context::propagation::base64_format::Base64Format;
pub use context::{
propagation::{
binary_propagator::BinaryFormat, composite_propagator::HttpTextCompositePropagator,
text_propagator::HttpTextFormat, Carrier,
composite_propagator::HttpTextCompositePropagator, text_propagator::HttpTextFormat, Carrier,
},
Context,
};
Expand Down
3 changes: 3 additions & 0 deletions src/experimental/api/context/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
//! # OpenTelemetry Experimental Context API
pub mod propagation;
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
//! and deserializes values from base64 strings. There is a blanket implementation
//! for any implementors of `BinaryFormat`
use crate::api;
use crate::api::BinaryFormat;
#[cfg(feature = "binary_propagator")]
use crate::experimental::api::BinaryFormat;
use base64::{decode, encode};

/// Used to serialize and deserialize `SpanContext`s to and from a base64
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ impl BinaryFormat for BinaryPropagator {
#[cfg(test)]
mod tests {
use super::*;
use crate::api::BinaryFormat;

#[rustfmt::skip]
fn to_bytes_data() -> Vec<(api::SpanContext, [u8; 29])> {
Expand Down
38 changes: 38 additions & 0 deletions src/experimental/api/context/propagation/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//! # OpenTelemetry Experimental Propagator interface
//!
//! ## Binary Format
//!
//! `BinaryFormat` is a formatter to serialize and deserialize a value
//! into a binary format.
//!
//! `BinaryFormat` MUST expose the APIs that serializes values into bytes,
//! and deserializes values from bytes.
//!
//! ### ToBytes
//!
//! Serializes the given value into the on-the-wire representation.
//!
//! Required arguments:
//!
//! - the value to serialize, can be `SpanContext` or `DistributedContext`.
//!
//! Returns the on-the-wire byte representation of the value.
//!
//! ### FromBytes
//!
//! Creates a value from the given on-the-wire encoded representation.
//!
//! If the value could not be parsed, the underlying implementation
//! SHOULD decide to return ether an empty value, an invalid value, or
//! a valid value.
//!
//! Required arguments:
//!
//! - on-the-wire byte representation of the value.
//!
//! Returns a value deserialized from bytes.
//!
#[cfg(feature = "base64")]
pub mod base64_format;
pub mod binary_propagator;
8 changes: 8 additions & 0 deletions src/experimental/api/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//! ## OpenTelemetry Experimental API: What applications use and SDKs implement.
pub mod context;

#[cfg(feature = "base64_format")]
pub use context::propagation::base64_format::Base64Format;
#[cfg(feature = "binary_propagator")]
pub use context::propagation::binary_propagator::BinaryFormat;
3 changes: 3 additions & 0 deletions src/experimental/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
//! # OpenTelemetry Experimental Features
pub mod api;
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@
#![cfg_attr(test, deny(warnings))]

pub mod api;
pub mod experimental;
pub mod exporter;
pub mod global;
pub mod sdk;

0 comments on commit 3a74399

Please sign in to comment.