Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move 3rd party propagators and merge exporter into sdk::export #375

Merged
merged 11 commits into from
Dec 7, 2020
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
override: true
- name: Run tests
run: cargo --version &&
cargo test --verbose --manifest-path=opentelemetry/Cargo.toml --features trace,metrics,serialize,tokio,serde,http,tonic,reqwest &&
cargo test --verbose --manifest-path=opentelemetry/Cargo.toml --features trace,metrics,serialize,tokio,serde,http,tonic,reqwest,testing &&
cargo test --manifest-path=opentelemetry-jaeger/Cargo.toml &&
cargo test --manifest-path=opentelemetry-zipkin/Cargo.toml
meta:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ observability tools.
## Getting Started

```rust
use opentelemetry::{exporter::trace::stdout, trace::Tracer};
use opentelemetry::{sdk::export::trace::stdout, trace::Tracer};

fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
// Create a new instrumentation pipeline
Expand Down
2 changes: 1 addition & 1 deletion examples/aws-xray/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ path = "src/client.rs"
hyper = "0.13"
tokio = { version = "0.2", features = ["full"] }
opentelemetry = { path = "../../opentelemetry", features = ["http"] }
opentelemetry-contrib = { path = "../../opentelemetry-contrib" }
opentelemetry-contrib = { path = "../../opentelemetry-contrib", features = ["aws-xray"] }
5 changes: 3 additions & 2 deletions examples/aws-xray/src/client.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use hyper::{body::Body, Client};
use opentelemetry::{
exporter::trace::stdout,
global,
sdk::{propagation::XrayPropagator, trace as sdktrace},
sdk::export::trace::stdout,
sdk::trace as sdktrace,
trace::{TraceContextExt, Tracer},
Context, KeyValue,
};
use opentelemetry_contrib::trace::propagator::XrayPropagator;

fn init_tracer() -> (sdktrace::Tracer, stdout::Uninstall) {
global::set_text_map_propagator(XrayPropagator::new());
Expand Down
5 changes: 3 additions & 2 deletions examples/aws-xray/src/server.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use hyper::service::{make_service_fn, service_fn};
use hyper::{Body, Request, Response, Server};
use opentelemetry::{
exporter::trace::stdout,
global,
sdk::{propagation::XrayPropagator, trace as sdktrace},
sdk::export::trace::stdout,
sdk::trace as sdktrace,
trace::{Span, Tracer},
};
use opentelemetry_contrib::trace::propagator::XrayPropagator;
use std::{convert::Infallible, net::SocketAddr};

async fn handle(req: Request<Body>) -> Result<Response<Body>, Infallible> {
Expand Down
3 changes: 1 addition & 2 deletions examples/basic-otlp/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use futures::stream::{Stream, StreamExt};
use opentelemetry::exporter;
use opentelemetry::sdk::metrics::PushController;
use opentelemetry::trace::TraceError;
use opentelemetry::{
Expand All @@ -22,7 +21,7 @@ fn delayed_interval(duration: Duration) -> impl Stream<Item = tokio::time::Insta
}

fn init_meter() -> metrics::Result<PushController> {
exporter::metrics::stdout(tokio::spawn, delayed_interval)
opentelemetry::sdk::export::metrics::stdout(tokio::spawn, delayed_interval)
.with_quantiles(vec![0.5, 0.9, 0.99])
.with_formatter(|batch| {
serde_json::to_value(batch)
Expand Down
3 changes: 1 addition & 2 deletions examples/basic/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use futures::stream::{Stream, StreamExt};
use opentelemetry::exporter;
use opentelemetry::global;
use opentelemetry::sdk::{metrics::PushController, trace as sdktrace};
use opentelemetry::trace::TraceError;
Expand Down Expand Up @@ -28,7 +27,7 @@ fn delayed_interval(duration: Duration) -> impl Stream<Item = tokio::time::Insta
}

fn init_meter() -> metrics::Result<PushController> {
exporter::metrics::stdout(tokio::spawn, delayed_interval)
opentelemetry::sdk::export::metrics::stdout(tokio::spawn, delayed_interval)
.with_quantiles(vec![0.5, 0.9, 0.99])
.with_formatter(|batch| {
serde_json::to_value(batch)
Expand Down
2 changes: 1 addition & 1 deletion examples/http/src/client.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use hyper::{body::Body, Client};
use opentelemetry::exporter::trace::stdout;
use opentelemetry::global;
use opentelemetry::sdk::export::trace::stdout;
use opentelemetry::sdk::{
propagation::TraceContextPropagator,
trace::{Config, Sampler},
Expand Down
2 changes: 1 addition & 1 deletion examples/http/src/server.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use hyper::service::{make_service_fn, service_fn};
use hyper::{Body, Request, Response, Server};
use opentelemetry::{
exporter::trace::stdout,
global,
sdk::export::trace::stdout,
sdk::{
propagation::TraceContextPropagator,
trace::{Config, Sampler},
Expand Down
2 changes: 1 addition & 1 deletion examples/stdout.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use opentelemetry::{
exporter::trace::stdout,
sdk::export::trace::stdout,
sdk::trace::{self, Sampler},
trace::Tracer,
};
Expand Down
4 changes: 4 additions & 0 deletions opentelemetry-contrib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ datadog = ["indexmap", "rmp", "async-trait", "thiserror"]
reqwest-blocking-client = ["reqwest/blocking", "opentelemetry/reqwest"]
reqwest-client = ["reqwest", "opentelemetry/reqwest"]
surf-client = ["surf", "opentelemetry/surf"]
jaeger = []
zipkin = []
aws-xray = []

[dependencies]
async-trait = { version = "0.1", optional = true }
Expand All @@ -42,3 +45,4 @@ thiserror = { version = "1.0", optional = true }
[dev-dependencies]
base64 = "0.13"
isahc = "0.9"
opentelemetry = { path = "../opentelemetry", features = ["trace", "http", "testing"] }
8 changes: 4 additions & 4 deletions opentelemetry-contrib/src/trace/exporter/datadog/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@
//! ```no_run
//! use opentelemetry::{KeyValue, trace::Tracer};
//! use opentelemetry::sdk::{trace::{self, IdGenerator, Sampler}, Resource};
//! use opentelemetry::exporter::trace::ExportResult;
//! use opentelemetry::exporter::trace::HttpClient;
//! use opentelemetry::sdk::export::trace::ExportResult;
//! use opentelemetry::sdk::export::trace::HttpClient;
//! use opentelemetry_contrib::trace::exporter::datadog::{new_pipeline, ApiVersion};
//! use async_trait::async_trait;
//! use opentelemetry_contrib::trace::exporter::datadog::Error;
Expand Down Expand Up @@ -127,8 +127,8 @@ pub use model::Error;

use async_trait::async_trait;
use http::{Method, Request, Uri};
use opentelemetry::exporter::trace;
use opentelemetry::exporter::trace::{HttpClient, SpanData};
use opentelemetry::sdk::export::trace;
use opentelemetry::sdk::export::trace::{HttpClient, SpanData};
use opentelemetry::trace::TraceError;
use opentelemetry::{global, sdk, trace::TracerProvider};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use opentelemetry::exporter::{trace, ExportError};
use opentelemetry::sdk::export::{trace, ExportError};

mod v03;
mod v05;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::trace::exporter::datadog::model::Error;
use opentelemetry::exporter::trace;
use opentelemetry::sdk::export::trace;
use opentelemetry::{Key, Value};
use std::time::SystemTime;

Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-contrib/src/trace/exporter/datadog/model/v05.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::trace::exporter::datadog::intern::StringInterner;
use crate::trace::exporter::datadog::model::Error;
use opentelemetry::exporter::trace;
use crate::trace::exporter::datadog::Error;
use opentelemetry::sdk::export::trace;
use opentelemetry::{Key, Value};
use std::time::SystemTime;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{
use opentelemetry::{
propagation::{text_map_propagator::FieldIter, Extractor, Injector, TextMapPropagator},
trace::{
SpanContext, SpanId, TraceContextExt, TraceId, TraceState, TRACE_FLAG_DEFERRED,
Expand Down Expand Up @@ -32,7 +32,7 @@ lazy_static::lazy_static! {
///
/// ```
/// use opentelemetry::global;
/// use opentelemetry::sdk::propagation::XrayPropagator;
/// use opentelemetry_contrib::trace::propagator::XrayPropagator;
///
/// global::set_text_map_propagator(XrayPropagator::default());
/// ```
Expand Down Expand Up @@ -236,8 +236,8 @@ fn title_case(s: &str) -> String {
#[cfg(test)]
mod tests {
use super::*;
use crate::testing::trace::TestSpan;
use crate::trace::TraceState;
use opentelemetry::testing::trace::TestSpan;
use opentelemetry::trace::TraceState;
use std::collections::HashMap;
use std::str::FromStr;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//!
//! If `inject_encoding` is set to `B3Encoding::SingleHeader` then `b3` header is used to inject
//! and extract. Otherwise, separate headers are used to inject and extract.
use crate::{
use opentelemetry::{
propagation::{text_map_propagator::FieldIter, Extractor, Injector, TextMapPropagator},
trace::{
SpanContext, SpanId, TraceContextExt, TraceId, TraceState, TRACE_FLAG_DEBUG,
Expand Down Expand Up @@ -302,9 +302,9 @@ impl TextMapPropagator for B3Propagator {
#[cfg(test)]
mod tests {
use super::*;
use crate::testing::trace::TestSpan;
use crate::{
use opentelemetry::{
propagation::TextMapPropagator,
testing::trace::TestSpan,
trace::{
SpanContext, SpanId, TraceId, TRACE_FLAG_DEBUG, TRACE_FLAG_DEFERRED,
TRACE_FLAG_NOT_SAMPLED, TRACE_FLAG_SAMPLED,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//! See [`Jaeger documentation`] for detail of Jaeger propagation format.
//!
//! [`Jaeger documentation`]: https://www.jaegertracing.io/docs/1.18/client-libraries/#propagation-format
use crate::{
use opentelemetry::{
propagation::{text_map_propagator::FieldIter, Extractor, Injector, TextMapPropagator},
trace::{
SpanContext, SpanId, TraceContextExt, TraceId, TraceState, TRACE_FLAG_DEBUG,
Expand Down Expand Up @@ -174,9 +174,9 @@ impl TextMapPropagator for JaegerPropagator {
#[cfg(test)]
mod tests {
use super::*;
use crate::testing::trace::TestSpan;
use crate::{
use opentelemetry::{
propagation::{Injector, TextMapPropagator},
testing::trace::TestSpan,
trace::{
SpanContext, SpanId, TraceContextExt, TraceId, TraceState, TRACE_FLAG_DEBUG,
TRACE_FLAG_NOT_SAMPLED, TRACE_FLAG_SAMPLED,
Expand Down
18 changes: 18 additions & 0 deletions opentelemetry-contrib/src/trace/propagator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,22 @@
//! Currently, the following propagators are supported:
//!
//! * `binary_propagator`, propagating trace context in the binary format.
//! * `XrayPropagator`, propagating via AWS XRay protocol.
//! * `B3Propagator`, propagating via B3 protocol and headers.
jtescher marked this conversation as resolved.
Show resolved Hide resolved
//! * `JaegerPropagator`, propagating via Jaeger protocol and headers.
//!
//! This module also provides relative types for those propagators.
#[cfg(feature = "aws-xray")]
mod aws;
#[cfg(feature = "zipkin")]
mod b3;
pub mod binary;
#[cfg(feature = "jaeger")]
mod jaeger;

#[cfg(feature = "aws-xray")]
pub use aws::XrayPropagator;
#[cfg(feature = "zipkin")]
pub use b3::{B3Encoding, B3Propagator};
#[cfg(feature = "jaeger")]
pub use jaeger::JaegerPropagator;
4 changes: 2 additions & 2 deletions opentelemetry-jaeger/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,11 @@ use agent::AgentAsyncClientUDP;
use async_trait::async_trait;
#[cfg(any(feature = "collector_client", feature = "wasm_collector_client"))]
use collector::CollectorAsyncClientHttp;
use opentelemetry::exporter::ExportError;
use opentelemetry::sdk::export::ExportError;
use opentelemetry::trace::TraceError;
use opentelemetry::{
exporter::trace,
global, sdk,
sdk::export::trace,
trace::{Event, Link, SpanKind, StatusCode, TracerProvider},
Key, KeyValue, Value,
};
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-jaeger/src/uploader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#[cfg(any(feature = "collector_client", feature = "wasm_collector_client"))]
use crate::collector;
use crate::{agent, jaeger};
use opentelemetry::exporter::trace;
use opentelemetry::sdk::export::trace;

/// Uploads a batch of spans to Jaeger
#[derive(Debug)]
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-otlp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ mod span;
mod transform;

pub use crate::span::{Compression, Credentials, Exporter, ExporterConfig, Protocol};
use opentelemetry::exporter::ExportError;
use opentelemetry::sdk::export::ExportError;
use opentelemetry::trace::TraceError;

/// Create a new pipeline builder with the recommended configuration.
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-otlp/src/proto/common.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file is generated by rust-protobuf 2.18.0. Do not edit
// This file is generated by rust-protobuf 2.18.1. Do not edit
// @generated

// https://github.com/rust-lang/rust-clippy/issues/702
Expand All @@ -21,7 +21,7 @@

/// Generated files are compatible only with the same version
/// of protobuf runtime.
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_18_0;
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_18_1;

#[derive(PartialEq,Clone,Default)]
#[cfg_attr(feature = "with-serde", derive(Serialize, Deserialize))]
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-otlp/src/proto/metrics.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file is generated by rust-protobuf 2.18.0. Do not edit
// This file is generated by rust-protobuf 2.18.1. Do not edit
// @generated

// https://github.com/rust-lang/rust-clippy/issues/702
Expand All @@ -21,7 +21,7 @@

/// Generated files are compatible only with the same version
/// of protobuf runtime.
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_18_0;
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_18_1;

#[derive(PartialEq,Clone,Default)]
#[cfg_attr(feature = "with-serde", derive(Serialize, Deserialize))]
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-otlp/src/proto/metrics_service.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file is generated by rust-protobuf 2.18.0. Do not edit
// This file is generated by rust-protobuf 2.18.1. Do not edit
// @generated

// https://github.com/rust-lang/rust-clippy/issues/702
Expand All @@ -21,7 +21,7 @@

/// Generated files are compatible only with the same version
/// of protobuf runtime.
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_18_0;
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_18_1;

#[derive(PartialEq,Clone,Default)]
#[cfg_attr(feature = "with-serde", derive(Serialize, Deserialize))]
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-otlp/src/proto/resource.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file is generated by rust-protobuf 2.18.0. Do not edit
// This file is generated by rust-protobuf 2.18.1. Do not edit
// @generated

// https://github.com/rust-lang/rust-clippy/issues/702
Expand All @@ -21,7 +21,7 @@

/// Generated files are compatible only with the same version
/// of protobuf runtime.
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_18_0;
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_18_1;

#[derive(PartialEq,Clone,Default)]
#[cfg_attr(feature = "with-serde", derive(Serialize, Deserialize))]
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-otlp/src/proto/trace.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file is generated by rust-protobuf 2.18.0. Do not edit
// This file is generated by rust-protobuf 2.18.1. Do not edit
// @generated

// https://github.com/rust-lang/rust-clippy/issues/702
Expand All @@ -21,7 +21,7 @@

/// Generated files are compatible only with the same version
/// of protobuf runtime.
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_18_0;
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_18_1;

#[derive(PartialEq,Clone,Default)]
#[cfg_attr(feature = "with-serde", derive(Serialize, Deserialize))]
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-otlp/src/proto/trace_config.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file is generated by rust-protobuf 2.18.0. Do not edit
// This file is generated by rust-protobuf 2.18.1. Do not edit
// @generated

// https://github.com/rust-lang/rust-clippy/issues/702
Expand All @@ -21,7 +21,7 @@

/// Generated files are compatible only with the same version
/// of protobuf runtime.
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_18_0;
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_18_1;

#[derive(PartialEq,Clone,Default)]
#[cfg_attr(feature = "with-serde", derive(Serialize, Deserialize))]
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-otlp/src/proto/trace_service.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file is generated by rust-protobuf 2.18.0. Do not edit
// This file is generated by rust-protobuf 2.18.1. Do not edit
// @generated

// https://github.com/rust-lang/rust-clippy/issues/702
Expand All @@ -21,7 +21,7 @@

/// Generated files are compatible only with the same version
/// of protobuf runtime.
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_18_0;
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_18_1;

#[derive(PartialEq,Clone,Default)]
#[cfg_attr(feature = "with-serde", derive(Serialize, Deserialize))]
Expand Down
Loading